muc-create-permission.jsp 7.51 KB
Newer Older
Derek DeMoro's avatar
Derek DeMoro committed
1
<%--
Matt Tucker's avatar
Matt Tucker committed
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.*,
Matt Tucker's avatar
Matt Tucker committed
16 17
                 org.jivesoftware.messenger.muc.MultiUserChatServer,
                 java.util.Iterator"
Bill Lynch's avatar
Bill Lynch committed
18
    errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
19 20
%>

21
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
Matt Tucker's avatar
Matt Tucker committed
22

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

<%  // Get parameters
    String userJID = ParamUtils.getParameter(request,"userJID");
Bill Lynch's avatar
Bill Lynch committed
28 29 30 31 32
    boolean add = request.getParameter("add") != null;
    boolean save = request.getParameter("save") != null;
    boolean success = request.getParameter("success") != null;
    boolean addsuccess = request.getParameter("addsuccess") != null;
    boolean deletesuccess = request.getParameter("deletesuccess") != null;
Matt Tucker's avatar
Matt Tucker committed
33
    boolean delete = ParamUtils.getBooleanParameter(request,"delete");
Bill Lynch's avatar
Bill Lynch committed
34
    boolean openPerms = ParamUtils.getBooleanParameter(request,"openPerms");
Matt Tucker's avatar
Matt Tucker committed
35 36

	// Get muc server
37
    MultiUserChatServer mucServer = admin.getMultiUserChatServer();
Matt Tucker's avatar
Matt Tucker committed
38 39 40

    // Handle a save
    Map errors = new HashMap();
Bill Lynch's avatar
Bill Lynch committed
41 42 43 44 45 46 47 48 49 50 51
    if (save) {
        if (openPerms) {
            // Remove all users who have the ability to create rooms
            List<String> removeables = new ArrayList<String>();
            for (Object obj : mucServer.getUsersAllowedToCreate()) {
                String user = (String)obj;
                removeables.add(user);
            }
            for (String user : removeables) {
                mucServer.removeUserAllowedToCreate(user);
            }
52 53 54 55 56 57
            mucServer.setRoomCreationRestricted(false);
            response.sendRedirect("muc-create-permission.jsp?success=true");
            return;
        }
        else {
            mucServer.setRoomCreationRestricted(true);
Bill Lynch's avatar
Bill Lynch committed
58 59 60 61 62 63
            response.sendRedirect("muc-create-permission.jsp?success=true");
            return;
        }
    }

    // Handle an add
Matt Tucker's avatar
Matt Tucker committed
64 65
    if (add) {
        // do validation
66
        if (userJID == null || userJID.indexOf('@') == -1) {
Matt Tucker's avatar
Matt Tucker committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
            errors.put("userJID","userJID");
        }
        if (errors.size() == 0) {
            mucServer.addUserAllowedToCreate(userJID);
            response.sendRedirect("muc-create-permission.jsp?addsuccess=true");
            return;
        }
    }

    if (delete) {
        // Remove the user from the allowed list
        mucServer.removeUserAllowedToCreate(userJID);
        // done, return
        response.sendRedirect("muc-create-permission.jsp?deletesuccess=true");
        return;
    }
%>

Bill Lynch's avatar
Bill Lynch committed
85 86 87 88 89 90 91 92 93 94
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<%  // Title of this page and breadcrumbs
    String title = "Room Creation Permissions";
    pageinfo.setTitle(title);
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Room Permissions", "muc-create-permission.jsp"));
    pageinfo.setPageID("muc-perms");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
Matt Tucker's avatar
Matt Tucker committed
95

Bill Lynch's avatar
Bill Lynch committed
96
<p>
Bill Lynch's avatar
Bill Lynch committed
97
Use the form below to configure the policy for who can create group chat rooms.
Bill Lynch's avatar
Bill Lynch committed
98
</p>
Matt Tucker's avatar
Matt Tucker committed
99

Bill Lynch's avatar
Bill Lynch committed
100
<%  if (errors.size() > 0) { %>
Matt Tucker's avatar
Matt Tucker committed
101

Bill Lynch's avatar
Bill Lynch committed
102 103 104 105 106 107 108 109 110 111
    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
        <td class="jive-icon-label">
        Error adding the user. Please verify the JID is correct.
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
112

Bill Lynch's avatar
Bill Lynch committed
113
<%  } else if (success || addsuccess || deletesuccess) { %>
Matt Tucker's avatar
Matt Tucker committed
114

Bill Lynch's avatar
Bill Lynch committed
115 116 117 118 119 120
    <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 (success) { %>
Matt Tucker's avatar
Matt Tucker committed
121

Bill Lynch's avatar
Bill Lynch committed
122
            Settings updated successfully.
Matt Tucker's avatar
Matt Tucker committed
123

Bill Lynch's avatar
Bill Lynch committed
124
        <%  } else if (addsuccess) { %>
Matt Tucker's avatar
Matt Tucker committed
125

Bill Lynch's avatar
Bill Lynch committed
126
            User added successfully.
Matt Tucker's avatar
Matt Tucker committed
127

Bill Lynch's avatar
Bill Lynch committed
128
        <%  } else if (deletesuccess) { %>
Matt Tucker's avatar
Matt Tucker committed
129

Bill Lynch's avatar
Bill Lynch committed
130
            User removed successfully.
Matt Tucker's avatar
Matt Tucker committed
131

Bill Lynch's avatar
Bill Lynch committed
132 133 134 135 136
        <%  } %>
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
137 138 139

<%  } %>

Bill Lynch's avatar
Bill Lynch committed
140
<form action="muc-create-permission.jsp?save" method="post">
Bill Lynch's avatar
Bill Lynch committed
141 142 143 144 145 146 147 148 149

<fieldset>
    <legend>Permission Policy</legend>
    <div>
        <table cellpadding="3" cellspacing="0" border="0" width="100%">
        <tbody>
            <tr>
                <td width="1%">
                    <input type="radio" name="openPerms" value="true" id="rb01"
150
                     <%= ((!mucServer.isRoomCreationRestricted()) ? "checked" : "") %>>
Bill Lynch's avatar
Bill Lynch committed
151 152 153 154 155 156 157 158 159
                </td>
                <td width="99%">
                    <label for="rb01">Anyone can create a chat room.</label>
                </td>
            </tr>
            <tr>
                <td width="1%">
                    <input type="radio" name="openPerms" value="false" id="rb02"
                     onfocus="this.form.userJID.focus();"
160
                     <%= ((mucServer.isRoomCreationRestricted()) ? "checked" : "") %>>
Bill Lynch's avatar
Bill Lynch committed
161 162
                </td>
                <td width="99%">
163
                    <label for="rb02">Only specific users can create a chat room.</label>
Bill Lynch's avatar
Bill Lynch committed
164 165 166 167
                </td>
            </tr>
        </tbody>
        </table>
168
        <br>
Bill Lynch's avatar
Bill Lynch committed
169
        <input type="submit" value="Save Settings">
Bill Lynch's avatar
Bill Lynch committed
170 171 172
    </div>
</fieldset>

173
</form>
Bill Lynch's avatar
Bill Lynch committed
174

175
<br>
Bill Lynch's avatar
Bill Lynch committed
176

177 178
<%  if (mucServer.isRoomCreationRestricted()) { %>

Bill Lynch's avatar
Bill Lynch committed
179
    <form action="muc-create-permission.jsp?add" method="post">
180 181 182 183 184

    <fieldset>
        <legend>Allowed Users</legend>
        <div>
        <p>
Bill Lynch's avatar
Bill Lynch committed
185
        <label for="userJIDtf">Add User (JID):</label>
186
        <input type="text" name="userJID" size="30" maxlength="100" value="<%= (userJID != null ? userJID : "") %>"
Bill Lynch's avatar
Bill Lynch committed
187 188
         onclick="this.form.openPerms[1].checked=true;" id="userJIDtf">
        <input type="submit" value="Add">
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
        </p>

        <div class="jive-table" style="width:400px;">
        <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <thead>
            <tr>
                <th width="99%">User</th>
                <th width="1%">Remove</th>
            </tr>
        </thead>
        <tbody>
            <%  if (mucServer.getUsersAllowedToCreate().size() == 0) { %>

                <tr>
                    <td colspan="2">
                        No allowed users, use the form above to add one.
                    </td>
                </tr>

            <%  } %>

            <%  for (Object obj : mucServer.getUsersAllowedToCreate()) {
                    String user = (String)obj;
            %>
                <tr>
                    <td width="99%">
                        <%= user %>
                    </td>
                    <td width="1%" align="center">
                        <a href="muc-create-permission.jsp?userJID=<%= user %>&delete=true"
                         title="Click to delete..."
                         onclick="return confirm('Are you sure you want to remove this user from the list?');"
                         ><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
                    </td>
                </tr>

            <%  } %>
        </tbody>
        </table>
        </div>
        </div>
    </fieldset>

    </form>

<%  } %>
Matt Tucker's avatar
Matt Tucker committed
235

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