muc-create-permission.jsp 7.42 KB
Newer Older
Derek DeMoro's avatar
Derek DeMoro committed
1
<%--
Matt Tucker's avatar
Matt Tucker committed
2 3
  -	$Revision$
  -	$Date$
Bill Lynch's avatar
Bill Lynch committed
4
  -
5
  - Copyright (C) 2004-2005 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
6 7 8
  -
  - 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
9 10 11 12
--%>

<%@ page import="org.jivesoftware.util.*,
                 java.util.*,
13
                 org.jivesoftware.wildfire.muc.MultiUserChatServer"
Bill Lynch's avatar
Bill Lynch committed
14
    errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
15 16
%>

17
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
18
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
19 20
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
Matt Tucker's avatar
Matt Tucker committed
21 22 23

<%  // Get parameters
    String userJID = ParamUtils.getParameter(request,"userJID");
Bill Lynch's avatar
Bill Lynch committed
24 25 26 27 28
    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
29
    boolean delete = ParamUtils.getBooleanParameter(request,"delete");
Bill Lynch's avatar
Bill Lynch committed
30
    boolean openPerms = ParamUtils.getBooleanParameter(request,"openPerms");
Matt Tucker's avatar
Matt Tucker committed
31 32

	// Get muc server
33
    MultiUserChatServer mucServer = webManager.getMultiUserChatServer();
Matt Tucker's avatar
Matt Tucker committed
34 35 36

    // Handle a save
    Map errors = new HashMap();
Bill Lynch's avatar
Bill Lynch committed
37 38 39 40 41 42 43 44 45 46 47
    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);
            }
48 49 50 51 52 53
            mucServer.setRoomCreationRestricted(false);
            response.sendRedirect("muc-create-permission.jsp?success=true");
            return;
        }
        else {
            mucServer.setRoomCreationRestricted(true);
Bill Lynch's avatar
Bill Lynch committed
54 55 56 57 58 59
            response.sendRedirect("muc-create-permission.jsp?success=true");
            return;
        }
    }

    // Handle an add
Matt Tucker's avatar
Matt Tucker committed
60 61
    if (add) {
        // do validation
62
        if (userJID == null || userJID.indexOf('@') == -1) {
Matt Tucker's avatar
Matt Tucker committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
            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;
    }
%>

81 82 83 84 85 86 87
<html>
    <head>
        <title><fmt:message key="muc.create.permission.title"/></title>
        <meta name="pageID" content="muc-perms"/>
        <meta name="helpPage" content="set_group_chat_room_creation_permissions.html"/>
    </head>
    <body>
Matt Tucker's avatar
Matt Tucker committed
88

Bill Lynch's avatar
Bill Lynch committed
89
<p>
90
<fmt:message key="muc.create.permission.info" />
Bill Lynch's avatar
Bill Lynch committed
91
</p>
Matt Tucker's avatar
Matt Tucker committed
92

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

Bill Lynch's avatar
Bill Lynch committed
95 96 97 98 99
    <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">
100
        <fmt:message key="muc.create.permission.error" />
Bill Lynch's avatar
Bill Lynch committed
101 102 103 104
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
105

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

Bill Lynch's avatar
Bill Lynch committed
108 109 110 111 112 113
    <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
114

115
            <fmt:message key="muc.create.permission.update" />
Matt Tucker's avatar
Matt Tucker committed
116

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

119
            <fmt:message key="muc.create.permission.add_user" />
Matt Tucker's avatar
Matt Tucker committed
120

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

123
            <fmt:message key="muc.create.permission.user_removed" />
Matt Tucker's avatar
Matt Tucker committed
124

Bill Lynch's avatar
Bill Lynch committed
125 126 127 128 129
        <%  } %>
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
130 131 132

<%  } %>

Bill Lynch's avatar
Bill Lynch committed
133
<form action="muc-create-permission.jsp?save" method="post">
Bill Lynch's avatar
Bill Lynch committed
134 135

<fieldset>
136
    <legend><fmt:message key="muc.create.permission.policy" /></legend>
Bill Lynch's avatar
Bill Lynch committed
137 138 139 140 141 142
    <div>
        <table cellpadding="3" cellspacing="0" border="0" width="100%">
        <tbody>
            <tr>
                <td width="1%">
                    <input type="radio" name="openPerms" value="true" id="rb01"
143
                     <%= ((!mucServer.isRoomCreationRestricted()) ? "checked" : "") %>>
Bill Lynch's avatar
Bill Lynch committed
144 145
                </td>
                <td width="99%">
146
                    <label for="rb01"><fmt:message key="muc.create.permission.anyone_created" /></label>
Bill Lynch's avatar
Bill Lynch committed
147 148 149 150 151 152
                </td>
            </tr>
            <tr>
                <td width="1%">
                    <input type="radio" name="openPerms" value="false" id="rb02"
                     onfocus="this.form.userJID.focus();"
153
                     <%= ((mucServer.isRoomCreationRestricted()) ? "checked" : "") %>>
Bill Lynch's avatar
Bill Lynch committed
154 155
                </td>
                <td width="99%">
156
                    <label for="rb02"><fmt:message key="muc.create.permission.specific_created" /></label>
Bill Lynch's avatar
Bill Lynch committed
157 158 159 160
                </td>
            </tr>
        </tbody>
        </table>
161
        <br>
162
        <input type="submit" value="<fmt:message key="global.save_settings" />">
Bill Lynch's avatar
Bill Lynch committed
163 164 165
    </div>
</fieldset>

166
</form>
Bill Lynch's avatar
Bill Lynch committed
167

168
<br>
Bill Lynch's avatar
Bill Lynch committed
169

170 171
<%  if (mucServer.isRoomCreationRestricted()) { %>

Bill Lynch's avatar
Bill Lynch committed
172
    <form action="muc-create-permission.jsp?add" method="post">
173 174

    <fieldset>
175
        <legend><fmt:message key="muc.create.permission.allowed_users" /></legend>
176 177
        <div>
        <p>
178
        <label for="userJIDtf"><fmt:message key="muc.create.permission.add_jid" /></label>
179
        <input type="text" name="userJID" size="30" maxlength="100" value="<%= (userJID != null ? userJID : "") %>"
Bill Lynch's avatar
Bill Lynch committed
180 181
         onclick="this.form.openPerms[1].checked=true;" id="userJIDtf">
        <input type="submit" value="Add">
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
        </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">
197
                        <fmt:message key="muc.create.permission.no_allowed_users" />
198 199 200 201 202 203 204 205 206 207 208 209 210 211
                    </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"
212 213
                         title="<fmt:message key="muc.create.permission.click_title" />"
                         onclick="return confirm('<fmt:message key="muc.create.permission.confirm_remove" />');"
214 215 216 217 218 219 220 221 222 223 224 225 226 227
                         ><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
228

229 230
    </body>
</html>