muc-tasks.jsp 8.79 KB
Newer Older
Gaston Dombiak's avatar
Gaston Dombiak committed
1 2 3 4
<%--
  -	$Revision$
  -	$Date$
  -
5
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
Gaston Dombiak's avatar
Gaston Dombiak committed
6 7
  -
  - This software is published under the terms of the GNU Public License (GPL),
8 9
  - a copy of which is included in this distribution, or a commercial license
  - agreement with Jive.
Gaston Dombiak's avatar
Gaston Dombiak committed
10 11 12 13
--%>

<%@ page import="org.jivesoftware.util.*,
                 java.util.*,
14
                 org.jivesoftware.openfire.muc.MultiUserChatService"
Gaston Dombiak's avatar
Gaston Dombiak committed
15 16
    errorPage="error.jsp"
%>
17
<%@ page import="java.net.URLEncoder" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
18

19
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
20
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
21 22 23

<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
Gaston Dombiak's avatar
Gaston Dombiak committed
24 25 26 27 28 29 30 31 32 33

<%  // Get parameters
    boolean kickEnabled = ParamUtils.getBooleanParameter(request,"kickEnabled");
    String idletime = ParamUtils.getParameter(request,"idletime");
    String logfreq = ParamUtils.getParameter(request,"logfreq");
    String logbatchsize = ParamUtils.getParameter(request,"logbatchsize");
    boolean kickSettings = request.getParameter("kickSettings") != null;
    boolean logSettings = request.getParameter("logSettings") != null;
    boolean kickSettingSuccess = request.getParameter("kickSettingSuccess") != null;
    boolean logSettingSuccess = request.getParameter("logSettingSuccess") != null;
34
    String mucname = ParamUtils.getParameter(request,"mucname");
Gaston Dombiak's avatar
Gaston Dombiak committed
35

36 37 38 39 40 41 42 43
    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);
Gaston Dombiak's avatar
Gaston Dombiak committed
44

45
    Map<String, String> errors = new HashMap<String, String>();
Gaston Dombiak's avatar
Gaston Dombiak committed
46 47 48 49
    // Handle an update of the kicking task settings
    if (kickSettings) {
        if (!kickEnabled) {
            // Disable kicking users by setting a value of -1
50
            mucService.setUserIdleTime(-1);
51
            // Log the event
52
            webManager.logEvent("disabled muc idle kick timeout for service "+mucname, null);
53
            response.sendRedirect("muc-tasks.jsp?kickSettingSuccess=true&mucname="+URLEncoder.encode(mucname, "UTF-8"));
Gaston Dombiak's avatar
Gaston Dombiak committed
54 55 56 57 58 59 60 61 62 63
            return;
        }
        // do validation
        if (idletime == null) {
            errors.put("idletime","idletime");
        }
        int idle = 0;
        // Try to obtain an int from the provided strings
        if (errors.size() == 0) {
            try {
Matt Tucker's avatar
Matt Tucker committed
64
                idle = Integer.parseInt(idletime) * 1000 * 60;
Gaston Dombiak's avatar
Gaston Dombiak committed
65 66
            }
            catch (NumberFormatException e) {
Matt Tucker's avatar
Matt Tucker committed
67
                errors.put("idletime","idletime");
Gaston Dombiak's avatar
Gaston Dombiak committed
68
            }
Matt Tucker's avatar
Matt Tucker committed
69
            if (idle < 0) {
Gaston Dombiak's avatar
Gaston Dombiak committed
70 71 72 73 74
                errors.put("idletime","idletime");
            }
        }

        if (errors.size() == 0) {
75
            mucService.setUserIdleTime(idle);
76
            // Log the event
77
            webManager.logEvent("edited muc idle kick timeout for service "+mucname, "timeout = "+idle);
78
            response.sendRedirect("muc-tasks.jsp?kickSettingSuccess=true&mucname="+URLEncoder.encode(mucname, "UTF-8"));
Gaston Dombiak's avatar
Gaston Dombiak committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
            return;
        }
    }

    // Handle an update of the log conversations task settings
    if (logSettings) {
        // do validation
        if (logfreq == null) {
            errors.put("logfreq","logfreq");
        }
        if (logbatchsize == null) {
            errors.put("logbatchsize","logbatchsize");
        }
        int frequency = 0;
        int batchSize = 0;
        // Try to obtain an int from the provided strings
        if (errors.size() == 0) {
            try {
                frequency = Integer.parseInt(logfreq) * 1000;
            }
            catch (NumberFormatException e) {
                errors.put("logfreq","logfreq");
            }
            try {
                batchSize = Integer.parseInt(logbatchsize);
            }
            catch (NumberFormatException e) {
                errors.put("logbatchsize","logbatchsize");
            }
        }

        if (errors.size() == 0) {
111 112
            mucService.setLogConversationsTimeout(frequency);
            mucService.setLogConversationBatchSize(batchSize);
113
            // Log the event
114
            webManager.logEvent("edited muc conversation log settings for service "+mucname, "timeout = "+frequency+"\nbatchSize = "+batchSize);
115
            response.sendRedirect("muc-tasks.jsp?logSettingSuccess=true&mucname="+URLEncoder.encode(mucname, "UTF-8"));
Gaston Dombiak's avatar
Gaston Dombiak committed
116 117 118 119 120
            return;
        }
    }
%>

121
<html>
122 123
<head>
<title><fmt:message key="muc.tasks.title"/></title>
124 125
<meta name="subPageID" content="muc-tasks"/>
<meta name="extraParams" content="<%= "mucname="+URLEncoder.encode(mucname, "UTF-8") %>"/>
126 127 128
<meta name="helpPage" content="edit_idle_user_settings.html"/>
</head>
<body>
Gaston Dombiak's avatar
Gaston Dombiak committed
129 130

<p>
131
<fmt:message key="muc.tasks.info" />
132
<fmt:message key="groupchat.service.settings_affect" /> <b><a href="muc-service-edit-form.jsp?mucname=<%= URLEncoder.encode(mucname, "UTF-8") %>"><%= mucname %></a></b>
Gaston Dombiak's avatar
Gaston Dombiak committed
133 134 135 136 137 138 139
</p>

<%  if (kickSettingSuccess || logSettingSuccess) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
140
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
141 142 143
        <td class="jive-icon-label">
        <%  if (kickSettingSuccess) { %>

144
            <fmt:message key="muc.tasks.update" />
Gaston Dombiak's avatar
Gaston Dombiak committed
145 146 147

        <%  } else if (logSettingSuccess) { %>

148
            <fmt:message key="muc.tasks.log" />
Gaston Dombiak's avatar
Gaston Dombiak committed
149 150 151 152 153 154 155 156 157

        <%  } %>
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

Matt Tucker's avatar
Matt Tucker committed
158 159 160
<% if (errors.size() != 0) {  %>

   <table class="jive-error-message" cellpadding="3" cellspacing="0" border="0" width="350"> <tr valign="top">
161
    <td width="1%"><img src="images/error-16x16.gif" width="16" height="16" border="0" alt=""></td>
Matt Tucker's avatar
Matt Tucker committed
162 163 164
    <td width="99%" class="jive-error-text">

		<% if (errors.get("idletime") != null) { %>
165
                <fmt:message key="muc.tasks.valid_idel_minutes" />
Matt Tucker's avatar
Matt Tucker committed
166 167
        <% }
           else if (errors.get("logfreq") != null) { %>
168
                <fmt:message key="muc.tasks.valid_frequency" />
Matt Tucker's avatar
Matt Tucker committed
169 170
        <%  }
            else if (errors.get("logbatchsize") != null) { %>
171
                <fmt:message key="muc.tasks.valid_batch" />
Matt Tucker's avatar
Matt Tucker committed
172 173 174 175 176 177 178
            <%  } %>
    </td>
    </tr>
    </table><br>

<% } %>

Gaston Dombiak's avatar
Gaston Dombiak committed
179

180 181
<!-- BEGIN 'Idle User Settings' -->
<form action="muc-tasks.jsp?kickSettings" method="post">
182 183
    <input type="hidden" name="mucname" value="<%= mucname %>" />
    <div class="jive-contentBoxHeader">
184 185 186 187 188 189 190 191
		<fmt:message key="muc.tasks.user_setting" />
	</div>
	<div class="jive-contentBox">
		<table cellpadding="3" cellspacing="0" border="0">
		<tbody>
			<tr valign="middle">
				<td width="1%" nowrap>
					<input type="radio" name="kickEnabled" value="false" id="rb01"
192
					 <%= ((mucService.getUserIdleTime() < 0) ? "checked" : "") %>>
193 194 195 196 197 198 199 200
				</td>
				<td width="99%">
					<label for="rb01"><fmt:message key="muc.tasks.never_kick" /></label>
				</td>
			</tr>
			<tr valign="middle">
				<td width="1%" nowrap>
					<input type="radio" name="kickEnabled" value="true" id="rb02"
201
					 <%= ((mucService.getUserIdleTime() > -1) ? "checked" : "") %>>
202 203 204 205 206
				</td>
				<td width="99%">
						<label for="rb02"><fmt:message key="muc.tasks.kick_user" /></label>
						 <input type="text" name="idletime" size="5" maxlength="5"
							 onclick="this.form.kickEnabled[1].checked=true;"
207
							 value="<%= mucService.getUserIdleTime() == -1 ? 30 : mucService.getUserIdleTime() / 1000 / 60 %>">
208 209 210 211 212
						 <fmt:message key="global.minutes" />.
				</td>
			</tr>
		</tbody>
		</table>
Matt Tucker's avatar
Matt Tucker committed
213 214
        <br/>
        <input type="submit" value="<fmt:message key="global.save_settings" />">
215
	</div>
Gaston Dombiak's avatar
Gaston Dombiak committed
216
</form>
217
<!-- END 'Idle User Settings' -->
Gaston Dombiak's avatar
Gaston Dombiak committed
218 219 220

<br>

221
<!-- BEGIN 'Conversation Logging' -->
Gaston Dombiak's avatar
Gaston Dombiak committed
222
<form action="muc-tasks.jsp?logSettings" method="post">
223 224
    <input type="hidden" name="mucname" value="<%= mucname %>" />
    <div class="jive-contentBoxHeader">
225 226 227 228 229 230 231 232 233 234
		<fmt:message key="muc.tasks.conversation.logging" />
	</div>
	<div class="jive-contentBox">
		<table cellpadding="3" cellspacing="0" border="0" >
		<tr valign="middle">
			<td width="1%" nowrap class="c1">
				<fmt:message key="muc.tasks.flush" />
			</td>
			<td width="99%">
				<input type="text" name="logfreq" size="15" maxlength="50"
235
				 value="<%= mucService.getLogConversationsTimeout() / 1000 %>">
236 237 238 239 240 241 242 243
			</td>
		</tr>
		<tr valign="middle">
			<td width="1%" nowrap class="c1">
				<fmt:message key="muc.tasks.batch" />
			</td>
			<td width="99%">
				<input type="text" name="logbatchsize" size="15" maxlength="50"
244
				 value="<%= mucService.getLogConversationBatchSize() %>">
245 246 247
			</td>
		</tr>
		</table>
Matt Tucker's avatar
Matt Tucker committed
248 249
        <br/>
        <input type="submit" value="<fmt:message key="global.save_settings" />">
250
	</div>
Gaston Dombiak's avatar
Gaston Dombiak committed
251
</form>
252 253
<!-- END 'Conversation Logging' -->

Gaston Dombiak's avatar
Gaston Dombiak committed
254

255
</body>
256
</html>