%--
- $Revision$
- $Date$
-
- Copyright (C) 2004-2008 Jive Software. All rights reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--%>
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.openfire.muc.MUCRoom,
java.util.*,
java.net.URLEncoder"
errorPage="error.jsp"
%>
<%@ page import="org.jivesoftware.openfire.muc.MultiUserChatService" %>
<%@ page import="org.xmpp.packet.JID" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters
int start = ParamUtils.getIntParameter(request,"start",0);
int range = ParamUtils.getIntParameter(request,"range",webManager.getRowsPerPage("muc-room-summary", 15));
String mucname = ParamUtils.getParameter(request,"mucname");
String roomJIDStr = ParamUtils.getParameter(request,"roomJID");
JID roomJID = null;
if (roomJIDStr != null) roomJID = new JID(roomJIDStr);
MultiUserChatService mucService = null;
if (roomJID != null) {
mucService = webManager.getMultiUserChatManager().getMultiUserChatService(roomJID);
}
else if (mucname != null && webManager.getMultiUserChatManager().isServiceRegistered(mucname)) {
mucService = webManager.getMultiUserChatManager().getMultiUserChatService(mucname);
}
else {
for (MultiUserChatService muc : webManager.getMultiUserChatManager().getMultiUserChatServices()) {
if (muc.isHidden()) {
// 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;
}
if (request.getParameter("range") != null) {
webManager.setRowsPerPage("muc-room-summary", range);
}
// Get the rooms in the server
List rooms = mucService.getChatRooms();
Collections.sort(rooms, new Comparator() {
public int compare(MUCRoom room1, MUCRoom room2) {
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);
%>