user-summary.jsp 9.72 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 7 8 9
  -
  - Copyright (C) 2004 Jive Software. All rights reserved.
  -
  - 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
10 11
--%>

12 13 14 15
<%@ page import="org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.LocaleUtils,
                 org.jivesoftware.util.ParamUtils,
                 org.jivesoftware.util.StringUtils,
16 17 18
                 org.jivesoftware.openfire.PresenceManager,
                 org.jivesoftware.openfire.user.User,
                 org.jivesoftware.openfire.user.UserManager"
19
%><%@ page import="org.xmpp.packet.JID"%>
20 21 22
<%@ page import="org.xmpp.packet.Presence" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.Collection" %>
Matt Tucker's avatar
Matt Tucker committed
23

24
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
25
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
26 27 28 29 30 31

<%!
    final int DEFAULT_RANGE = 15;
    final int[] RANGE_PRESETS = {15, 25, 50, 75, 100};
%>

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

35 36 37 38 39 40 41
<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
42

Matt Tucker's avatar
Matt Tucker committed
43 44
<%  // Get parameters
    int start = ParamUtils.getIntParameter(request,"start",0);
45
    int range = ParamUtils.getIntParameter(request,"range",webManager.getRowsPerPage("user-summary", DEFAULT_RANGE));
46

47 48
    if (request.getParameter("range") != null) {
        webManager.setRowsPerPage("user-summary", range);
49
    }
Matt Tucker's avatar
Matt Tucker committed
50 51

    // Get the user manager
Derek DeMoro's avatar
Derek DeMoro committed
52
    int userCount = webManager.getUserManager().getUserCount();
Matt Tucker's avatar
Matt Tucker committed
53 54

    // Get the presence manager
55
    PresenceManager presenceManager = webManager.getPresenceManager();
Matt Tucker's avatar
Matt Tucker committed
56 57 58 59 60 61

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

Bill Lynch's avatar
Bill Lynch committed
62 63 64 65 66 67 68
<style type="text/css">
.jive-current {
    font-weight : bold;
    text-decoration : none;
}
</style>

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

    <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">
76
        <fmt:message key="user.summary.deleted" />
Bill Lynch's avatar
Bill Lynch committed
77 78 79 80 81 82 83
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

Matt Tucker's avatar
Matt Tucker committed
84
<p>
Bill Lynch's avatar
Bill Lynch committed
85
<fmt:message key="user.summary.total_user" />:
86
<b><%= LocaleUtils.getLocalizedNumber(userCount) %></b> --
Bill Lynch's avatar
Bill Lynch committed
87

Matt Tucker's avatar
Matt Tucker committed
88 89
<%  if (numPages > 1) { %>

90
    <fmt:message key="global.showing" />
91
    <%= LocaleUtils.getLocalizedNumber(start+1) %>-<%= LocaleUtils.getLocalizedNumber(start+range > userCount ? userCount:start+range) %>,
Matt Tucker's avatar
Matt Tucker committed
92 93

<%  } %>
94
<fmt:message key="user.summary.sorted" />
95

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

    <%  for (int i=0; i<RANGE_PRESETS.length; i++) { %>

        <option value="<%= RANGE_PRESETS[i] %>"
         <%= (RANGE_PRESETS[i] == range ? "selected" : "") %>><%= RANGE_PRESETS[i] %></option>

    <%  } %>

</select>
Matt Tucker's avatar
Matt Tucker committed
107 108 109 110 111
</p>

<%  if (numPages > 1) { %>

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

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

    <%  } %>
Bill Lynch's avatar
Bill Lynch committed
138 139 140 141 142 143 144

    <%  if (i < numPages) { %>

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

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
145
    ]
146

Matt Tucker's avatar
Matt Tucker committed
147 148 149 150
    </p>

<%  } %>

Bill Lynch's avatar
Bill Lynch committed
151 152 153 154 155
<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
156 157 158
        <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>
159
        <th nowrap><fmt:message key="user.summary.created" /></th>
160
        <th nowrap><fmt:message key="user.summary.last-logout" /></th>
161 162
         <%  // Don't allow editing or deleting if users are read-only.
            if (!UserManager.getUserProvider().isReadOnly()) { %>
163
        <th nowrap><fmt:message key="user.summary.edit" /></th>
164
        <th nowrap><fmt:message key="global.delete" /></th>
165
        <% } %>
Bill Lynch's avatar
Bill Lynch committed
166 167 168 169
    </tr>
</thead>
<tbody>

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

<%
    }
    int i = start;
Matt Tucker's avatar
Matt Tucker committed
183
    for (User user : users) {
Matt Tucker's avatar
Matt Tucker committed
184 185
        i++;
%>
Gaston Dombiak's avatar
Gaston Dombiak committed
186
    <tr class="jive-<%= (((i%2)==0) ? "even" : "odd") %>">
Matt Tucker's avatar
Matt Tucker committed
187 188 189
        <td width="1%">
            <%= i %>
        </td>
Matt Tucker's avatar
Matt Tucker committed
190 191 192 193
        <td width="1%" align="center" valign="middle">
            <%  if (presenceManager.isAvailable(user)) {
                    Presence presence = presenceManager.getPresence(user);
            %>
Derek DeMoro's avatar
Derek DeMoro committed
194
                <% if (presence.getShow() == null) { %>
195
                <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
196
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
197
                <% if (presence.getShow() == Presence.Show.chat) { %>
198
                <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
199
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
200
                <% if (presence.getShow() == Presence.Show.away) { %>
201
                <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
202
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
203
                <% if (presence.getShow() == Presence.Show.xa) { %>
204
                <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
205
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
206
                <% if (presence.getShow() == Presence.Show.dnd) { %>
207
                <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
208
                <% } %>
Matt Tucker's avatar
Matt Tucker committed
209 210 211

            <%  } else { %>

212
                <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
213 214 215

            <%  } %>
        </td>
216
        <td width="23%">
217
            <a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"><%= JID.unescapeNode(user.getUsername()) %></a>
Matt Tucker's avatar
Matt Tucker committed
218
        </td>
219
        <td width="33%">
Matt Tucker's avatar
Matt Tucker committed
220
            <%= user.getName() %> &nbsp;
Matt Tucker's avatar
Matt Tucker committed
221
        </td>
222
        <td width="15%">
Matt Tucker's avatar
Matt Tucker committed
223
            <%= JiveGlobals.formatDate(user.getCreationDate()) %>
224 225 226 227 228 229 230 231 232
        </td>
        <td width="25%">
            <% long logoutTime = presenceManager.getLastActivity(user);
                if (logoutTime > -1) {
                    out.println(StringUtils.getElapsedTime(logoutTime));
                }
                else {
                    out.println("&nbsp;");
                } %>
Matt Tucker's avatar
Matt Tucker committed
233
        </td>
234 235
         <%  // Don't allow editing or deleting if users are read-only.
            if (!UserManager.getUserProvider().isReadOnly()) { %>
Matt Tucker's avatar
Matt Tucker committed
236
        <td width="1%" align="center">
237
            <a href="user-edit-form.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
238
             title="<fmt:message key="global.click_edit" />"
239
             ><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
240
        </td>
Bill Lynch's avatar
Bill Lynch committed
241
        <td width="1%" align="center" style="border-right:1px #ccc solid;">
242
            <a href="user-delete.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
243
             title="<fmt:message key="global.click_delete" />"
244
             ><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
245
        </td>
246
        <% } %>
Matt Tucker's avatar
Matt Tucker committed
247 248 249 250 251
    </tr>

<%
    }
%>
Bill Lynch's avatar
Bill Lynch committed
252
</tbody>
Matt Tucker's avatar
Matt Tucker committed
253 254 255 256 257 258
</table>
</div>

<%  if (numPages > 1) { %>

    <p>
259
    <fmt:message key="global.pages" />:
Matt Tucker's avatar
Matt Tucker committed
260
    [
Bill Lynch's avatar
Bill Lynch committed
261 262 263 264 265
    <%  int num = 15 + curPage;
        int s = curPage-1;
        if (s > 5) {
            s -= 5;
        }
266 267 268
        if (s < 5) {
            s = 0;
        }
Bill Lynch's avatar
Bill Lynch committed
269 270 271 272 273 274 275 276
        if (s > 2) {
    %>
        <a href="user-summary.jsp?start=0&range=<%= range %>">1</a> ...

    <%
        }
        i = 0;
        for (i=s; i<numPages && i<num; i++) {
Matt Tucker's avatar
Matt Tucker committed
277 278 279
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
Bill Lynch's avatar
Bill Lynch committed
280
        <a href="user-summary.jsp?start=<%= (i*range) %>&range=<%= range %>"
Matt Tucker's avatar
Matt Tucker committed
281 282 283 284
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
Bill Lynch's avatar
Bill Lynch committed
285 286 287 288 289 290 291

    <%  if (i < numPages) { %>

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

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
292
    ]
Bill Lynch's avatar
Bill Lynch committed
293

Matt Tucker's avatar
Matt Tucker committed
294 295 296 297
    </p>

<%  } %>

298 299
    </body>
</html>