muc-sysadmins.jsp 5.9 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
  -
  - This software is published under the terms of the GNU Public License (GPL),
8 9
  - a copy of which is included in this distribution, or a commercial license
  - agreement with Jive.
Matt Tucker's avatar
Matt Tucker committed
10 11 12 13
--%>

<%@ page import="org.jivesoftware.util.*,
                 java.util.*,
14 15
                 org.jivesoftware.openfire.muc.MultiUserChatService"
         errorPage="error.jsp"
Matt Tucker's avatar
Matt Tucker committed
16
%>
17
<%@ page import="java.net.URLEncoder" %>
Bill Lynch's avatar
Bill Lynch committed
18

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

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

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

31 32 33 34 35 36 37 38
    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
39 40

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

    if (delete) {
        // Remove the user from the list of system administrators
58
        mucService.removeSysadmin(userJID);
59
        // Log the event
60
        webManager.logEvent("removed muc sysadmin "+userJID+" for service "+mucname, null);
Matt Tucker's avatar
Matt Tucker committed
61
        // done, return
62
        response.sendRedirect("muc-sysadmins.jsp?deletesuccess=true&mucname="+URLEncoder.encode(mucname, "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
63 64
        return;
    }
Bill Lynch's avatar
Bill Lynch committed
65
%>
Matt Tucker's avatar
Matt Tucker committed
66

67
<html>
68 69
<head>
<title><fmt:message key="groupchat.admins.title"/></title>
70 71
<meta name="subPageID" content="muc-sysadmin"/>
<meta name="extraParams" content="<%= "mucname="+URLEncoder.encode(mucname, "UTF-8") %>"/>
72 73 74
<meta name="helpPage" content="edit_group_chat_service_administrators.html"/>
</head>
<body>
Matt Tucker's avatar
Matt Tucker committed
75

Bill Lynch's avatar
Bill Lynch committed
76
<p>
77
<fmt:message key="groupchat.admins.introduction" />
78
<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
79
</p>
Matt Tucker's avatar
Matt Tucker committed
80 81 82

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

Bill Lynch's avatar
Bill Lynch committed
83 84 85
    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
86
        <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
87
        <td class="jive-icon-label">
88
        <fmt:message key="groupchat.admins.user_removed" />
Bill Lynch's avatar
Bill Lynch committed
89 90 91 92
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
93

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

Bill Lynch's avatar
Bill Lynch committed
96 97 98
    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
99
        <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
100
        <td class="jive-icon-label">
101
        <fmt:message key="groupchat.admins.user_added" />
Bill Lynch's avatar
Bill Lynch committed
102 103 104 105
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
106

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

Bill Lynch's avatar
Bill Lynch committed
109 110 111
    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
112
        <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
113
        <td class="jive-icon-label">
114
        <fmt:message key="groupchat.admins.error_adding" />
Bill Lynch's avatar
Bill Lynch committed
115 116 117 118
        </td></tr>
    </tbody>
    </table>
    </div><br>
Matt Tucker's avatar
Matt Tucker committed
119

Bill Lynch's avatar
Bill Lynch committed
120
<%  } %>
Matt Tucker's avatar
Matt Tucker committed
121 122


123 124
<!-- BEGIN 'Administrators' -->
<form action="muc-sysadmins.jsp?add" method="post">
125 126
    <input type="hidden" name="mucname" value="<%= mucname %>" />
    <div class="jive-contentBoxHeader">
127 128 129 130 131 132
		<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">
133
		<input type="submit" value="<fmt:message key="groupchat.admins.add" />">
134 135 136 137 138 139 140 141 142 143 144
		<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>
145
				<%  if (mucService.getSysadmins().size() == 0) { %>
146 147 148 149 150 151 152 153 154

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

				<%  } %>

155
				<%  for (String user : mucService.getSysadmins()) { %>
156 157 158 159 160 161

					<tr>
						<td width="99%">
							<%= user %>
						</td>
						<td width="1%" align="center">
162
							<a href="muc-sysadmins.jsp?userJID=<%= user %>&delete=true&mucname=<%= URLEncoder.encode(mucname, "UTF-8") %>"
163 164
							 title="<fmt:message key="groupchat.admins.dialog.title" />"
							 onclick="return confirm('<fmt:message key="groupchat.admins.dialog.text" />');"
165
							 ><img src="images/delete-16x16.gif" width="16" height="16" border="0" alt=""></a>
166 167 168 169 170 171 172 173
						</td>
					</tr>

				<%  } %>
			</tbody>
			</table>
		</div>
	</div>
Bill Lynch's avatar
Bill Lynch committed
174
</form>
175 176
<!-- END 'Administrators' -->

Bill Lynch's avatar
Bill Lynch committed
177

178
</body>
179
</html>