muc-room-summary.jsp 8.07 KB
Newer Older
Gaston Dombiak's avatar
Gaston Dombiak committed
1 2 3 4
<%--
  -	$Revision$
  -	$Date$
  -
5
  - Copyright (C) 2004-2005 Jive Software. All rights reserved.
Gaston Dombiak's avatar
Gaston Dombiak committed
6 7 8 9 10 11
  -
  - This software is the proprietary information of Jive Software.
  - Use is subject to license terms.
--%>

<%@ page import="org.jivesoftware.util.*,
12
                 org.jivesoftware.openfire.muc.MUCRoom,
Gaston Dombiak's avatar
Gaston Dombiak committed
13 14
                 java.util.*,
                 java.net.URLEncoder"
Gaston Dombiak's avatar
Gaston Dombiak committed
15 16
    errorPage="error.jsp"
%>
17
<%@ page import="org.jivesoftware.openfire.muc.MultiUserChatService" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
18 19

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
20
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
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="muc.room.summary.title"/></title>
        <meta name="pageID" content="muc-room-summary"/>
        <meta name="helpPage" content="edit_group_chat_room_settings.html"/>
    </head>
    <body>
Gaston Dombiak's avatar
Gaston Dombiak committed
31 32 33

<%  // Get parameters
    int start = ParamUtils.getIntParameter(request,"start",0);
34
    int range = ParamUtils.getIntParameter(request,"range",webManager.getRowsPerPage("muc-room-summary", 15));
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    String mucname = ParamUtils.getParameter(request,"mucname");

    MultiUserChatService mucService = null;
    if (webManager.getMultiUserChatManager().isServiceRegistered(mucname)) {
        mucService = webManager.getMultiUserChatManager().getMultiUserChatService(mucname);
    }
    else {
        for (MultiUserChatService muc : webManager.getMultiUserChatManager().getMultiUserChatServices()) {
            if (muc.isServicePrivate()) {
                // Private and hidden, skip it.
                continue;
            }
            mucService = muc;
            break;
        }
    }

    if (mucService == null) {
        // No services exist, so redirect to where one can configure the services
        response.sendRedirect("muc-service-summary.jsp");
        return;
    }
57 58 59 60

    if (request.getParameter("range") != null) {
        webManager.setRowsPerPage("muc-room-summary", range);
    }
Gaston Dombiak's avatar
Gaston Dombiak committed
61 62

    // Get the rooms in the server
63
    List<MUCRoom> rooms = mucService.getChatRooms();
64 65
    Collections.sort(rooms, new Comparator<MUCRoom>() {
        public int compare(MUCRoom room1, MUCRoom room2) {
Gaston Dombiak's avatar
Gaston Dombiak committed
66 67 68 69 70 71 72 73 74 75 76 77
            return room1.getName().toLowerCase().compareTo(room2.getName().toLowerCase());
        }
    });
    int roomsCount = rooms.size();

    // paginator vars
    int numPages = (int)Math.ceil((double)roomsCount/(double)range);
    int curPage = (start/range) + 1;
    int maxRoomIndex = (start+range <= roomsCount ? start+range : roomsCount);
%>

<p>
78
<fmt:message key="muc.room.summary.info" />
Gaston Dombiak's avatar
Gaston Dombiak committed
79 80 81 82 83 84 85
</p>

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

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
86
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
87
        <td class="jive-icon-label">
88
        <fmt:message key="muc.room.summary.destroyed" />
Gaston Dombiak's avatar
Gaston Dombiak committed
89 90 91 92 93 94 95 96
        </td></tr>
    </tbody>
    </table>
    </div><br>

<%  } %>

<p>
97
<fmt:message key="muc.room.summary.total_room" />: <%= roomsCount %>,
Gaston Dombiak's avatar
Gaston Dombiak committed
98 99
<%  if (numPages > 1) { %>

100
    <fmt:message key="global.showing" /> <%= (start+1) %>-<%= (maxRoomIndex) %>,
Gaston Dombiak's avatar
Gaston Dombiak committed
101 102

<%  } %>
103
<fmt:message key="muc.room.summary.sorted_id" />
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118

<% if (webManager.getMultiUserChatManager().getMultiUserChatServicesCount() > 1) { %>
-- <fmt:message key="muc.room.summary.service" />:
    <select name="mucname" onchange="location.href='muc-room-summary.jsp?mucname=' + this.options[this.selectedIndex].value;">
<% for (MultiUserChatService service : webManager.getMultiUserChatManager().getMultiUserChatServices()) {
    if (service.isServicePrivate()) {
        // Private and hidden, skip it.
        continue;
    }
%>
    <option value="<%= service.getServiceName() %>"<%= mucService.getServiceName().equals(service.getServiceName()) ? " selected='selected'" : "" %>><%= service.getServiceDomain() %></option>
<% } %>
    </select>
<% } %>

Gaston Dombiak's avatar
Gaston Dombiak committed
119 120 121 122 123
</p>

<%  if (numPages > 1) { %>

    <p>
124
    <fmt:message key="global.pages" />:
Gaston Dombiak's avatar
Gaston Dombiak committed
125 126 127 128 129
    [
    <%  for (int i=0; i<numPages; i++) {
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
130
        <a href="muc-room-summary.jsp?mucname=<%= mucname == null ? "" : mucname %>&start=<%= (i*range) %>"
Gaston Dombiak's avatar
Gaston Dombiak committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144
         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
145 146 147 148 149 150
        <th nowrap><fmt:message key="muc.room.summary.room" /></th>
        <th nowrap><fmt:message key="muc.room.summary.description" /></th>
        <th nowrap><fmt:message key="muc.room.summary.persistent" /></th>
        <th nowrap><fmt:message key="muc.room.summary.users" /></th>
        <th nowrap><fmt:message key="muc.room.summary.edit" /></th>
        <th nowrap><fmt:message key="muc.room.summary.destroy" /></th>
Gaston Dombiak's avatar
Gaston Dombiak committed
151 152 153 154 155 156 157 158 159 160
    </tr>
</thead>
<tbody>

<%  // Print the list of rooms
    Iterator<MUCRoom> roomsPage = rooms.subList(start, maxRoomIndex).iterator();
    if (!roomsPage.hasNext()) {
%>
    <tr>
        <td align="center" colspan="7">
161
            <fmt:message key="muc.room.summary.no_room_in_group" />
Gaston Dombiak's avatar
Gaston Dombiak committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175
        </td>
    </tr>

<%
    }
    int i = start;
    while (roomsPage.hasNext()) {
        MUCRoom room = roomsPage.next();
        i++;
%>
    <tr class="jive-<%= (((i%2)==0) ? "even" : "odd") %>">
        <td width="1%">
            <%= i %>
        </td>
Matt Tucker's avatar
Matt Tucker committed
176
        <td width="45%" valign="middle">
Matt Tucker's avatar
Matt Tucker committed
177
            <% if (room.getName().equals(room.getNaturalLanguageName())) { %>
178
                 <a href="muc-room-edit-form.jsp?roomJID=<%= URLEncoder.encode(room.getJID().toBareJID(), "UTF-8") %>"title="<fmt:message key="global.click_edit" />">
Ryan Graham's avatar
Ryan Graham committed
179 180
	                 <%=  room.getName() %>
	             </a>
Matt Tucker's avatar
Matt Tucker committed
181 182
            <% }
               else { %>
183
	            <a href="muc-room-edit-form.jsp?roomJID=<%= URLEncoder.encode(room.getJID().toBareJID(), "UTF-8") %>"title="<fmt:message key="global.click_edit" />">
Matt Tucker's avatar
Matt Tucker committed
184
                <%= room.getNaturalLanguageName() %> (<%=  room.getName() %>)
Ryan Graham's avatar
Ryan Graham committed
185
	            </a>
Matt Tucker's avatar
Matt Tucker committed
186
            <% } %>
Gaston Dombiak's avatar
Gaston Dombiak committed
187
        </td>
Matt Tucker's avatar
Matt Tucker committed
188
        <td width="45%" valign="middle">
Gaston Dombiak's avatar
Gaston Dombiak committed
189 190 191
            <%=  room.getDescription() %>
        </td>
        <td width="1%" align="center">
192
                <% if (room.isPersistent()) { %>
193
                <img src="images/tape.gif" width="16" height="16" border="0" alt="<fmt:message key="muc.room.summary.alt_persistent" />">
Gaston Dombiak's avatar
Gaston Dombiak committed
194
                <% } else { %>
195
                <img src="images/blank.gif" width="16" height="16" border="0" alt="<fmt:message key="muc.room.summary.alt_temporary" />">
Gaston Dombiak's avatar
Gaston Dombiak committed
196 197 198
                <% } %>
        </td>
        <td width="1%" align="center">
199
            <nobr><%= room.getOccupantsCount() %> / <%= room.getMaxUsers() %></nobr>
Gaston Dombiak's avatar
Gaston Dombiak committed
200 201
        </td>
        <td width="1%" align="center">
202
            <a href="muc-room-edit-form.jsp?roomJID=<%= URLEncoder.encode(room.getJID().toBareJID(), "UTF-8") %>"
203
             title="<fmt:message key="global.click_edit" />"
204
             ><img src="images/edit-16x16.gif" width="17" height="17" border="0" alt=""></a>
Gaston Dombiak's avatar
Gaston Dombiak committed
205 206
        </td>
        <td width="1%" align="center" style="border-right:1px #ccc solid;">
207
            <a href="muc-room-delete.jsp?roomJID=<%= URLEncoder.encode(room.getJID().toBareJID(), "UTF-8") %>"
208
             title="<fmt:message key="global.click_delete" />"
209
             ><img src="images/delete-16x16.gif" width="16" height="16" border="0" alt=""></a>
Gaston Dombiak's avatar
Gaston Dombiak committed
210 211 212 213 214 215 216 217 218 219 220 221 222
        </td>
    </tr>

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

<%  if (numPages > 1) { %>

    <p>
223
    <fmt:message key="global.pages" />:
Gaston Dombiak's avatar
Gaston Dombiak committed
224 225 226 227 228
    [
    <%  for (i=0; i<numPages; i++) {
            String sep = ((i+1)<numPages) ? " " : "";
            boolean isCurrent = (i+1) == curPage;
    %>
229
        <a href="muc-room-summary.jsp?mucname=<%= mucname == null ? "" : mucname %>&start=<%= (i*range) %>"
Gaston Dombiak's avatar
Gaston Dombiak committed
230 231 232 233 234 235 236 237 238
         class="<%= ((isCurrent) ? "jive-current" : "") %>"
         ><%= (i+1) %></a><%= sep %>

    <%  } %>
    ]
    </p>

<%  } %>

239 240
    </body>
</html>