%--
- $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.openfire.muc.HistoryStrategy,
org.jivesoftware.openfire.muc.MultiUserChatServer"
errorPage="error.jsp"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<%! // Global vars and methods:
// Strategy definitions:
static final int ALL = 1;
static final int NONE = 2;
static final int NUMBER = 3;
%>
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters:
boolean update = request.getParameter("update") != null;
int policy = ParamUtils.getIntParameter(request,"policy",-1);
int numMessages = ParamUtils.getIntParameter(request,"numMessages",0);
// Get muc history
MultiUserChatServer mucServer = webManager.getMultiUserChatServer();
HistoryStrategy historyStrat = mucServer.getHistoryStrategy();
Map errors = new HashMap();
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);
}
// All done, redirect
response.sendRedirect("muc-history-settings.jsp?success=true");
return;
}
}
// 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();
}
%>
<% if ("true".equals(request.getParameter("success"))) { %>
<% } %>