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

<%@ page import="org.jivesoftware.util.*,
13
                 org.jivesoftware.wildfire.user.*,
Matt Tucker's avatar
Matt Tucker committed
14
                 java.util.*,
15
                 org.jivesoftware.wildfire.PresenceManager,
16
                 org.xmpp.packet.Presence,
Bill Lynch's avatar
Bill Lynch committed
17
                 java.net.URLEncoder,
18
                 org.jivesoftware.util.JiveGlobals"
19
%><%@ page import="org.xmpp.packet.JID"%>
Matt Tucker's avatar
Matt Tucker committed
20

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

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

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

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

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

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

    // Get the user manager
Derek DeMoro's avatar
Derek DeMoro committed
49
    int userCount = webManager.getUserManager().getUserCount();
Matt Tucker's avatar
Matt Tucker committed
50 51

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

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

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

Bill Lynch's avatar
Bill Lynch committed
66 67 68 69 70 71 72
<%  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">
73
        <fmt:message key="user.summary.deleted" />
Bill Lynch's avatar
Bill Lynch committed
74 75 76 77 78 79 80
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

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

Matt Tucker's avatar
Matt Tucker committed
85 86
<%  if (numPages > 1) { %>

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

<%  } %>
91
<fmt:message key="user.summary.sorted" />
92

93
-- <fmt:message key="user.summary.users_per_page" />:
94 95 96 97 98 99 100 101 102 103
<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
104 105 106 107 108
</p>

<%  if (numPages > 1) { %>

    <p>
109
    <fmt:message key="global.pages" />:
Matt Tucker's avatar
Matt Tucker committed
110
    [
Bill Lynch's avatar
Bill Lynch committed
111 112 113 114 115
    <%  int num = 15 + curPage;
        int s = curPage-1;
        if (s > 5) {
            s -= 5;
        }
116 117 118
        if (s < 5) {
            s = 0;
        }
Bill Lynch's avatar
Bill Lynch committed
119 120 121 122 123 124 125 126
        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
127 128 129
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
130
        <a href="user-summary.jsp?start=<%= (i*range) %>&range=<%= range %>"
Matt Tucker's avatar
Matt Tucker committed
131 132 133 134
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
Bill Lynch's avatar
Bill Lynch committed
135 136 137 138 139 140 141

    <%  if (i < numPages) { %>

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

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
142
    ]
143

Matt Tucker's avatar
Matt Tucker committed
144 145 146 147
    </p>

<%  } %>

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

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

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

            <%  } else { %>

208
                <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
209 210 211 212

            <%  } %>
        </td>
        <td width="30%">
213
            <a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"><%= JID.unescapeNode(user.getUsername()) %></a>
Matt Tucker's avatar
Matt Tucker committed
214 215
        </td>
        <td width="40%">
Matt Tucker's avatar
Matt Tucker committed
216
            <%= user.getName() %> &nbsp;
Matt Tucker's avatar
Matt Tucker committed
217 218
        </td>
        <td width="26%">
Matt Tucker's avatar
Matt Tucker committed
219
            <%= JiveGlobals.formatDate(user.getCreationDate()) %>
Matt Tucker's avatar
Matt Tucker committed
220
        </td>
221 222
         <%  // Don't allow editing or deleting if users are read-only.
            if (!UserManager.getUserProvider().isReadOnly()) { %>
Matt Tucker's avatar
Matt Tucker committed
223
        <td width="1%" align="center">
224
            <a href="user-edit-form.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
225
             title="<fmt:message key="global.click_edit" />"
226
             ><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
227
        </td>
Bill Lynch's avatar
Bill Lynch committed
228
        <td width="1%" align="center" style="border-right:1px #ccc solid;">
229
            <a href="user-delete.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
230
             title="<fmt:message key="global.click_delete" />"
231
             ><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
232
        </td>
233
        <% } %>
Matt Tucker's avatar
Matt Tucker committed
234 235 236 237 238
    </tr>

<%
    }
%>
Bill Lynch's avatar
Bill Lynch committed
239
</tbody>
Matt Tucker's avatar
Matt Tucker committed
240 241 242 243 244 245
</table>
</div>

<%  if (numPages > 1) { %>

    <p>
246
    <fmt:message key="global.pages" />:
Matt Tucker's avatar
Matt Tucker committed
247
    [
Bill Lynch's avatar
Bill Lynch committed
248 249 250 251 252
    <%  int num = 15 + curPage;
        int s = curPage-1;
        if (s > 5) {
            s -= 5;
        }
253 254 255
        if (s < 5) {
            s = 0;
        }
Bill Lynch's avatar
Bill Lynch committed
256 257 258 259 260 261 262 263
        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
264 265 266
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
Bill Lynch's avatar
Bill Lynch committed
267
        <a href="user-summary.jsp?start=<%= (i*range) %>&range=<%= range %>"
Matt Tucker's avatar
Matt Tucker committed
268 269 270 271
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
Bill Lynch's avatar
Bill Lynch committed
272 273 274 275 276 277 278

    <%  if (i < numPages) { %>

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

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
279
    ]
Bill Lynch's avatar
Bill Lynch committed
280

Matt Tucker's avatar
Matt Tucker committed
281 282 283 284
    </p>

<%  } %>

285 286
    </body>
</html>