muc-tasks.jsp 8.02 KB
Newer Older
Gaston Dombiak's avatar
Gaston Dombiak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<%--
  -	$RCSfile$
  -	$Revision$
  -	$Date$
  -
  - Copyright (C) 2004 Jive Software. All rights reserved.
  -
  - This software is published under the terms of the GNU Public License (GPL),
  - a copy of which is included in this distribution.
--%>

<%@ page import="org.jivesoftware.util.*,
                 java.util.*,
                 org.jivesoftware.messenger.*,
                 org.jivesoftware.admin.*,
                 org.jivesoftware.messenger.muc.MultiUserChatServer,
                 java.util.Iterator"
    errorPage="error.jsp"
%>

21
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
22
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
23 24 25 26 27 28 29 30 31 32 33 34 35 36
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<% admin.init(request, response, session, application, out ); %>

<%  // 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;

	// Get muc server
37
    MultiUserChatServer mucServer = admin.getMultiUserChatServer();
Gaston Dombiak's avatar
Gaston Dombiak committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55

    Map errors = new HashMap();
    // Handle an update of the kicking task settings
    if (kickSettings) {
        if (!kickEnabled) {
            // Disable kicking users by setting a value of -1
            mucServer.setUserIdleTime(-1);
            response.sendRedirect("muc-tasks.jsp?kickSettingSuccess=true");
            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
56
                idle = Integer.parseInt(idletime) * 1000 * 60;
Gaston Dombiak's avatar
Gaston Dombiak committed
57 58
            }
            catch (NumberFormatException e) {
Matt Tucker's avatar
Matt Tucker committed
59
                errors.put("idletime","idletime");
Gaston Dombiak's avatar
Gaston Dombiak committed
60
            }
Matt Tucker's avatar
Matt Tucker committed
61
            if (idle < 0) {
Gaston Dombiak's avatar
Gaston Dombiak committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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
                errors.put("idletime","idletime");
            }
        }

        if (errors.size() == 0) {
            mucServer.setUserIdleTime(idle);
            response.sendRedirect("muc-tasks.jsp?kickSettingSuccess=true");
            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) {
            mucServer.setLogConversationsTimeout(frequency);
            mucServer.setLogConversationBatchSize(batchSize);
            response.sendRedirect("muc-tasks.jsp?logSettingSuccess=true");
            return;
        }
    }
%>

<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<%  // Title of this page and breadcrumbs
111
    String title = LocaleUtils.getLocalizedString("muc.tasks.title");
Gaston Dombiak's avatar
Gaston Dombiak committed
112
    pageinfo.setTitle(title);
113 114
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp"));
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "muc-tasks.jsp"));
Gaston Dombiak's avatar
Gaston Dombiak committed
115 116 117 118 119 120
    pageinfo.setPageID("muc-tasks");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />

<p>
121
<fmt:message key="muc.tasks.info" />
Gaston Dombiak's avatar
Gaston Dombiak committed
122 123 124 125 126 127 128 129 130 131 132
</p>

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

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
        <td class="jive-icon-label">
        <%  if (kickSettingSuccess) { %>

133
            <fmt:message key="muc.tasks.update" />
Gaston Dombiak's avatar
Gaston Dombiak committed
134 135 136

        <%  } else if (logSettingSuccess) { %>

137
            <fmt:message key="muc.tasks.log" />
Gaston Dombiak's avatar
Gaston Dombiak committed
138 139 140 141 142 143 144 145 146

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

<%  } %>

Matt Tucker's avatar
Matt Tucker committed
147 148 149 150 151 152 153
<% if (errors.size() != 0) {  %>

   <table class="jive-error-message" cellpadding="3" cellspacing="0" border="0" width="350"> <tr valign="top">
    <td width="1%"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
    <td width="99%" class="jive-error-text">

		<% if (errors.get("idletime") != null) { %>
154
                <fmt:message key="muc.tasks.valid_idel_minutes" />
Matt Tucker's avatar
Matt Tucker committed
155 156
        <% }
           else if (errors.get("logfreq") != null) { %>
157
                <fmt:message key="muc.tasks.valid_frequency" />
Matt Tucker's avatar
Matt Tucker committed
158 159
        <%  }
            else if (errors.get("logbatchsize") != null) { %>
160
                <fmt:message key="muc.tasks.valid_batch" />
Matt Tucker's avatar
Matt Tucker committed
161 162 163 164 165 166 167
            <%  } %>
    </td>
    </tr>
    </table><br>

<% } %>

Gaston Dombiak's avatar
Gaston Dombiak committed
168 169 170
<form action="muc-tasks.jsp?kickSettings" method="post">

<fieldset>
171
    <legend><fmt:message key="muc.tasks.user_setting" /></legend>
Gaston Dombiak's avatar
Gaston Dombiak committed
172 173 174
    <div>
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
    <tbody>
Matt Tucker's avatar
Matt Tucker committed
175
        <tr valign="middle">
Gaston Dombiak's avatar
Gaston Dombiak committed
176 177
            <td width="1%" nowrap>
                <input type="radio" name="kickEnabled" value="false" id="rb01"
Matt Tucker's avatar
Matt Tucker committed
178
                 <%= ((mucServer.getUserIdleTime() < 0) ? "checked" : "") %>>
Gaston Dombiak's avatar
Gaston Dombiak committed
179 180
            </td>
            <td width="99%">
181
                <label for="rb01"><fmt:message key="muc.tasks.never_kick" /></label>
Gaston Dombiak's avatar
Gaston Dombiak committed
182 183
            </td>
        </tr>
Matt Tucker's avatar
Matt Tucker committed
184
        <tr valign="middle">
Gaston Dombiak's avatar
Gaston Dombiak committed
185 186 187 188 189
            <td width="1%" nowrap>
                <input type="radio" name="kickEnabled" value="true" id="rb02"
                 <%= ((mucServer.getUserIdleTime() > -1) ? "checked" : "") %>>
            </td>
            <td width="99%">
190
                    <label for="rb02"><fmt:message key="muc.tasks.kick_user" /></label>
Matt Tucker's avatar
Matt Tucker committed
191
                     <input type="text" name="idletime" size="5" maxlength="5"
Gaston Dombiak's avatar
Gaston Dombiak committed
192
                         onclick="this.form.kickEnabled[1].checked=true;"
Matt Tucker's avatar
Matt Tucker committed
193
                         value="<%= mucServer.getUserIdleTime() == -1 ? 30 : mucServer.getUserIdleTime() / 1000 / 60 %>">
194
                     <fmt:message key="muc.tasks.minutes" />
Gaston Dombiak's avatar
Gaston Dombiak committed
195 196 197 198 199 200 201 202 203
            </td>
        </tr>
    </tbody>
    </table>
    </div>
</fieldset>

<br><br>

204
<input type="submit" value="<fmt:message key="global.save_settings" />">
Gaston Dombiak's avatar
Gaston Dombiak committed
205 206 207 208 209 210 211 212

</form>

<br>

<form action="muc-tasks.jsp?logSettings" method="post">

<fieldset>
213
    <legend><fmt:message key="muc.tasks.conversation.logging" /></legend>
Gaston Dombiak's avatar
Gaston Dombiak committed
214 215
    <div>
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
Matt Tucker's avatar
Matt Tucker committed
216
    <tr valign="middle">
Gaston Dombiak's avatar
Gaston Dombiak committed
217
        <td width="1%" nowrap class="c1">
218
            <fmt:message key="muc.tasks.flush" />
Gaston Dombiak's avatar
Gaston Dombiak committed
219 220 221 222 223 224
        </td>
        <td width="99%">
            <input type="text" name="logfreq" size="15" maxlength="50"
             value="<%= mucServer.getLogConversationsTimeout() / 1000 %>">
        </td>
    </tr>
Matt Tucker's avatar
Matt Tucker committed
225
    <tr valign="middle">
Gaston Dombiak's avatar
Gaston Dombiak committed
226
        <td width="1%" nowrap class="c1">
227
            <fmt:message key="muc.tasks.batch" />
Gaston Dombiak's avatar
Gaston Dombiak committed
228 229 230 231 232 233 234 235 236 237 238 239
        </td>
        <td width="99%">
            <input type="text" name="logbatchsize" size="15" maxlength="50"
             value="<%= mucServer.getLogConversationBatchSize() %>">
        </td>
    </tr>
    </table>
    </div>
</fieldset>

<br><br>

240
<input type="submit" value="<fmt:message key="global.save_settings" />">
Gaston Dombiak's avatar
Gaston Dombiak committed
241 242 243 244

</form>

<jsp:include page="bottom.jsp" flush="true" />