muc-history-settings.jsp 6.95 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3
<%--
  -	$Revision$
  -	$Date$
Bill Lynch's avatar
Bill Lynch committed
4
  -
5
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
6
  -
7 8 9 10 11 12 13 14 15 16 17 18
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.

Matt Tucker's avatar
Matt Tucker committed
19
--%>
Bill Lynch's avatar
Bill Lynch committed
20

Matt Tucker's avatar
Matt Tucker committed
21 22
<%@ page import="org.jivesoftware.util.*,
                 java.util.*,                  
23
                 org.jivesoftware.openfire.muc.HistoryStrategy,
24
                 org.jivesoftware.openfire.muc.MultiUserChatService"
Bill Lynch's avatar
Bill Lynch committed
25 26
    errorPage="error.jsp"
%>
27
<%@ page import="java.net.URLEncoder" %>
Bill Lynch's avatar
Bill Lynch committed
28

29
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
30
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
Bill Lynch's avatar
Bill Lynch committed
31

Matt Tucker's avatar
Matt Tucker committed
32 33 34 35 36 37 38
<%!  // Global vars and methods:

    // Strategy definitions:
    static final int ALL = 1;
    static final int NONE = 2;
    static final int NUMBER = 3;
%>
Bill Lynch's avatar
Bill Lynch committed
39

40 41
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/>
<%  webManager.init(request, response, session, application, out ); %>
Bill Lynch's avatar
Bill Lynch committed
42

Matt Tucker's avatar
Matt Tucker committed
43 44 45 46
<%   // Get parameters:
    boolean update = request.getParameter("update") != null;
    int policy = ParamUtils.getIntParameter(request,"policy",-1);
    int numMessages = ParamUtils.getIntParameter(request,"numMessages",0);
47
    String mucname = ParamUtils.getParameter(request,"mucname");
Matt Tucker's avatar
Matt Tucker committed
48

49 50 51 52 53 54 55 56 57 58
    if (!webManager.getMultiUserChatManager().isServiceRegistered(mucname)) {
        // The requested service name does not exist so return to the list of the existing rooms
        response.sendRedirect("muc-service-summary.jsp");
        return;
    }

    // Get muc server
    MultiUserChatService mucService = webManager.getMultiUserChatManager().getMultiUserChatService(mucname);
    
    HistoryStrategy historyStrat = mucService.getHistoryStrategy();
Matt Tucker's avatar
Matt Tucker committed
59

60
    Map<String,String> errors = new HashMap<String,String>();
Matt Tucker's avatar
Matt Tucker committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    if (update) {
        if (policy != ALL && policy != NONE && policy != NUMBER) {
            errors.put("general", "Please choose a valid chat history policy.");
        }
        else {
            if (policy == NUMBER && numMessages <= 0) {
                errors.put("numMessages", "Please enter a valid number of messages.");
            }
        }
        if (errors.size() == 0) {
            if (policy == ALL) {
                // Update MUC history strategy
                historyStrat.setType(HistoryStrategy.Type.all);
            }
            else if (policy == NONE) {
                // Update MUC history strategy
                historyStrat.setType(HistoryStrategy.Type.none);
            }
            else if (policy == NUMBER) {
                // Update MUC history strategy
                historyStrat.setType(HistoryStrategy.Type.number);
                historyStrat.setMaxNumber(numMessages);
            }
84
            // Log the event
85
            webManager.logEvent("set MUC history settings for service "+mucname, "type = "+policy+"\nmax messages = "+numMessages);
Matt Tucker's avatar
Matt Tucker committed
86
            // All done, redirect
87
            response.sendRedirect("muc-history-settings.jsp?success=true&mucname="+URLEncoder.encode(mucname, "UTF-8"));
Bill Lynch's avatar
Bill Lynch committed
88
            return;
Matt Tucker's avatar
Matt Tucker committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
        }
    }

    // Set page vars
    if (errors.size() == 0) {
        if (historyStrat.getType() == HistoryStrategy.Type.all) {
            policy = ALL;
        }
        else if (historyStrat.getType() == HistoryStrategy.Type.none) {
            policy = NONE;
        }
        else if (historyStrat.getType() == HistoryStrategy.Type.number) {
            policy = NUMBER;
        }
        numMessages = historyStrat.getMaxNumber();
    }
%>
Derek DeMoro's avatar
Derek DeMoro committed
106

107
<html>
108 109
<head>
<title><fmt:message key="groupchat.history.settings.title"/></title>
110 111
<meta name="subPageID" content="muc-history"/>
<meta name="extraParams" content="<%= "mucname="+URLEncoder.encode(mucname, "UTF-8") %>"/>
112 113 114
<meta name="helpPage" content="edit_group_chat_history_settings.html"/>
</head>
<body>
Bill Lynch's avatar
Bill Lynch committed
115 116

<p>
117
<fmt:message key="groupchat.history.settings.introduction" />
Sven Tantau's avatar
Sven Tantau committed
118
<fmt:message key="groupchat.service.settings_affect" /> <b><a href="muc-service-edit-form.jsp?mucname=<%= URLEncoder.encode(mucname, "UTF-8") %>"><%= StringUtils.escapeHTMLTags(mucname) %></a></b>
Bill Lynch's avatar
Bill Lynch committed
119 120 121 122 123 124 125
</p>

<%  if ("true".equals(request.getParameter("success"))) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
126
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
127
        <td class="jive-icon-label">
128
        <fmt:message key="groupchat.history.settings.saved_successfully" />
Bill Lynch's avatar
Bill Lynch committed
129 130 131 132 133 134 135
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

136
<!-- BEGIN 'History Settings' -->
Bill Lynch's avatar
Bill Lynch committed
137
<form action="muc-history-settings.jsp" method="post">
Sven Tantau's avatar
Sven Tantau committed
138
    <input type="hidden" name="mucname" value="<%= StringUtils.escapeForXML(mucname) %>" />
139
    <div class="jive-contentBoxHeader">
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
		<fmt:message key="groupchat.history.settings.legend" />
	</div>
	<div class="jive-contentBox">
		<table cellpadding="3" cellspacing="0" border="0" >
		<tbody>
			<tr valign="middle" class="">
				<td width="1%" nowrap>
					<input type="radio" name="policy" value="<%= NONE %>" id="rb01"  <%= ((policy==NONE) ? "checked" : "") %> />
				</td>
				<td width="99%">
					<label for="rb01">
					<b><fmt:message key="groupchat.history.settings.label1_no_history" /></b>
					</label><fmt:message key="groupchat.history.settings.label2_no_history" />
				</td>
			</tr>
			<tr valign="middle">
				<td width="1%" nowrap>
					<input type="radio" name="policy" value="<%= ALL %>" id="rb02"  <%= ((policy==ALL) ? "checked" : "") %>/>
				</td>
				<td width="99%">
					<label for="rb02">
					<b><fmt:message key="groupchat.history.settings.label1_entire_history" /></b>
					</label><fmt:message key="groupchat.history.settings.label2_entire_history" />
				</td>
			</tr>
			<tr valign="top">
				<td width="1%" nowrap>
					<input type="radio" name="policy" value="<%= NUMBER %>" id="rb03"  <%= ((policy==NUMBER) ? "checked" : "") %> />
				</td>
				<td width="99%">
					<label for="rb03">
					<b><fmt:message key="groupchat.history.settings.label1_number_messages" /></b>
					</label><fmt:message key="groupchat.history.settings.label2_number_messages" />
				</td>
			</tr>
			<tr valign="middle" class="">
				<td width="1%" nowrap>&nbsp;</td>
				<td width="99%">
					<input type="text" name="numMessages" size="5" maxlength="10" onclick="this.form.policy[2].checked=true;" value="<%= ((numMessages > 0) ? ""+numMessages : "") %>"/> <fmt:message key="groupchat.history.settings.messages" />
				</td>
			</tr>
		</tbody>
		</table>
	</div>
Matt Tucker's avatar
Matt Tucker committed
184
    <input type="submit" name="update" value="<fmt:message key="groupchat.history.settings.save" />"/>
Matt Tucker's avatar
Matt Tucker committed
185
</form>
186 187
<!-- END 'History Settings' -->

Matt Tucker's avatar
Matt Tucker committed
188

189
</body>
Sven Tantau's avatar
Sven Tantau committed
190
</html>