user-summary.jsp 9.64 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
--%>

<%@ page import="org.jivesoftware.util.*,
                 org.jivesoftware.messenger.user.*,
Matt Tucker's avatar
Matt Tucker committed
14
                 java.util.*,
Matt Tucker's avatar
Matt Tucker committed
15 16
                 org.jivesoftware.messenger.user.UserManager,
                 java.text.DateFormat,
Derek DeMoro's avatar
Derek DeMoro committed
17
                 org.jivesoftware.admin.*,
Matt Tucker's avatar
Matt Tucker committed
18
                 org.jivesoftware.messenger.PresenceManager,
19
                 org.xmpp.packet.Presence,
Bill Lynch's avatar
Bill Lynch committed
20
                 java.net.URLEncoder,
21
                 org.jivesoftware.util.JiveGlobals"
Matt Tucker's avatar
Matt Tucker committed
22 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 32

<%!
    final int DEFAULT_RANGE = 15;
    final int[] RANGE_PRESETS = {15, 25, 50, 75, 100};
    final String USER_RANGE_PROP = "admin.userlist.range";
%>

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

Derek DeMoro's avatar
Derek DeMoro committed
36 37
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<%  // Title of this page and breadcrumbs
38
    String title = LocaleUtils.getLocalizedString("user.summary.title");
Derek DeMoro's avatar
Derek DeMoro committed
39
    pageinfo.setTitle(title);
40
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(LocaleUtils.getLocalizedString("global.main"), "index.jsp"));
Derek DeMoro's avatar
Derek DeMoro committed
41 42 43 44 45 46
    pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "user-summary.jsp"));
    pageinfo.setPageID("user-summary");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />

Matt Tucker's avatar
Matt Tucker committed
47 48
<%  // Get parameters
    int start = ParamUtils.getIntParameter(request,"start",0);
49 50 51 52 53 54 55
    int range = ParamUtils.getIntParameter(request,"range",DEFAULT_RANGE);
    boolean setRange = request.getParameter("range") != null;

    if (setRange) {
        User user = webManager.getUser();
        if (user != null) {
            if (range == DEFAULT_RANGE) {
56
                user.getProperties().remove(USER_RANGE_PROP);
57 58
            }
            else {
59
                user.getProperties().put(USER_RANGE_PROP, String.valueOf(range));
60 61 62 63 64 65 66 67
            }
        }
    }

    // Adjust the range based on the user's settings
    if (webManager.getUser() != null) {
        User user = webManager.getUser();
        try {
68
            range = Integer.parseInt(user.getProperties().get(USER_RANGE_PROP));
69 70
        }
        catch (Exception e) {
71
            user.getProperties().remove(USER_RANGE_PROP);
72 73
        }
    }
Matt Tucker's avatar
Matt Tucker committed
74 75

    // Get the user manager
Derek DeMoro's avatar
Derek DeMoro committed
76
    int userCount = webManager.getUserManager().getUserCount();
Matt Tucker's avatar
Matt Tucker committed
77 78

    // Get the presence manager
79
    PresenceManager presenceManager = webManager.getPresenceManager();
Matt Tucker's avatar
Matt Tucker committed
80 81 82 83 84 85 86

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

<p>
87
<fmt:message key="user.summary.info" />
Matt Tucker's avatar
Matt Tucker committed
88 89
</p>

Bill Lynch's avatar
Bill Lynch committed
90 91 92 93 94 95 96
<style type="text/css">
.jive-current {
    font-weight : bold;
    text-decoration : none;
}
</style>

Bill Lynch's avatar
Bill Lynch committed
97 98 99 100 101 102 103
<%  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">
104
        <fmt:message key="user.summary.deleted" />
Bill Lynch's avatar
Bill Lynch committed
105 106 107 108 109 110 111
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

Matt Tucker's avatar
Matt Tucker committed
112
<p>
Bill Lynch's avatar
Bill Lynch committed
113 114 115
<fmt:message key="user.summary.total_user" />:
<%= LocaleUtils.getLocalizedNumber(webManager.getUserManager().getUserCount()) %> --

Matt Tucker's avatar
Matt Tucker committed
116 117
<%  if (numPages > 1) { %>

Bill Lynch's avatar
Bill Lynch committed
118 119
    <fmt:message key="user.summary.showing" />
    <%= LocaleUtils.getLocalizedNumber(start+1) %>-<%= LocaleUtils.getLocalizedNumber(start+range) %>,
Matt Tucker's avatar
Matt Tucker committed
120 121

<%  } %>
122
<fmt:message key="user.summary.sorted" />
123

124
- <fmt:message key="user.summary.users_per_page" />:
125 126 127 128 129 130 131 132 133 134
<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
135 136 137 138 139
</p>

<%  if (numPages > 1) { %>

    <p>
140
    <fmt:message key="user.summary.pages" />:
Matt Tucker's avatar
Matt Tucker committed
141
    [
Bill Lynch's avatar
Bill Lynch committed
142 143 144 145 146
    <%  int num = 15 + curPage;
        int s = curPage-1;
        if (s > 5) {
            s -= 5;
        }
147 148 149
        if (s < 5) {
            s = 0;
        }
Bill Lynch's avatar
Bill Lynch committed
150 151 152 153 154 155 156 157
        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
158 159 160
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
161
        <a href="user-summary.jsp?start=<%= (i*range) %>&range=<%= range %>"
Matt Tucker's avatar
Matt Tucker committed
162 163 164 165
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
Bill Lynch's avatar
Bill Lynch committed
166 167 168 169 170 171 172

    <%  if (i < numPages) { %>

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

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
173
    ]
174

Matt Tucker's avatar
Matt Tucker committed
175 176 177 178
    </p>

<%  } %>

Bill Lynch's avatar
Bill Lynch committed
179 180 181 182 183
<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
184 185 186
        <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>
187 188 189
        <th nowrap><fmt:message key="user.summary.created" /></th>
        <th nowrap><fmt:message key="user.summary.edit" /></th>
        <th nowrap><fmt:message key="user.summary.delete" /></th>
Bill Lynch's avatar
Bill Lynch committed
190 191 192 193
    </tr>
</thead>
<tbody>

Matt Tucker's avatar
Matt Tucker committed
194
<%  // Print the list of users
Matt Tucker's avatar
Matt Tucker committed
195 196
    Collection<User> users = webManager.getUserManager().getUsers(start, range);
    if (users.isEmpty()) {
Matt Tucker's avatar
Matt Tucker committed
197 198 199
%>
    <tr>
        <td align="center" colspan="7">
200
            <fmt:message key="user.summary.not_user" />
Matt Tucker's avatar
Matt Tucker committed
201 202 203 204 205 206
        </td>
    </tr>

<%
    }
    int i = start;
Matt Tucker's avatar
Matt Tucker committed
207
    for (User user : users) {
Matt Tucker's avatar
Matt Tucker committed
208 209
        i++;
%>
Gaston Dombiak's avatar
Gaston Dombiak committed
210
    <tr class="jive-<%= (((i%2)==0) ? "even" : "odd") %>">
Matt Tucker's avatar
Matt Tucker committed
211 212 213
        <td width="1%">
            <%= i %>
        </td>
Matt Tucker's avatar
Matt Tucker committed
214 215 216 217
        <td width="1%" align="center" valign="middle">
            <%  if (presenceManager.isAvailable(user)) {
                    Presence presence = presenceManager.getPresence(user);
            %>
Derek DeMoro's avatar
Derek DeMoro committed
218
                <% if (presence.getShow() == null) { %>
219
                <img src="images/user-green-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="user.properties.available" />">
Matt Tucker's avatar
Matt Tucker committed
220
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
221
                <% if (presence.getShow() == Presence.Show.chat) { %>
222
                <img src="images/user-green-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="session.details.chat_available" />">
Matt Tucker's avatar
Matt Tucker committed
223
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
224
                <% if (presence.getShow() == Presence.Show.away) { %>
225
                <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="session.details.away" />">
Matt Tucker's avatar
Matt Tucker committed
226
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
227
                <% if (presence.getShow() == Presence.Show.xa) { %>
228
                <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="session.details.extended" />">
Matt Tucker's avatar
Matt Tucker committed
229
                <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
230
                <% if (presence.getShow() == Presence.Show.dnd) { %>
231
                <img src="images/user-red-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="session.details.not_disturb" />">
Matt Tucker's avatar
Matt Tucker committed
232
                <% } %>
Matt Tucker's avatar
Matt Tucker committed
233 234 235

            <%  } else { %>

236
                <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
237 238 239 240

            <%  } %>
        </td>
        <td width="30%">
241
            <a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"><%= user.getUsername() %></a>
Matt Tucker's avatar
Matt Tucker committed
242 243
        </td>
        <td width="40%">
Matt Tucker's avatar
Matt Tucker committed
244
            <%= user.getName() %> &nbsp;
Matt Tucker's avatar
Matt Tucker committed
245 246
        </td>
        <td width="26%">
Matt Tucker's avatar
Matt Tucker committed
247
            <%= JiveGlobals.formatDate(user.getCreationDate()) %>
Matt Tucker's avatar
Matt Tucker committed
248 249
        </td>
        <td width="1%" align="center">
250
            <a href="user-edit-form.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
251
             title="<fmt:message key="user.summary.click_edit" />"
Matt Tucker's avatar
Matt Tucker committed
252 253
             ><img src="images/edit-16x16.gif" width="17" height="17" border="0"></a>
        </td>
Bill Lynch's avatar
Bill Lynch committed
254
        <td width="1%" align="center" style="border-right:1px #ccc solid;">
255
            <a href="user-delete.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
256
             title="<fmt:message key="user.summary.click_delete" />"
Matt Tucker's avatar
Matt Tucker committed
257
             ><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
Matt Tucker's avatar
Matt Tucker committed
258 259 260 261 262 263
        </td>
    </tr>

<%
    }
%>
Bill Lynch's avatar
Bill Lynch committed
264
</tbody>
Matt Tucker's avatar
Matt Tucker committed
265 266 267 268 269 270
</table>
</div>

<%  if (numPages > 1) { %>

    <p>
271
    <fmt:message key="user.summary.pages" />:
Matt Tucker's avatar
Matt Tucker committed
272
    [
Bill Lynch's avatar
Bill Lynch committed
273 274 275 276 277
    <%  int num = 15 + curPage;
        int s = curPage-1;
        if (s > 5) {
            s -= 5;
        }
278 279 280
        if (s < 5) {
            s = 0;
        }
Bill Lynch's avatar
Bill Lynch committed
281 282 283 284 285 286 287 288
        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
289 290 291
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
Bill Lynch's avatar
Bill Lynch committed
292
        <a href="user-summary.jsp?start=<%= (i*range) %>&range=<%= range %>"
Matt Tucker's avatar
Matt Tucker committed
293 294 295 296
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
Bill Lynch's avatar
Bill Lynch committed
297 298 299 300 301 302 303

    <%  if (i < numPages) { %>

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

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
304
    ]
Bill Lynch's avatar
Bill Lynch committed
305

Matt Tucker's avatar
Matt Tucker committed
306 307 308 309
    </p>

<%  } %>

Bill Lynch's avatar
Bill Lynch committed
310
<jsp:include page="bottom.jsp" flush="true" />