user-summary.jsp 8.45 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"
Matt Tucker's avatar
Matt Tucker committed
19 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 59

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

<p>
60
<fmt:message key="user.summary.info" />
Matt Tucker's avatar
Matt Tucker committed
61 62
</p>

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

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

<%  } %>

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

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

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

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

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

<%  if (numPages > 1) { %>

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

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

    <%  if (i < numPages) { %>

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

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
146
    ]
147

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

<%  } %>

Bill Lynch's avatar
Bill Lynch committed
152 153 154 155 156
<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
157 158 159
        <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>
160 161
        <th nowrap><fmt:message key="user.summary.created" /></th>
        <th nowrap><fmt:message key="user.summary.edit" /></th>
162
        <th nowrap><fmt:message key="global.delete" /></th>
Bill Lynch's avatar
Bill Lynch committed
163 164 165 166
    </tr>
</thead>
<tbody>

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

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

            <%  } else { %>

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

            <%  } %>
        </td>
        <td width="30%">
214
            <a href="user-properties.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"><%= user.getUsername() %></a>
Matt Tucker's avatar
Matt Tucker committed
215 216
        </td>
        <td width="40%">
Matt Tucker's avatar
Matt Tucker committed
217
            <%= user.getName() %> &nbsp;
Matt Tucker's avatar
Matt Tucker committed
218 219
        </td>
        <td width="26%">
Matt Tucker's avatar
Matt Tucker committed
220
            <%= JiveGlobals.formatDate(user.getCreationDate()) %>
Matt Tucker's avatar
Matt Tucker committed
221 222
        </td>
        <td width="1%" align="center">
223
            <a href="user-edit-form.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
224
             title="<fmt:message key="global.click_edit" />"
Matt Tucker's avatar
Matt Tucker committed
225 226
             ><img src="images/edit-16x16.gif" width="17" height="17" border="0"></a>
        </td>
Bill Lynch's avatar
Bill Lynch committed
227
        <td width="1%" align="center" style="border-right:1px #ccc solid;">
228
            <a href="user-delete.jsp?username=<%= URLEncoder.encode(user.getUsername(), "UTF-8") %>"
229
             title="<fmt:message key="global.click_delete" />"
Matt Tucker's avatar
Matt Tucker committed
230
             ><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
Matt Tucker's avatar
Matt Tucker committed
231 232 233 234 235 236
        </td>
    </tr>

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

<%  if (numPages > 1) { %>

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

    <%  } %>
Bill Lynch's avatar
Bill Lynch committed
270 271 272 273 274 275 276

    <%  if (i < numPages) { %>

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

    <%  } %>

Matt Tucker's avatar
Matt Tucker committed
277
    ]
Bill Lynch's avatar
Bill Lynch committed
278

Matt Tucker's avatar
Matt Tucker committed
279 280 281 282
    </p>

<%  } %>

283 284
    </body>
</html>