muc-create-permission.jsp 7.91 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" %>
22
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
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
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<%  // Title of this page and breadcrumbs
87
    String title = LocaleUtils.getLocalizedString("muc.create.permission.title");
Bill Lynch's avatar
Bill Lynch committed
88
    pageinfo.setTitle(title);
89 90
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp"));
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "muc-create-permission.jsp"));
Bill Lynch's avatar
Bill Lynch committed
91 92 93 94
    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>
97
<fmt:message key="muc.create.permission.info" />
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
    <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">
107
        <fmt:message key="muc.create.permission.error" />
Bill Lynch's avatar
Bill Lynch committed
108 109 110 111
        </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

122
            <fmt:message key="muc.create.permission.update" />
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

126
            <fmt:message key="muc.create.permission.add_user" />
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

130
            <fmt:message key="muc.create.permission.user_removed" />
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

<fieldset>
143
    <legend><fmt:message key="muc.create.permission.policy" /></legend>
Bill Lynch's avatar
Bill Lynch committed
144 145 146 147 148 149
    <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
                </td>
                <td width="99%">
153
                    <label for="rb01"><fmt:message key="muc.create.permission.anyone_created" /></label>
Bill Lynch's avatar
Bill Lynch committed
154 155 156 157 158 159
                </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"><fmt:message key="muc.create.permission.specific_created" /></label>
Bill Lynch's avatar
Bill Lynch committed
164 165 166 167
                </td>
            </tr>
        </tbody>
        </table>
168
        <br>
169
        <input type="submit" value="<fmt:message key="global.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

    <fieldset>
182
        <legend><fmt:message key="muc.create.permission.allowed_users" /></legend>
183 184
        <div>
        <p>
185
        <label for="userJIDtf"><fmt:message key="muc.create.permission.add_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
        </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">
204
                        <fmt:message key="muc.create.permission.no_allowed_users" />
205 206 207 208 209 210 211 212 213 214 215 216 217 218
                    </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"
219 220
                         title="<fmt:message key="muc.create.permission.click_title" />"
                         onclick="return confirm('<fmt:message key="muc.create.permission.confirm_remove" />');"
221 222 223 224 225 226 227 228 229 230 231 232 233 234
                         ><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" />