user-summary.jsp 12.4 KB
Newer Older
Bill Lynch's avatar
Bill Lynch committed
1
<%--
Matt Tucker's avatar
Matt Tucker committed
2 3 4
  -	$RCSfile$
  -	$Revision$
  -	$Date$
Bill Lynch's avatar
Bill Lynch committed
5
  -
6
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
7
  -
8 9 10 11 12 13 14 15 16 17 18
  - 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
19 20
--%>

21 22
<%@ page import="org.jivesoftware.openfire.PresenceManager,
                 org.jivesoftware.openfire.admin.AdminManager,
23
                 org.jivesoftware.openfire.user.User,
24
                 org.jivesoftware.openfire.user.UserManager,
25
                 org.jivesoftware.openfire.group.Group,
26 27 28 29 30
                 org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.LocaleUtils,
                 org.jivesoftware.util.ParamUtils"
%><%@ page import="org.jivesoftware.util.StringUtils"%>
<%@ page import="org.xmpp.packet.JID" %>
31 32 33
<%@ page import="org.xmpp.packet.Presence" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.Collection" %>
Matt Tucker's avatar
Matt Tucker committed
34

35 36
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
37 38

<%!
39 40
    final int DEFAULT_RANGE = 100;
    final int[] RANGE_PRESETS = {25, 50, 75, 100, 500, 1000, -1};
41 42
%>

Derek DeMoro's avatar
Derek DeMoro committed
43 44
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"  />
<% webManager.init(request, response, session, application, out ); %>
Matt Tucker's avatar
Matt Tucker committed
45

46 47 48 49 50 51 52
<html>
    <head>
        <title><fmt:message key="user.summary.title"/></title>
        <meta name="pageID" content="user-summary"/>
        <meta name="helpPage" content="about_users_and_groups.html"/>
    </head>
    <body>
Derek DeMoro's avatar
Derek DeMoro committed
53

Matt Tucker's avatar
Matt Tucker committed
54 55
<%  // Get parameters
    int start = ParamUtils.getIntParameter(request,"start",0);
56
    int range = ParamUtils.getIntParameter(request,"range",webManager.getRowsPerPage("user-summary", DEFAULT_RANGE));
57

58 59
    if (request.getParameter("range") != null) {
        webManager.setRowsPerPage("user-summary", range);
60
    }
Matt Tucker's avatar
Matt Tucker committed
61 62

    // Get the user manager
Derek DeMoro's avatar
Derek DeMoro committed
63
    int userCount = webManager.getUserManager().getUserCount();
Matt Tucker's avatar
Matt Tucker committed
64 65

    // Get the presence manager
66
    PresenceManager presenceManager = webManager.getPresenceManager();
Matt Tucker's avatar
Matt Tucker committed
67 68 69 70 71 72

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

Bill Lynch's avatar
Bill Lynch committed
73 74 75 76 77
<%  if (request.getParameter("deletesuccess") != null) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
78
        <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
79
        <td class="jive-icon-label">
80
        <fmt:message key="user.summary.deleted" />
Bill Lynch's avatar
Bill Lynch committed
81 82 83 84 85 86 87
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

Matt Tucker's avatar
Matt Tucker committed
88
<p>
Bill Lynch's avatar
Bill Lynch committed
89
<fmt:message key="user.summary.total_user" />:
90
<b><%= LocaleUtils.getLocalizedNumber(userCount) %></b> --
Bill Lynch's avatar
Bill Lynch committed
91

Matt Tucker's avatar
Matt Tucker committed
92 93
<%  if (numPages > 1) { %>

94
    <fmt:message key="global.showing" />
95
    <%= LocaleUtils.getLocalizedNumber(start+1) %>-<%= LocaleUtils.getLocalizedNumber(start+range > userCount ? userCount:start+range) %>,
Matt Tucker's avatar
Matt Tucker committed
96 97

<%  } %>
98
<fmt:message key="user.summary.sorted" />
99

100
-- <fmt:message key="user.summary.users_per_page" />:
101 102
<select size="1" onchange="location.href='user-summary.jsp?start=0&range=' + this.options[this.selectedIndex].value;">

103
    <% for (int aRANGE_PRESETS : RANGE_PRESETS) { %>
104

105
    <option value="<%  if (aRANGE_PRESETS > 0) { %><%= aRANGE_PRESETS %><%  }else{ %><%= userCount %><%}%>"
106
            <%= (aRANGE_PRESETS == range ? "selected" : "") %>><%  if (aRANGE_PRESETS > 0) { %><%= aRANGE_PRESETS %><%  }else{ %><%= userCount %><%}%>
107
    </option>
108

109
    <% } %>
110 111

</select>
Matt Tucker's avatar
Matt Tucker committed
112 113 114 115 116
</p>

<%  if (numPages > 1) { %>

    <p>
117
    <fmt:message key="global.pages" />:
Matt Tucker's avatar
Matt Tucker committed
118
    [
Bill Lynch's avatar
Bill Lynch committed
119 120 121 122 123
    <%  int num = 15 + curPage;
        int s = curPage-1;
        if (s > 5) {
            s -= 5;
        }
124 125 126
        if (s < 5) {
            s = 0;
        }
Bill Lynch's avatar
Bill Lynch committed
127 128 129 130 131 132
        if (s > 2) {
    %>
        <a href="user-summary.jsp?start=0&range=<%= range %>">1</a> ...

    <%
        }
133
        int i;
Bill Lynch's avatar
Bill Lynch committed
134
        for (i=s; i<numPages && i<num; i++) {
Matt Tucker's avatar
Matt Tucker committed
135 136 137
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
138
        <a href="user-summary.jsp?start=<%= (i*range) %>&range=<%= range %>"
Matt Tucker's avatar
Matt Tucker committed
139 140 141 142
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
Bill Lynch's avatar
Bill Lynch committed
143 144 145 146 147 148 149

    <%  if (i < numPages) { %>

        ... <a href="user-summary.jsp?start=<%= ((numPages-1)*range) %>&range=<%= range %>"><%= numPages %></a>

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
150
    ]
151

Matt Tucker's avatar
Matt Tucker committed
152 153 154 155
    </p>

<%  } %>

Bill Lynch's avatar
Bill Lynch committed
156 157 158 159 160
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th>&nbsp;</th>
Bill Lynch's avatar
Bill Lynch committed
161 162 163
        <th nowrap><fmt:message key="session.details.online" /></th>
        <th nowrap><fmt:message key="user.create.username" /></th>
        <th nowrap><fmt:message key="user.create.name" /></th>
164
        <th nowrap><fmt:message key="user.roster.groups" /></th>
165
        <th nowrap><fmt:message key="user.summary.created" /></th>
166
        <th nowrap><fmt:message key="user.summary.last-logout" /></th>
167 168
         <%  // Don't allow editing or deleting if users are read-only.
            if (!UserManager.getUserProvider().isReadOnly()) { %>
169
        <th nowrap><fmt:message key="user.summary.edit" /></th>
170
        <th nowrap><fmt:message key="global.delete" /></th>
171
        <% } %>
Bill Lynch's avatar
Bill Lynch committed
172 173 174 175
    </tr>
</thead>
<tbody>

Matt Tucker's avatar
Matt Tucker committed
176
<%  // Print the list of users
Matt Tucker's avatar
Matt Tucker committed
177 178
    Collection<User> users = webManager.getUserManager().getUsers(start, range);
    if (users.isEmpty()) {
Matt Tucker's avatar
Matt Tucker committed
179 180 181
%>
    <tr>
        <td align="center" colspan="7">
182
            <fmt:message key="user.summary.not_user" />
Matt Tucker's avatar
Matt Tucker committed
183 184 185 186 187 188
        </td>
    </tr>

<%
    }
    int i = start;
Matt Tucker's avatar
Matt Tucker committed
189
    for (User user : users) {
Matt Tucker's avatar
Matt Tucker committed
190
        i++;
191 192
        Boolean lockedOut = false;
        Boolean pendingLockOut = false;
193 194
        if (webManager.getLockOutManager().getDisabledStatus(user.getUsername()) != null) {
            // User is locked out. Check if its locked out now!
195 196 197 198 199 200 201
            if (webManager.getLockOutManager().isAccountDisabled(user.getUsername())) {
                lockedOut = true;
            }
            else {
                pendingLockOut = true;
            }
        }
202
        Boolean isAdmin = AdminManager.getInstance().isUserAdmin(user.getUsername(), false);
Matt Tucker's avatar
Matt Tucker committed
203
%>
Gaston Dombiak's avatar
Gaston Dombiak committed
204
    <tr class="jive-<%= (((i%2)==0) ? "even" : "odd") %>">
Matt Tucker's avatar
Matt Tucker committed
205 206 207
        <td width="1%">
            <%= i %>
        </td>
Matt Tucker's avatar
Matt Tucker committed
208 209 210 211
        <td width="1%" align="center" valign="middle">
            <%  if (presenceManager.isAvailable(user)) {
                    Presence presence = presenceManager.getPresence(user);
            %>
Derek DeMoro's avatar
Derek DeMoro committed
212
                <% if (presence.getShow() == null) { %>
213
                <img src="images/user-green-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="user.properties.available" />" alt="<fmt:message key="user.properties.available" />">
Matt Tucker's avatar
Matt Tucker committed
214
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
215
                <% if (presence.getShow() == Presence.Show.chat) { %>
216
                <img src="images/user-green-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.chat_available" />" alt="<fmt:message key="session.details.chat_available" />">
Matt Tucker's avatar
Matt Tucker committed
217
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
218
                <% if (presence.getShow() == Presence.Show.away) { %>
219
                <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.away" />" alt="<fmt:message key="session.details.away" />">
Matt Tucker's avatar
Matt Tucker committed
220
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
221
                <% if (presence.getShow() == Presence.Show.xa) { %>
222
                <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.extended" />" alt="<fmt:message key="session.details.extended" />">
Matt Tucker's avatar
Matt Tucker committed
223
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
224
                <% if (presence.getShow() == Presence.Show.dnd) { %>
225
                <img src="images/user-red-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.not_disturb" />" alt="<fmt:message key="session.details.not_disturb" />">
Matt Tucker's avatar
Matt Tucker committed
226
                <% } %>
Matt Tucker's avatar
Matt Tucker committed
227 228 229

            <%  } else { %>

230
                <img src="images/user-clear-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="user.properties.offline" />">
Matt Tucker's avatar
Matt Tucker committed
231 232 233

            <%  } %>
        </td>
234
        <td width="23%">
Sven Tantau's avatar
Sven Tantau committed
235
            <a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"<%= lockedOut ? " style='text-decoration: line-through underline;'" : "" %>><%= StringUtils.escapeHTMLTags(JID.unescapeNode(user.getUsername())) %></a>
236
            <% if (isAdmin) { %><img src="/images/star-16x16.gif" height="16" width="16" align="top" alt="<fmt:message key='user.properties.isadmin'/>" title="<fmt:message key='user.properties.isadmin'/>"/><% } %>
237 238
            <% if (lockedOut) { %><img src="/images/forbidden-16x16.gif" height="16" width="16" align="top" alt="<fmt:message key='user.properties.locked'/>" title="<fmt:message key='user.properties.locked'/>"/><% } %>
            <% if (pendingLockOut) { %><img src="/images/warning-16x16.gif" height="16" width="16" align="top" alt="<fmt:message key='user.properties.locked_set'/>" title="<fmt:message key='user.properties.locked_set'/>"/><% } %>
Matt Tucker's avatar
Matt Tucker committed
239
        </td>
240
        <td width="23%">
Sven Tantau's avatar
Sven Tantau committed
241
            <%= StringUtils.escapeHTMLTags(user.getName()) %> &nbsp;
Matt Tucker's avatar
Matt Tucker committed
242
        </td>
243
        <td width="15%">
244 245 246 247 248 249 250 251 252 253 254 255 256
            <%
                Collection<Group> groups = webManager.getGroupManager().getGroups(user);
                if (groups.isEmpty()) {
            %>
                <i>None</i>
            <%
                }
                else {
                    int count = 0;
                    for (Group group : groups) {
                        if (count != 0) {
                            out.print(", ");
                        }
257
                        %><a href="group-edit.jsp?group=<%= URLEncoder.encode(group.getName(), "UTF-8") %>"><%= StringUtils.escapeHTMLTags(JID.unescapeNode(group.getName())) %></a><%
258 259 260 261 262 263
                        count++;
                    }
                }
            %>
        </td>
        <td width="12%">
Matt Tucker's avatar
Matt Tucker committed
264
            <%= JiveGlobals.formatDate(user.getCreationDate()) %>
265
        </td>
266
        <td width="23%">
267 268 269 270 271 272 273
            <% long logoutTime = presenceManager.getLastActivity(user);
                if (logoutTime > -1) {
                    out.println(StringUtils.getElapsedTime(logoutTime));
                }
                else {
                    out.println("&nbsp;");
                } %>
Matt Tucker's avatar
Matt Tucker committed
274
        </td>
275 276
         <%  // Don't allow editing or deleting if users are read-only.
            if (!UserManager.getUserProvider().isReadOnly()) { %>
Matt Tucker's avatar
Matt Tucker committed
277
        <td width="1%" align="center">
278
            <a href="user-edit-form.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
279
             title="<fmt:message key="global.click_edit" />"
280
             ><img src="images/edit-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="global.click_edit" />"></a>
Matt Tucker's avatar
Matt Tucker committed
281
        </td>
Bill Lynch's avatar
Bill Lynch committed
282
        <td width="1%" align="center" style="border-right:1px #ccc solid;">
283
            <a href="user-delete.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
284
             title="<fmt:message key="global.click_delete" />"
285
             ><img src="images/delete-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="global.click_delete" />"></a>
Matt Tucker's avatar
Matt Tucker committed
286
        </td>
287
        <% } %>
Matt Tucker's avatar
Matt Tucker committed
288 289 290 291 292
    </tr>

<%
    }
%>
Bill Lynch's avatar
Bill Lynch committed
293
</tbody>
Matt Tucker's avatar
Matt Tucker committed
294 295 296 297 298 299
</table>
</div>

<%  if (numPages > 1) { %>

    <p>
300
    <fmt:message key="global.pages" />:
Matt Tucker's avatar
Matt Tucker committed
301
    [
Bill Lynch's avatar
Bill Lynch committed
302 303 304 305 306
    <%  int num = 15 + curPage;
        int s = curPage-1;
        if (s > 5) {
            s -= 5;
        }
307 308 309
        if (s < 5) {
            s = 0;
        }
Bill Lynch's avatar
Bill Lynch committed
310 311 312 313 314 315 316
        if (s > 2) {
    %>
        <a href="user-summary.jsp?start=0&range=<%= range %>">1</a> ...

    <%
        }
        for (i=s; i<numPages && i<num; i++) {
Matt Tucker's avatar
Matt Tucker committed
317 318 319
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
Bill Lynch's avatar
Bill Lynch committed
320
        <a href="user-summary.jsp?start=<%= (i*range) %>&range=<%= range %>"
Matt Tucker's avatar
Matt Tucker committed
321 322 323 324
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
Bill Lynch's avatar
Bill Lynch committed
325 326 327 328 329 330 331

    <%  if (i < numPages) { %>

        ... <a href="user-summary.jsp?start=<%= ((numPages-1)*range) %>&range=<%= range %>"><%= numPages %></a>

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
332
    ]
Bill Lynch's avatar
Bill Lynch committed
333

Matt Tucker's avatar
Matt Tucker committed
334 335 336 337
    </p>

<%  } %>

338 339
    </body>
</html>