muc-sysadmins.jsp 6.28 KB
Newer Older
Bill Lynch's avatar
Bill Lynch 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-2008 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
6
  -
7 8 9 10 11 12 13 14 15 16 17
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.
Matt Tucker's avatar
Matt Tucker committed
18 19 20 21
--%>

<%@ page import="org.jivesoftware.util.*,
                 java.util.*,
22 23
                 org.jivesoftware.openfire.muc.MultiUserChatService"
         errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
24
%>
25
<%@ page import="java.net.URLEncoder" %>
Bill Lynch's avatar
Bill Lynch committed
26

27
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
28
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
Bill Lynch's avatar
Bill Lynch committed
29

30 31
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
Matt Tucker's avatar
Matt Tucker committed
32 33 34

<%  // Get parameters
    String userJID = ParamUtils.getParameter(request,"userJID");
Bill Lynch's avatar
Bill Lynch committed
35
    boolean add = request.getParameter("add") != null;
Matt Tucker's avatar
Matt Tucker committed
36
    boolean delete = ParamUtils.getBooleanParameter(request,"delete");
37
    String mucname = ParamUtils.getParameter(request,"mucname");
Matt Tucker's avatar
Matt Tucker committed
38

39 40 41 42 43 44 45 46
    if (!webManager.getMultiUserChatManager().isServiceRegistered(mucname)) {
        // The requested service name does not exist so return to the list of the existing rooms
        response.sendRedirect("muc-service-summary.jsp");
        return;
    }

    // Get muc server
    MultiUserChatService mucService = webManager.getMultiUserChatManager().getMultiUserChatService(mucname);
Matt Tucker's avatar
Matt Tucker committed
47 48

    // Handle a save
49
    Map<String,String> errors = new HashMap<String,String>();
Matt Tucker's avatar
Matt Tucker committed
50 51
    if (add) {
        // do validation
52
        if (userJID == null || userJID.indexOf('@') == -1) {
Matt Tucker's avatar
Matt Tucker committed
53 54 55
            errors.put("userJID","userJID");
        }
        if (errors.size() == 0) {
56
            mucService.addSysadmin(userJID);
57
            // Log the event
58
            webManager.logEvent("added muc sysadmin "+userJID+" for service "+mucname, null);
59
            response.sendRedirect("muc-sysadmins.jsp?addsuccess=true&mucname="+URLEncoder.encode(mucname, "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
60 61 62 63 64 65
            return;
        }
    }

    if (delete) {
        // Remove the user from the list of system administrators
66
        mucService.removeSysadmin(userJID);
67
        // Log the event
68
        webManager.logEvent("removed muc sysadmin "+userJID+" for service "+mucname, null);
Matt Tucker's avatar
Matt Tucker committed
69
        // done, return
70
        response.sendRedirect("muc-sysadmins.jsp?deletesuccess=true&mucname="+URLEncoder.encode(mucname, "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
71 72
        return;
    }
Bill Lynch's avatar
Bill Lynch committed
73
%>
Matt Tucker's avatar
Matt Tucker committed
74

75
<html>
76 77
<head>
<title><fmt:message key="groupchat.admins.title"/></title>
78 79
<meta name="subPageID" content="muc-sysadmin"/>
<meta name="extraParams" content="<%= "mucname="+URLEncoder.encode(mucname, "UTF-8") %>"/>
80 81 82
<meta name="helpPage" content="edit_group_chat_service_administrators.html"/>
</head>
<body>
Matt Tucker's avatar
Matt Tucker committed
83

Bill Lynch's avatar
Bill Lynch committed
84
<p>
85
<fmt:message key="groupchat.admins.introduction" />
86
<fmt:message key="groupchat.service.settings_affect" /> <b><a href="muc-service-edit-form.jsp?mucname=<%= URLEncoder.encode(mucname, "UTF-8") %>"><%= mucname %></a></b>
Bill Lynch's avatar
Bill Lynch committed
87
</p>
Matt Tucker's avatar
Matt Tucker committed
88 89 90

<%  if ("true".equals(request.getParameter("deletesuccess"))) { %>

Bill Lynch's avatar
Bill Lynch committed
91 92 93
    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
94
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
95
        <td class="jive-icon-label">
96
        <fmt:message key="groupchat.admins.user_removed" />
Bill Lynch's avatar
Bill Lynch committed
97 98 99 100
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
101

Bill Lynch's avatar
Bill Lynch committed
102
<%  } else if ("true".equals(request.getParameter("addsuccess"))) { %>
Matt Tucker's avatar
Matt Tucker committed
103

Bill Lynch's avatar
Bill Lynch committed
104 105 106
    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
107
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
108
        <td class="jive-icon-label">
109
        <fmt:message key="groupchat.admins.user_added" />
Bill Lynch's avatar
Bill Lynch committed
110 111 112 113
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
114

Bill Lynch's avatar
Bill Lynch committed
115
<%  } else if (errors.size() > 0) { %>
Matt Tucker's avatar
Matt Tucker committed
116

Bill Lynch's avatar
Bill Lynch committed
117 118 119
    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
120
        <tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0" alt=""></td>
Bill Lynch's avatar
Bill Lynch committed
121
        <td class="jive-icon-label">
122
        <fmt:message key="groupchat.admins.error_adding" />
Bill Lynch's avatar
Bill Lynch committed
123 124 125 126
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
127

Bill Lynch's avatar
Bill Lynch committed
128
<%  } %>
Matt Tucker's avatar
Matt Tucker committed
129 130


131 132
<!-- BEGIN 'Administrators' -->
<form action="muc-sysadmins.jsp?add" method="post">
133 134
    <input type="hidden" name="mucname" value="<%= mucname %>" />
    <div class="jive-contentBoxHeader">
135 136 137 138 139 140
		<fmt:message key="groupchat.admins.legend" />
	</div>
	<div class="jive-contentBox">
		<label for="userJIDtf"><fmt:message key="groupchat.admins.label_add_admin" /></label>
		<input type="text" name="userJID" size="30" maxlength="100" value="<%= (userJID != null ? userJID : "") %>"
		 id="userJIDtf">
141
		<input type="submit" value="<fmt:message key="groupchat.admins.add" />">
142 143 144 145 146 147 148 149 150 151 152
		<br><br>

		<div class="jive-table" style="width:400px;">
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
			<thead>
				<tr>
					<th width="99%"><fmt:message key="groupchat.admins.column_user" /></th>
					<th width="1%" nowrap><fmt:message key="groupchat.admins.column_remove" /></th>
				</tr>
			</thead>
			<tbody>
153
				<%  if (mucService.getSysadmins().size() == 0) { %>
154 155 156 157 158 159 160 161 162

					<tr>
						<td colspan="2">
							<fmt:message key="groupchat.admins.no_admins" />
						</td>
					</tr>

				<%  } %>

163
				<%  for (String user : mucService.getSysadmins()) { %>
164 165 166 167 168 169

					<tr>
						<td width="99%">
							<%= user %>
						</td>
						<td width="1%" align="center">
170
							<a href="muc-sysadmins.jsp?userJID=<%= user %>&delete=true&mucname=<%= URLEncoder.encode(mucname, "UTF-8") %>"
171 172
							 title="<fmt:message key="groupchat.admins.dialog.title" />"
							 onclick="return confirm('<fmt:message key="groupchat.admins.dialog.text" />');"
173
							 ><img src="images/delete-16x16.gif" width="16" height="16" border="0" alt=""></a>
174 175 176 177 178 179 180 181
						</td>
					</tr>

				<%  } %>
			</tbody>
			</table>
		</div>
	</div>
Bill Lynch's avatar
Bill Lynch committed
182
</form>
183 184
<!-- END 'Administrators' -->

Bill Lynch's avatar
Bill Lynch committed
185

186
</body>
187
</html>