group-summary.jsp 7.08 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4 5 6 7 8 9 10 11 12 13
<%--
  -	$RCSfile$
  -	$Revision$
  -	$Date$
  -
  - 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.
--%>

<%@ page import="org.jivesoftware.util.*,
                 java.util.*,
14
                 org.jivesoftware.openfire.group.*,
Derek DeMoro's avatar
Derek DeMoro committed
15
                 java.net.URLEncoder"
Matt Tucker's avatar
Matt Tucker committed
16 17
%>

18
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
19
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Matt Tucker's avatar
Matt Tucker committed
20 21 22 23

<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"  />
<% webManager.init(request, response, session, application, out ); %>

24 25 26 27 28 29 30
<html>
    <head>
        <title><fmt:message key="group.summary.title"/></title>
        <meta name="pageID" content="group-summary"/>
        <meta name="helpPage" content="about_users_and_groups.html"/>
    </head>
    <body>
Matt Tucker's avatar
Matt Tucker committed
31 32 33

<%  // Get parameters
    int start = ParamUtils.getIntParameter(request,"start",0);
34 35 36 37 38
    int range = ParamUtils.getIntParameter(request,"range",webManager.getRowsPerPage("group-summary", 15));

    if (request.getParameter("range") != null) {
        webManager.setRowsPerPage("group-summary", range);
    }
Matt Tucker's avatar
Matt Tucker committed
39 40

    int groupCount = webManager.getGroupManager().getGroupCount();
41 42 43 44 45 46 47 48 49 50 51 52 53
    Collection<Group> groups = webManager.getGroupManager().getGroups(start, range);

    String search = null;
    if (webManager.getGroupManager().isSearchSupported() && request.getParameter("search") != null
            && !request.getParameter("search").trim().equals(""))
    {
        search = request.getParameter("search");
        // Use the search terms to get the list of groups and group count.
        groups = webManager.getGroupManager().search(search, start, range);
        // Get the count as a search for *all* groups. That will let us do pagination even
        // though it's a bummer to execute the search twice.
        groupCount = webManager.getGroupManager().search(search).size();
    }
Matt Tucker's avatar
Matt Tucker committed
54 55 56 57 58 59 60 61 62 63 64

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

<%  if (request.getParameter("deletesuccess") != null) { %>

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
65
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Matt Tucker's avatar
Matt Tucker committed
66
        <td class="jive-icon-label">
67
        <fmt:message key="group.summary.delete_group" />
Matt Tucker's avatar
Matt Tucker committed
68 69 70 71 72 73 74
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

75 76 77 78 79 80 81
<% if (webManager.getGroupManager().isSearchSupported()) { %>

<form action="group-summary.jsp" method="get" name="searchForm">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td valign="bottom">
<fmt:message key="group.summary.total_group" /> <b><%= groupCount %></b>
Matt Tucker's avatar
Matt Tucker committed
82 83
<%  if (numPages > 1) { %>

84
    , <fmt:message key="global.showing" /> <%= LocaleUtils.getLocalizedNumber(start+1) %>-<%= LocaleUtils.getLocalizedNumber(start+range > groupCount ? groupCount:start+range) %>
Matt Tucker's avatar
Matt Tucker committed
85 86

<%  } %>
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
        </td>
        <td align="right" valign="bottom">
   <fmt:message key="group.summary.search" />: <input type="text" size="30" maxlength="150" name="search" value="<%= ((search!=null) ? search : "") %>">
        </td>
    </tr>
</table>
</form>

<script language="JavaScript" type="text/javascript">
document.searchForm.search.focus();
</script>

<% }
   // Otherwise, searching is not supported.
   else {
%>
    <p>
    <fmt:message key="group.summary.total_group" /> <b><%= groupCount %></b>
    <%  if (numPages > 1) { %>

        , <fmt:message key="global.showing" /> <%= (start+1) %>-<%= (start+range) %>

    <%  } %>
    </p>
<% } %>
Matt Tucker's avatar
Matt Tucker committed
112 113 114 115

<%  if (numPages > 1) { %>

    <p>
116
    <fmt:message key="global.pages" />
Matt Tucker's avatar
Matt Tucker committed
117 118 119 120 121
    [
    <%  for (int i=0; i<numPages; i++) {
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
122
        <a href="group-summary.jsp?start=<%= (i*range) %><%= search!=null? "&search=" + URLEncoder.encode(search, "UTF-8") : ""%>"
Matt Tucker's avatar
Matt Tucker committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
    ]
    </p>

<%  } %>

<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
137 138 139
        <th nowrap><fmt:message key="group.summary.page_name" /></th>
        <th nowrap><fmt:message key="group.summary.page_member" /></th>
        <th nowrap><fmt:message key="group.summary.page_admin" /></th>
140 141
        <%  // Only show edit and delete options if the groups aren't read-only.
            if (!webManager.getGroupManager().isReadOnly()) { %>
Bill Lynch's avatar
Bill Lynch committed
142
        <th nowrap><fmt:message key="group.summary.page_edit" /></th>
143
        <th nowrap><fmt:message key="global.delete" /></th>
144
        <% } %>
Matt Tucker's avatar
Matt Tucker committed
145 146 147 148 149 150 151 152 153
    </tr>
</thead>
<tbody>

<%  // Print the list of groups
    if (groups.isEmpty()) {
%>
    <tr>
        <td align="center" colspan="6">
154
            <fmt:message key="group.summary.no_groups" />
Matt Tucker's avatar
Matt Tucker committed
155 156 157 158 159 160 161
        </td>
    </tr>

<%
    }
    int i = start;
    for (Group group : groups) {
Derek DeMoro's avatar
Derek DeMoro committed
162
        String groupName = URLEncoder.encode(group.getName(), "UTF-8");
Matt Tucker's avatar
Matt Tucker committed
163 164 165
        i++;
%>
    <tr class="jive-<%= (((i%2)==0) ? "even" : "odd") %>">
Matt Tucker's avatar
Matt Tucker committed
166
        <td width="1%" valign="top">
Matt Tucker's avatar
Matt Tucker committed
167 168 169
            <%= i %>
        </td>
        <td width="60%">
Derek DeMoro's avatar
Derek DeMoro committed
170
            <a href="group-edit.jsp?group=<%= groupName %>"><%= group.getName() %></a>
Matt Tucker's avatar
Matt Tucker committed
171
            <% if (group.getDescription() != null) { %>
Matt Tucker's avatar
Matt Tucker committed
172 173 174 175
            <br>
                <span class="jive-description">
                <%= group.getDescription() %>
                </span>
Matt Tucker's avatar
Matt Tucker committed
176
             <% } %>
Matt Tucker's avatar
Matt Tucker committed
177
        </td>
Matt Tucker's avatar
Matt Tucker committed
178
        <td width="10%" align="center">
Matt Tucker's avatar
Matt Tucker committed
179 180
            <%= group.getMembers().size() %>
        </td>
Matt Tucker's avatar
Matt Tucker committed
181
        <td width="10%" align="center">
182
            <%= group.getAdmins().size() %>
Matt Tucker's avatar
Matt Tucker committed
183
        </td>
184 185
        <%  // Only show edit and delete options if the groups aren't read-only.
            if (!webManager.getGroupManager().isReadOnly()) { %>
Matt Tucker's avatar
Matt Tucker committed
186
        <td width="1%" align="center">
Derek DeMoro's avatar
Derek DeMoro committed
187
            <a href="group-edit.jsp?group=<%= groupName %>"
188
             title=<fmt:message key="global.click_edit" />
189
            ><img src="images/edit-16x16.gif" width="16" height="16" border="0" alt=""></a>
Matt Tucker's avatar
Matt Tucker committed
190 191
        </td>
        <td width="1%" align="center" style="border-right:1px #ccc solid;">
Derek DeMoro's avatar
Derek DeMoro committed
192
            <a href="group-delete.jsp?group=<%= groupName %>"
193
             title=<fmt:message key="global.click_delete" />
194
             ><img src="images/delete-16x16.gif" width="16" height="16" border="0" alt=""></a>
Matt Tucker's avatar
Matt Tucker committed
195
        </td>
196
        <% } %>
Matt Tucker's avatar
Matt Tucker committed
197 198 199 200 201 202 203 204 205 206
    </tr>

<%
    }
%>
</tbody>
</table>
</div>

<%  if (numPages > 1) { %>
207
    <br>
Matt Tucker's avatar
Matt Tucker committed
208
    <p>
209
    <fmt:message key="global.pages" />
Matt Tucker's avatar
Matt Tucker committed
210 211 212 213 214
    [
    <%  for (i=0; i<numPages; i++) {
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
215
        <a href="group-summary.jsp?start=<%= (i*range) %><%= search!=null? "&search=" + URLEncoder.encode(search, "UTF-8") : ""%>"
Matt Tucker's avatar
Matt Tucker committed
216 217 218 219 220 221 222 223 224
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
    ]
    </p>

<%  } %>

225 226
    </body>
</html>