chatroom-history-settings.jsp 5.72 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4
<%--
  -	$RCSfile$
  -	$Revision$
  -	$Date$
Bill Lynch's avatar
Bill Lynch committed
5 6 7 8 9
  -
  - 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.
Matt Tucker's avatar
Matt Tucker committed
10 11 12 13 14
--%>

<%@ page import="org.jivesoftware.util.*,
                 java.util.*,
                 org.jivesoftware.messenger.*,
Derek DeMoro's avatar
Derek DeMoro committed
15
                 org.jivesoftware.admin.*,
16 17
                 org.jivesoftware.messenger.muc.HistoryStrategy,
                 org.jivesoftware.messenger.muc.MultiUserChatServer"
Bill Lynch's avatar
Bill Lynch committed
18
    errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
19 20
%>

Bill Lynch's avatar
Bill Lynch committed
21 22 23
<%@ taglib uri="core" prefix="c"%>
<%@ taglib uri="fmt" prefix="fmt" %>

Matt Tucker's avatar
Matt Tucker committed
24 25 26
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager"  />
<% admin.init(request, response, session, application, out ); %>

Derek DeMoro's avatar
Derek DeMoro committed
27 28 29 30
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<%  // Title of this page and breadcrumbs
    String title = "Chat Room History Settings";
    pageinfo.setTitle(title);
Bill Lynch's avatar
Bill Lynch committed
31
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
Derek DeMoro's avatar
Derek DeMoro committed
32 33 34
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "chatroom-history-settings.jsp"));
    pageinfo.setPageID("server-chatroom-history");
%>
Bill Lynch's avatar
Bill Lynch committed
35
<jsp:include page="top.jsp" flush="true" />
Derek DeMoro's avatar
Derek DeMoro committed
36
<jsp:include page="title.jsp" flush="true" />
Matt Tucker's avatar
Matt Tucker committed
37 38 39 40 41 42 43 44 45 46 47 48 49

<%! // Global vars and methods:
    static final int ALL = 1;
    static final int NONE = 2;
    static final int NUMBER = 3;
%>

<%  // Get parameters:
    boolean update = request.getParameter("update") != null;
    int policy = ParamUtils.getIntParameter(request,"policy",-1);
    int numMessages = ParamUtils.getIntParameter(request,"numMessages",0);

    // Get an audit manager:
50 51
    MultiUserChatServer muc = admin.getMultiUserChatServer();
    HistoryStrategy historyStrat = muc.getHistoryStrategy();
Matt Tucker's avatar
Matt Tucker committed
52 53 54 55 56 57 58 59 60 61 62 63 64

    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) {
65
                historyStrat.setType(HistoryStrategy.Type.all);
Matt Tucker's avatar
Matt Tucker committed
66 67
            }
            else if (policy == NONE) {
68
                historyStrat.setType(HistoryStrategy.Type.none);
Matt Tucker's avatar
Matt Tucker committed
69 70
            }
            else if (policy == NUMBER) {
71 72
                historyStrat.setType(HistoryStrategy.Type.number);
                historyStrat.setMaxNumber(numMessages);
Matt Tucker's avatar
Matt Tucker committed
73 74 75
            }
            // All done, redirect
            %>
Bill Lynch's avatar
Bill Lynch committed
76 77 78 79 80 81 82 83 84 85
    <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">
        Settings updated successfully.
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
86 87 88 89 90 91
            <%
        }
    }

    // Set page vars
    if (errors.size() == 0) {
92 93 94 95 96 97 98 99 100 101
        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();
Matt Tucker's avatar
Matt Tucker committed
102 103
    }
%>
Derek DeMoro's avatar
Derek DeMoro committed
104

Bill Lynch's avatar
Bill Lynch committed
105
<p>
Matt Tucker's avatar
Matt Tucker committed
106
Chatrooms can replay conversation histories to provide context to new members joining a room.
Bill Lynch's avatar
Bill Lynch committed
107 108 109 110
<fmt:message key="short.title" bundle="${lang}" /> provides several options for controlling how
much history to store for each room.
</p>

111
<form action="chatroom-history-settings.jsp" method="post">
Bill Lynch's avatar
Bill Lynch committed
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162

<fieldset>
    <legend>Set Chatroom History Policy</legend>
    <div>
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
    <tbody>
        <tr valign="top" 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>Don't Show History</b></label> - Do not show the entire chat
                history.
            </td>
        </tr>
        <tr valign="top">
            <td width="1%" nowrap>
                <input type="radio" name="policy" value="<%= ALL %>" id="rb02"
                 <%= ((policy==ALL) ? "checked" : "") %>>
            </td>
            <td width="99%">
                <label for="rb02"><b>Show Entire Chat History</b></label> - Show the entire chat history
                to the user.
            </td>
        </tr>
        <tr valign="top" class="">
            <td width="1%" nowrap>
                <input type="radio" name="policy" value="<%= NUMBER %>" id="rb03"
                 <%= ((policy==NUMBER) ? "checked" : "") %>>
            </td>
            <td width="99%">
                <label for="rb03"><b>Show a Specific Number of Messages</b></label> - Show a specific
                number of the most recent messages in the chat. Use the box below to specify
                that number.
        </tr>
        <tr valign="top" 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 : "") %>"> messages
        </tr>
    </tbody>
    </table>
    </div>
</fieldset>

<br><br>
Matt Tucker's avatar
Matt Tucker committed
163 164 165 166 167

<input type="submit" name="update" value="Save Settings">

</form>

Bill Lynch's avatar
Bill Lynch committed
168
<jsp:include page="bottom.jsp" flush="true" />