muc-sysadmins.jsp 5.92 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4 5 6 7 8 9
<%@ taglib uri="core" prefix="c"%><%--
  -	$RCSfile$
  -	$Revision$
  -	$Date$
--%>

<%@ page import="org.jivesoftware.util.*,
                 java.util.*,
                 org.jivesoftware.messenger.*,
Derek DeMoro's avatar
Derek DeMoro committed
10
                 org.jivesoftware.admin.*,
Matt Tucker's avatar
Matt Tucker committed
11 12 13
                 org.jivesoftware.messenger.muc.MultiUserChatServer,
                 java.util.Iterator"
%>
Bill Lynch's avatar
Bill Lynch committed
14
<%-- Define Administration Bean --%>
Matt Tucker's avatar
Matt Tucker committed
15 16 17
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<% admin.init(request, response, session, application, out ); %>

Derek DeMoro's avatar
Derek DeMoro committed
18 19 20 21 22 23 24 25 26 27 28
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<%  // Title of this page and breadcrumbs
    String title = "System Administrators For MultiUser Chat Rooms";
    pageinfo.setTitle(title);
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "main.jsp"));
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "muc-sysadmins.jsp"));
    pageinfo.setPageID("muc-sysadmins");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />

Matt Tucker's avatar
Matt Tucker committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

<%  // Get parameters
    int start = ParamUtils.getIntParameter(request,"start",0);
    int range = ParamUtils.getIntParameter(request,"range",15);
    String userJID = ParamUtils.getParameter(request,"userJID");
    boolean add = ParamUtils.getBooleanParameter(request,"add");
    boolean delete = ParamUtils.getBooleanParameter(request,"delete");

	// Get muc server
    MultiUserChatServer mucServer = (MultiUserChatServer)admin.getServiceLookup().lookup(MultiUserChatServer.class);

    // Get the total system adminstrators count:
    int userCount = mucServer.getSysadmins().size();

    // Handle a save
    Map errors = new HashMap();
    if (add) {
        // do validation
47
        if (userJID == null || userJID.indexOf('@') == -1) {
Matt Tucker's avatar
Matt Tucker committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
            errors.put("userJID","userJID");
        }
        if (errors.size() == 0) {
            mucServer.addSysadmin(userJID);
            response.sendRedirect("muc-sysadmins.jsp?addsuccess=true");
            return;
        }
    }

    if (delete) {
        // Remove the user from the list of system administrators
        mucServer.removeSysadmin(userJID);
        // done, return
        response.sendRedirect("muc-sysadmins.jsp?deletesuccess=true");
        return;
    }

    // paginator vars
    int numPages = (int)Math.ceil((double)userCount/(double)range);
    int curPage = (start/range) + 1;
%>

<table  cellpadding="3" cellspacing="1" border="0" width="600">
Derek DeMoro's avatar
Derek DeMoro committed
71
<tr><td colspan="1">
Matt Tucker's avatar
Matt Tucker committed
72 73 74 75 76 77 78
Below is the list of system administrators of the Multi-User Chat service. System administrators can
enter any groupchat room and their permissions are the same as the room owner.</td></tr>
</table>

<table cellpadding="3" cellspacing="1" border="0" width="600">
<tr class="tableHeader"><td colspan="8" align="left">User Summary</td></tr>

Derek DeMoro's avatar
Derek DeMoro committed
79
<tr><td colspan="1" class="text">
Matt Tucker's avatar
Matt Tucker committed
80 81 82 83 84 85 86 87 88 89
Total Users: <%= userCount %>.
<%  if (numPages > 1) { %>

    Showing <%= (start+1) %>-<%= (start+range) %>.

<%  } %>
</td></tr>

<%  if (numPages > 1) { %>

Derek DeMoro's avatar
Derek DeMoro committed
90
  <tr><td colspan="1" class="text">
Matt Tucker's avatar
Matt Tucker committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    Pages:
    [
    <%  for (int pageIndex=0; pageIndex<numPages; pageIndex++) {
            String sep = ((pageIndex+1)<numPages) ? " " : "";
            boolean isCurrent = (pageIndex+1) == curPage;
    %>
        <a href="muc-sysadmins.jsp?start=<%= (pageIndex*range) %>"
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (pageIndex+1) %></a><%= sep %>

    <%  } %>
    ]
  </td></tr>
<%  } %>
</table>


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

    <p class="jive-success-text">
    User removed from the list successfully.
    </p>

<%  } %>

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

  <p class="jive-success-text">
    User added to the list successfully.
    </p>

<%  } %>

Derek DeMoro's avatar
Derek DeMoro committed
124

Derek DeMoro's avatar
Derek DeMoro committed
125 126
<table class="jive-table" cellpadding="3" cellspacing="1" border="0" width="400">
<tr>
Matt Tucker's avatar
Matt Tucker committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
    <th nowrap align="left">User</th>
    <th>Delete</th>
</tr>
<%  // Print the list of system administrators
    int max = start + range;
    max = (max > mucServer.getSysadmins().size() ? mucServer.getSysadmins().size() : max);
    Iterator users = mucServer.getSysadmins().subList(start, max).iterator();
    if (!users.hasNext()) {
%>
    <tr>
        <td align="center" colspan="2">
            <br>
            The list of system administrators is empty.
            <br><br>
        </td>
    </tr>
<%
    }
    int i = start;
    while (users.hasNext()) {
        userJID = (String)users.next();
        i++;
%>
Derek DeMoro's avatar
Derek DeMoro committed
150
    <tr>
Matt Tucker's avatar
Matt Tucker committed
151 152 153 154 155 156 157
        <td width="90%" align="left">
            <%= userJID %>
        </td>
        <td width="10%" align="center">
            <a href="muc-sysadmins.jsp?userJID=<%= userJID %>&delete=true"
             title="Click to delete..."
             onclick="return confirm('Are you sure you want to remove this user from the list?');"
Matt Tucker's avatar
Matt Tucker committed
158
             ><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
Matt Tucker's avatar
Matt Tucker committed
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
        </td>
    </tr>
<%
    }
%>
</table>
<%  if (numPages > 1) { %>

    <p>
    Pages:
    [
    <%  for (int pageIndex=0; pageIndex<numPages; pageIndex++) {
            String sep = ((pageIndex+1)<numPages) ? " " : "";
            boolean isCurrent = (pageIndex+1) == curPage;
    %>
        <a href="muc-sysadmins.jsp?start=<%= (pageIndex*range) %>"
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (pageIndex+1) %></a><%= sep %>

    <%  } %>
    ]
    </p>

<%  } %>

<form action="muc-sysadmins.jsp">
<input type="hidden" name="add" value="true">

<table cellpadding="3" cellspacing="1" border="0" width="400">
<tr>
Derek DeMoro's avatar
Derek DeMoro committed
189
    <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
190 191 192 193 194 195 196 197
        Enter bare JID of user to add:
    </td>
    <td>
    <input type="text" size="30" maxlength="150" name="userJID">

    <%  if (errors.get("userJID") != null) { %>

        <span class="jive-error-text">
198
        Please enter a valid bare JID (e.g. johndoe@company.org).
Matt Tucker's avatar
Matt Tucker committed
199 200 201 202 203 204 205 206 207
        </span>

    <%  } %>
    </td>
</tr>
</table>
<br>
<input type="submit" value="Add">
<%@ include file="footer.jsp" %>