Commit 2e849c01 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Initial version. JM-77


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@699 b35dd754-fafc-0310-a699-88a17e54d16e
parent 13968f72
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 Jive Software. All rights reserved.
-
- This software is the proprietary information of Jive Software.
- Use is subject to license terms.
--%>
<%@ page import="org.jivesoftware.util.*,
java.util.*,
org.jivesoftware.messenger.*,
org.jivesoftware.admin.*,
java.util.Iterator,
org.jivesoftware.messenger.muc.*,
org.xmpp.packet.IQ,
org.dom4j.Element"
errorPage="error.jsp"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<jsp:useBean id="admin" class="org.jivesoftware.util.WebManager" />
<% admin.init(request, response, session, application, out ); %>
<% // Get parameters
String roomName = ParamUtils.getParameter(request,"roomName");
String affiliation = ParamUtils.getParameter(request,"affiliation");
String userJID = ParamUtils.getParameter(request,"userJID");
boolean add = request.getParameter("add") != null;
boolean addsuccess = request.getParameter("addsuccess") != null;
boolean deletesuccess = request.getParameter("deletesuccess") != null;
boolean delete = ParamUtils.getBooleanParameter(request,"delete");
// Load the room object
MUCRoom room = admin.getMultiUserChatServer().getChatRoom(roomName);
if (room == null) {
// The requested room name does not exist so return to the list of the existing rooms
response.sendRedirect("muc-room-summary.jsp");
return;
}
Map errors = new HashMap();
// Handle an add
if (add) {
// do validation
if (userJID == null || userJID.indexOf('@') == -1) {
errors.put("userJID","userJID");
}
if (errors.size() == 0) {
try {
IQ iq = new IQ(IQ.Type.set);
if ("owner".equals(affiliation) || "admin".equals(affiliation)) {
Element frag = iq.setChildElement("query", "http://jabber.org/protocol/muc#owner");
Element item = frag.addElement("item");
item.addAttribute("affiliation", affiliation);
item.addAttribute("jid", userJID);
// Send the IQ packet that will modify the room's configuration
room.getIQOwnerHandler().handleIQ(iq, room.getRole());
}
else if ("member".equals(affiliation) || "outcast".equals(affiliation)) {
Element frag = iq.setChildElement("query", "http://jabber.org/protocol/muc#admin");
Element item = frag.addElement("item");
item.addAttribute("affiliation", affiliation);
item.addAttribute("jid", userJID);
// Send the IQ packet that will modify the room's configuration
room.getIQAdminHandler().handleIQ(iq, room.getRole());
}
// done, return
response.sendRedirect("muc-room-affiliations.jsp?addsuccess=true&roomName="+roomName);
return;
}
catch (ConflictException e) {
errors.put("ConflictException","ConflictException");
}
catch (NotAllowedException e) {
errors.put("NotAllowedException","NotAllowedException");
}
}
}
if (delete) {
// Remove the user from the allowed list
IQ iq = new IQ(IQ.Type.set);
Element frag = iq.setChildElement("query", "http://jabber.org/protocol/muc#admin");
Element item = frag.addElement("item");
item.addAttribute("affiliation", "none");
item.addAttribute("jid", userJID);
try {
// Send the IQ packet that will modify the room's configuration
room.getIQOwnerHandler().handleIQ(iq, room.getRole());
// done, return
response.sendRedirect("muc-room-affiliations.jsp?deletesuccess=true&roomName="+roomName);
return;
}
catch (ConflictException e) {
errors.put("ConflictException","ConflictException");
}
}
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "User Permissions";
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Room Permissions", "muc-room-affiliations.jsp?roomName="+roomName));
pageinfo.setSubPageID("muc-room-affiliations");
pageinfo.setExtraParams("roomName="+roomName);
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<p>
Below is the list of room owners, administrators, members and outcasts of the the room
<b><a href="muc-room-edit-form.jsp?roomName=<%= room.getName() %>"><%= room.getName() %></a></b>.
Room owners can alter the room configuration, grant ownership and administrative privileges to users
and destroy the room. Room administrators can ban, grant membership and moderator privileges to
users. Room members are the only allowed users to join the room when it is configured as members-only.
Whilst room outcasts are users who have been banned from the room.
</p>
<% if (errors.size() > 0) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
<% if (errors.containsKey("ConflictException")) { %>
Error removing the user. The room must have at least one owner.
<% } else if (errors.containsKey("NotAllowedException")) { %>
Error banning the user. Owners or Administratos cannot be banned.
<% } else { %>
Error adding the user. Please verify the JID is correct.
<% } %>
</td></tr>
</tbody>
</table>
</div><br>
<% } else if (addsuccess || deletesuccess) { %>
<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">
<% if (addsuccess) { %>
User added successfully.
<% } else if (deletesuccess) { %>
User removed successfully.
<% } %>
</td></tr>
</tbody>
</table>
</div><br>
<% } %>
<form action="muc-room-affiliations.jsp?add" method="post">
<input type="hidden" name="roomName" value="<%= roomName %>">
<fieldset>
<legend>User Permissions</legend>
<div>
<p>
<label for="memberJID">Add User (JID):</label>
<input type="text" name="userJID" size="30" maxlength="100" value="<%= (userJID != null ? userJID : "") %>" id="memberJID">
<select name="affiliation">
<option value="owner">Owner</option>
<option value="admin">Admin</option>
<option value="member">Member</option>
<option value="outcast">Outcast</option>
</select>
<input type="submit" value="Add">
</p>
<div class="jive-table" style="width:400px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th colspan="2">User</th>
<th width="1%">Delete</th>
</tr>
</thead>
<tbody>
<%-- Add owners section --%>
<tr>
<td colspan="2"><b>Room Owners</b></td>
<td>&nbsp;</td>
</tr>
<% if (room.getOwners().isEmpty()) { %>
<tr>
<td colspan="2" align="center"><i>No Users</i></td>
<td>&nbsp;</td>
</tr>
<% }
else {
for (String user : room.getOwners()) {
%>
<tr>
<td>&nbsp;</td>
<td>
<%= user %>
</td>
<td width="1%" align="center">
<a href="muc-room-affiliations.jsp?roomName=<%= roomName %>&userJID=<%= user %>&delete=true&affiliation=owner"
title="Click to delete..."
onclick="return confirm('Are you sure you want to remove this user from the list?');"
><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
</td>
</tr>
<% } } %>
<%-- Add admins section --%>
<tr>
<td colspan="2"><b>Room Admins</b></td>
<td>&nbsp;</td>
</tr>
<% if (room.getAdmins().isEmpty()) { %>
<tr>
<td colspan="2" align="center"><i>No Users</i></td>
<td>&nbsp;</td>
</tr>
<% }
else {
for (String user : room.getAdmins()) {
%>
<tr>
<td>&nbsp;</td>
<td>
<%= user %>
</td>
<td width="1%" align="center">
<a href="muc-room-affiliations.jsp?roomName=<%= roomName %>&userJID=<%= user %>&delete=true&affiliation=admin"
title="Click to delete..."
onclick="return confirm('Are you sure you want to remove this user from the list?');"
><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
</td>
</tr>
<% } } %>
<%-- Add members section --%>
<tr>
<td colspan="2"><b>Room Members</b></td>
<td>&nbsp;</td>
</tr>
<% if (room.getMembers().isEmpty()) { %>
<tr>
<td colspan="2" align="center"><i>No Users</i></td>
<td>&nbsp;</td>
</tr>
<% }
else {
for (String user : room.getMembers()) {
String nickname = room.getReservedNickname(user);
nickname = (nickname == null ? "" : " (" + nickname + ")");
%>
<tr>
<td>&nbsp;</td>
<td>
<%= user %><%= nickname %>
</td>
<td width="1%" align="center">
<a href="muc-room-affiliations.jsp?roomName=<%= roomName %>&userJID=<%= user %>&delete=true&affiliation=member"
title="Click to delete..."
onclick="return confirm('Are you sure you want to remove this user from the list?');"
><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
</td>
</tr>
<% } } %>
<%-- Add outcasts section --%>
<tr>
<td colspan="2"><b>Room Outcasts</b></td>
<td>&nbsp;</td>
</tr>
<% if (room.getOutcasts().isEmpty()) { %>
<tr>
<td colspan="2" align="center"><i>No Users</i></td>
<td>&nbsp;</td>
</tr>
<% }
else {
for (String user : room.getOutcasts()) {
%>
<tr>
<td>&nbsp;</td>
<td>
<%= user %>
</td>
<td width="1%" align="center">
<a href="muc-room-affiliations.jsp?roomName=<%= roomName %>&userJID=<%= user %>&delete=true&affiliation=outcast"
title="Click to delete..."
onclick="return confirm('Are you sure you want to remove this user from the list?');"
><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
</td>
</tr>
<% } } %>
</tbody>
</table>
</div>
</div>
</fieldset>
</form>
<jsp:include page="bottom.jsp" flush="true" />
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 Jive Software. All rights reserved.
-
- This software is the proprietary information of Jive Software.
- Use is subject to license terms.
--%>
<%@ page import="org.jivesoftware.util.ParamUtils,
org.jivesoftware.admin.*,
java.util.*,
org.jivesoftware.messenger.muc.MUCRoom,
org.jivesoftware.messenger.*,
org.jivesoftware.messenger.auth.UnauthorizedException,
org.xmpp.packet.JID"
errorPage="error.jsp"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out); %>
<% // Get parameters
boolean save = ParamUtils.getBooleanParameter(request,"save");
String roomName = ParamUtils.getParameter(request,"roomName");
// Handle a cancel
if (request.getParameter("cancel") != null) {
response.sendRedirect("muc-room-summary.jsp");
return;
}
// Handle a save
Map errors = new HashMap();
if (save) {
// do validation
if (roomName == null || roomName.contains("@")) {
errors.put("roomName","roomName");
}
MUCRoom room = null;
// If everything is ok so far then try to create a new room (with default configuration)
if (errors.size() == 0) {
// Check that the requested room ID is available
room = webManager.getMultiUserChatServer().getChatRoom(roomName);
if (room != null) {
errors.put("room_already_exists", "room_already_exists");
}
else {
// Try to create a new room
JID address = new JID(webManager.getUser().getUsername(), webManager.getServerInfo().getName(), null);
try {
room = webManager.getMultiUserChatServer().getChatRoom(roomName, address);
// Check if the room was created concurrently by another user
if (!room.getOwners().contains(address.toBareJID())) {
errors.put("room_already_exists", "room_already_exists");
}
}
catch (UnauthorizedException e) {
// This user is not allowed to create rooms
errors.put("not_enough_permissions", "not_enough_permissions");
}
}
}
if (errors.size() == 0) {
// Creation good, so redirect
response.sendRedirect("muc-room-edit-form.jsp?addsuccess=true&roomconfig_persistentroom=true&roomName=" + roomName);
return;
}
}
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "Room Creation";
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "muc-room-create.jsp"));
pageinfo.setPageID("muc-room-create");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<p>Use the form below to create a new room. After the room has been created you will need to set the
room configuration to unlock the room.</p>
<% if (errors.containsKey("room_already_exists") || errors.containsKey("not_enough_permissions")) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
<% if (errors.containsKey("room_already_exists")) { %>
Error creating the room. A room with the request ID already exists.
<% } else if (errors.containsKey("not_enough_permissions")) { %>
Error creating the room. You do not have enough privileges to create rooms.
<% } %>
</td></tr>
</tbody>
</table>
</div><br>
<% } %>
<form action="muc-room-create.jsp">
<input type="hidden" name="save" value="true">
<table cellpadding="3" cellspacing="1" border="0" width="350">
<tr class="jive-even">
<td width="70">
Room ID:
</td>
<td><input type="text" name="roomName" value="<%= roomName != null ? roomName : ""%>">
<% if (errors.get("roomName") != null) { %>
<span class="jive-error-text">
Please enter a valid ID. Do not include the service name in the ID.
</span>
<% } %>
</td>
</tr>
</table>
<br>
<input type="submit" name="Submit" value="Create Room">
<input type="submit" name="cancel" value="Cancel">
</form>
<jsp:include page="bottom.jsp" flush="true" />
\ No newline at end of file
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 Jive Software. All rights reserved.
-
- This software is the proprietary information of Jive Software.
- Use is subject to license terms.
--%>
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.admin.*,
org.jivesoftware.messenger.muc.MUCRoom"
errorPage="error.jsp"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters //
boolean cancel = request.getParameter("cancel") != null;
boolean delete = request.getParameter("delete") != null;
String roomName = ParamUtils.getParameter(request,"roomName");
String alternateJID = ParamUtils.getParameter(request,"alternateJID");
String reason = ParamUtils.getParameter(request,"reason");
// Handle a cancel
if (cancel) {
response.sendRedirect("muc-room-summary.jsp");
return;
}
// Load the room object
MUCRoom room = webManager.getMultiUserChatServer().getChatRoom(roomName);
// Handle a room delete:
if (delete) {
// Delete the room
if (room != null) {
// If the room still exists then destroy it
room.destroyRoom(alternateJID, reason);
}
// Done, so redirect
response.sendRedirect("muc-room-summary.jsp?deletesuccess=true");
return;
}
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "Destroy Room";
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "muc-room-delete.jsp?roomName="+roomName));
pageinfo.setSubPageID("muc-room-delete");
pageinfo.setExtraParams("roomName="+roomName);
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<p>
Are you sure you want to destroy the room
<b><a href="muc-room-edit-form.jsp?roomName=<%= room.getName() %>"><%= room.getName() %></a></b>
from the system? You may specify a reason for the room destruction and an alternative room
address that will replace this room. This information will be sent to room occupants.
</p>
<form action="muc-room-delete.jsp">
<input type="hidden" name="roomName" value="<%= roomName %>">
<fieldset>
<legend>Destruction Details</legend>
<div>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td class="c1">
Room ID:
</td>
<td>
<%= room.getName() %>
</td>
</tr>
<tr>
<td class="c1">
Reason:
</td>
<td>
<input type="text" size="50" maxlength="150" name="reason">
</td>
</tr>
<tr>
<td class="c1">
Alternate Room Address:
</td>
<td>
<input type="text" size="30" maxlength="150" name="alternateJID">
</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
<br><br>
<input type="submit" name="delete" value="Destroy Room">
<input type="submit" name="cancel" value="Cancel">
</form>
<jsp:include page="bottom.jsp" flush="true" />
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 Jive Software. All rights reserved.
-
- This software is the proprietary information of Jive Software.
- Use is subject to license terms.
--%>
<%@ page import="org.jivesoftware.util.ParamUtils,
java.text.DateFormat,
org.jivesoftware.admin.*,
java.util.*,
org.jivesoftware.messenger.muc.MUCRoom,
org.jivesoftware.messenger.forms.spi.*,
org.jivesoftware.messenger.forms.*,
org.dom4j.Element,
org.dom4j.DocumentHelper,
org.dom4j.QName,
org.xmpp.packet.IQ,
org.xmpp.packet.Message"
errorPage="error.jsp"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% // Get parameters
boolean save = ParamUtils.getBooleanParameter(request,"save");
boolean success = ParamUtils.getBooleanParameter(request,"success");
boolean addsuccess = ParamUtils.getBooleanParameter(request,"addsuccess");
String roomName = ParamUtils.getParameter(request,"roomName");
String naturalName = ParamUtils.getParameter(request,"roomconfig_roomname");
String description = ParamUtils.getParameter(request,"roomconfig_roomdesc");
String maxUsers = ParamUtils.getParameter(request, "roomconfig_maxusers");
String broadcastModerator = ParamUtils.getParameter(request, "roomconfig_presencebroadcast");
String broadcastParticipant = ParamUtils.getParameter(request, "roomconfig_presencebroadcast2");
String broadcastVisitor = ParamUtils.getParameter(request, "roomconfig_presencebroadcast3");
String password = ParamUtils.getParameter(request, "roomconfig_roomsecret");
String confirmPassword = ParamUtils.getParameter(request, "roomconfig_roomsecret2");
String whois = ParamUtils.getParameter(request, "roomconfig_whois");
String publicRoom = ParamUtils.getParameter(request, "roomconfig_publicroom");
String persistentRoom = ParamUtils.getParameter(request, "roomconfig_persistentroom");
String moderatedRoom = ParamUtils.getParameter(request, "roomconfig_moderatedroom");
String membersOnly = ParamUtils.getParameter(request, "roomconfig_membersonly");
String allowInvites = ParamUtils.getParameter(request, "roomconfig_allowinvites");
String changeSubject = ParamUtils.getParameter(request, "roomconfig_changesubject");
String enableLog = ParamUtils.getParameter(request, "roomconfig_enablelogging");
String roomSubject = ParamUtils.getParameter(request, "room_topic");
// Handle a cancel
if (request.getParameter("cancel") != null) {
response.sendRedirect("muc-room-edit-form.jsp?roomName=" + roomName);
return;
}
// Load the room object
MUCRoom room = webManager.getMultiUserChatServer().getChatRoom(roomName);
if (room == null) {
// The requested room name does not exist so return to the list of the existing rooms
response.sendRedirect("muc-room-summary.jsp");
return;
}
// Handle a save
Map errors = new HashMap();
if (save) {
// do validation
if (naturalName == null) {
errors.put("roomconfig_roomname","roomconfig_roomname");
}
if (description == null) {
errors.put("roomconfig_roomdesc","roomconfig_roomdesc");
}
if (roomSubject == null) {
errors.put("room_topic","room_topic");
}
if (maxUsers == null) {
errors.put("roomconfig_maxusers","roomconfig_maxusers");
}
if (password != null && !password.equals(confirmPassword)) {
errors.put("roomconfig_roomsecret2","roomconfig_roomsecret2");
}
if (whois == null) {
errors.put("roomconfig_whois","roomconfig_whois");
}
if (errors.size() == 0) {
// Set the new configuration sending an IQ packet with an dataform
FormField field;
XDataFormImpl dataForm = new XDataFormImpl(DataForm.TYPE_SUBMIT);
field = new XFormFieldImpl("FORM_TYPE");
field.setType(FormField.TYPE_HIDDEN);
field.addValue("http://jabber.org/protocol/muc#roomconfig");
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_roomname");
field.addValue(naturalName);
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_roomdesc");
field.addValue(description);
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_changesubject");
field.addValue((changeSubject == null) ? "0": "1");
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_maxusers");
field.addValue(maxUsers);
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_presencebroadcast");
if (broadcastModerator != null) {
field.addValue("moderator");
}
if (broadcastParticipant != null) {
field.addValue("participant");
}
if (broadcastVisitor != null) {
field.addValue("visitor");
}
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_publicroom");
field.addValue((publicRoom == null) ? "0": "1");
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_persistentroom");
field.addValue((persistentRoom == null) ? "0": "1");
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_moderatedroom");
field.addValue((moderatedRoom == null) ? "0": "1");
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_membersonly");
field.addValue((membersOnly == null) ? "0": "1");
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_allowinvites");
field.addValue((allowInvites == null) ? "0": "1");
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_passwordprotectedroom");
field.addValue((password == null) ? "0": "1");
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_roomsecret");
field.addValue(password);
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_whois");
field.addValue(whois);
dataForm.addField(field);
field = new XFormFieldImpl("muc#roomconfig_enablelogging");
field.addValue((enableLog == null) ? "0": "1");
dataForm.addField(field);
// Keep the existing list of admins
field = new XFormFieldImpl("muc#roomconfig_roomadmins");
for (String jid : room.getAdmins()) {
field.addValue(jid);
}
dataForm.addField(field);
// Keep the existing list of owners
field = new XFormFieldImpl("muc#roomconfig_roomowners");
for (String jid : room.getOwners()) {
field.addValue(jid);
}
dataForm.addField(field);
// Create an IQ packet and set the dataform as the main fragment
IQ iq = new IQ(IQ.Type.set);
Element element = iq.setChildElement("query", "http://jabber.org/protocol/muc#owner");
element.add(dataForm.asXMLElement());
// Send the IQ packet that will modify the room's configuration
room.getIQOwnerHandler().handleIQ(iq, room.getRole());
// Change the subject of the room by sending a new message
Message message = new Message();
message.setType(Message.Type.groupchat);
message.setSubject(roomSubject);
message.setFrom(room.getRole().getRoleAddress());
room.changeSubject(message, room.getRole());
// Changes good, so redirect
response.sendRedirect("muc-room-edit-form.jsp?success=true&roomName=" + roomName);
return;
}
}
else {
naturalName = room.getNaturalLanguageName();
description = room.getDescription();
roomSubject = room.getSubject();
maxUsers = Integer.toString(room.getMaxUsers());
broadcastModerator = Boolean.toString(room.canBroadcastPresence("moderator"));
broadcastParticipant = Boolean.toString(room.canBroadcastPresence("participant"));
broadcastVisitor = Boolean.toString(room.canBroadcastPresence("visitor"));
password = room.getPassword();
confirmPassword = room.getPassword();
whois = (room.canAnyoneDiscoverJID() ? "anyone" : "moderator");
publicRoom = Boolean.toString(room.isPublicRoom());
// Only set the room persistence property if a value was not provided already. If the room has
// just been created, this property will already have a value of "true"
if (persistentRoom == null) {
persistentRoom = Boolean.toString(room.isPersistent());
}
moderatedRoom = Boolean.toString(room.isModerated());
membersOnly = Boolean.toString(room.isMembersOnly());
allowInvites = Boolean.toString(room.canOccupantsInvite());
changeSubject = Boolean.toString(room.canOccupantsChangeSubject());
enableLog = Boolean.toString(room.isLogEnabled());
}
// Formatter for dates
DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
%>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "Room Administration";
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "muc-room-edit-form.jsp?roomName="+roomName));
pageinfo.setSubPageID("muc-room-edit-form");
pageinfo.setExtraParams("roomName="+roomName);
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<% if (success || addsuccess) { %>
<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">
<% if (success) { %>
Room settings edited successfully.
<% } else if (addsuccess) { %>
Room creation was successfully.
<% } %>
</td></tr>
</tbody>
</table>
</div><br
<% } %>
<p>
Use the form below to edit the room settings.
</p>
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th scope="col">Room ID</th>
<th scope="col">Users</th>
<th scope="col">Created On</th>
<th scope="col">Last Modified</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= room.getName() %></td>
<td><%= room.getOccupantsCount() %> / <%= room.getMaxUsers() %></td>
<td><%= dateFormatter.format(room.getCreationDate()) %></td>
<td><%= dateFormatter.format(room.getModificationDate()) %></td>
</tr>
</tbody>
</table>
</div>
<br>
<p>Change the room settings of this room using the form below</p>
<form action="muc-room-edit-form.jsp">
<input type="hidden" name="roomName" value="<%= roomName %>">
<input type="hidden" name="save" value="true">
<table width="100%" border="0"> <tr>
<td width="70%"><table width="100%" border="0">
<tbody>
<tr>
<td>Room Name:</td>
<td><input type="text" name="roomconfig_roomname" value="<%= (naturalName == null ? "" : naturalName) %>">
<% if (errors.get("roomconfig_roomname") != null) { %>
<span class="jive-error-text">
Please enter a valid name.
</span>
<% } %>
</td>
</tr>
<tr>
<td>Description:</td>
<td><input name="roomconfig_roomdesc" value="<%= (description == null ? "" : description) %>" type="text" size="40">
<% if (errors.get("roomconfig_roomdesc") != null) { %>
<span class="jive-error-text">
Please enter a valid description.
</span>
<% } %>
</td>
</tr>
<tr>
<td>Topic:</td>
<td><input name="room_topic" value="<%= (roomSubject == null ? "" : roomSubject) %>" type="text" size="40">
<% if (errors.get("room_topic") != null) { %>
<span class="jive-error-text">
Please enter a valid subject.
</span>
<% } %>
</td>
</tr>
<tr>
<td>Maximun Room Occupants:</td>
<td><select name="roomconfig_maxusers">
<option value="10" <% if ("10".equals(maxUsers)) out.write("selected");%>>10</option>
<option value="20" <% if ("20".equals(maxUsers)) out.write("selected");%>>20</option>
<option value="30" <% if ("30".equals(maxUsers)) out.write("selected");%>>30</option>
<option value="40" <% if ("40".equals(maxUsers)) out.write("selected");%>>40</option>
<option value="50" <% if ("50".equals(maxUsers)) out.write("selected");%>>50</option>
<option value="0" <% if ("0".equals(maxUsers)) out.write("selected");%>>None</option>
</select>
<% if (errors.get("roomconfig_maxusers") != null) { %>
<span class="jive-error-text">
Please select the maximun room occupants.
</span>
<% } %>
</td>
</tr>
<tr>
<td valign="top">Roles for Which Presence is Broadcast:</td>
<td><fieldset>
<input name="roomconfig_presencebroadcast" type="checkbox" value="true" id="moderator" <% if ("true".equals(broadcastModerator)) out.write("checked");%>>
<LABEL FOR="moderator">Moderator</LABEL>
<input name="roomconfig_presencebroadcast2" type="checkbox" value="true" id="participant" <% if ("true".equals(broadcastParticipant)) out.write("checked");%>>
<LABEL FOR="participant">Participant</LABEL>
<input name="roomconfig_presencebroadcast3" type="checkbox" value="true" id="visitor" <% if ("true".equals(broadcastVisitor)) out.write("checked");%>>
<LABEL FOR="visitor">Visitor</LABEL>
</fieldset></td>
</tr>
<tr>
<td>Password required to enter:</td>
<td><input type="password" name="roomconfig_roomsecret" <% if(password != null) { %> value="<%= password %>" <% } %>></td>
</tr>
<tr>
<td>Confirm password:</td>
<td><input type="password" name="roomconfig_roomsecret2" <% if(confirmPassword != null) { %> value="<%= confirmPassword %>" <% } %>>
<% if (errors.get("roomconfig_roomsecret2") != null) { %>
<span class="jive-error-text">
Please make sure to enter the same new password.
</span>
<% } %>
</td>
</tr>
<tr>
<td>Role that May Discover Real JIDs of Occupants:</td>
<td><select name="roomconfig_whois">
<option value="moderator" <% if ("moderator".equals(whois)) out.write("selected");%>>Moderator</option>
<option value="anyone" <% if ("anyone".equals(whois)) out.write("selected");%>>Anyone</option>
</select>
<% if (errors.get("roomconfig_whois") != null) { %>
<span class="jive-error-text">
Please select a role.
</span>
<% } %>
</td>
</tr>
</tbody>
</table></td>
<td width="30%" valign="top" >
<fieldset>
<legend>Room Options</legend>
<table width="100%" border="0">
<tbody>
<tr>
<td><input type="checkbox" name="roomconfig_publicroom" value="true" id="public" <% if ("true".equals(publicRoom)) out.write("checked");%>>
<LABEL FOR="public">List Room in Directory</LABEL></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_persistentroom" value="true" id="persistent" <% if ("true".equals(persistentRoom)) out.write("checked");%>>
<LABEL FOR="persistent">Make Room Persistant</LABEL></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_moderatedroom" value="true" id="moderated" <% if ("true".equals(moderatedRoom)) out.write("checked");%>>
<LABEL FOR="moderated">Make Room Moderated</LABEL></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_membersonly" value="true" id="membersOnly" <% if ("true".equals(membersOnly)) out.write("checked");%>>
<LABEL FOR="membersOnly">Invitation Required to Enter</LABEL></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_allowinvites" value="true" id="allowinvites" <% if ("true".equals(allowInvites)) out.write("checked");%>>
<LABEL FOR="allowinvites">Allow Occupants to invite Others</LABEL></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_changesubject" value="true" id="changesubject" <% if ("true".equals(changeSubject)) out.write("checked");%>>
<LABEL FOR="changesubject">Allow Occupants to change Subject</LABEL></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_enablelogging" value="true" id="enablelogging" <% if ("true".equals(enableLog)) out.write("checked");%>>
<LABEL FOR="enablelogging">Log Room Conversations</td>
</tr>
</table>
</fieldset>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name="Submit" value="Save changes">
<input type="submit" name="cancel" value="Cancel"></td>
</tr>
</tbody>
</table>
</form>
<jsp:include page="bottom.jsp" flush="true" />
\ No newline at end of file
<%--
- $RCSfile$
- $Revision$
- $Date$
-
- Copyright (C) 2004 Jive Software. All rights reserved.
-
- This software is the proprietary information of Jive Software.
- Use is subject to license terms.
--%>
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.messenger.muc.spi.*,
java.text.DateFormat,
org.jivesoftware.admin.*,
org.jivesoftware.messenger.muc.MUCRoom,
java.util.*"
errorPage="error.jsp"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
<jsp:useBean id="pageinfo" scope="request" class="org.jivesoftware.admin.AdminPageBean" />
<% // Title of this page and breadcrumbs
String title = "Group Chat Rooms";
pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "muc-room-summary.jsp"));
pageinfo.setPageID("muc-room-summary");
%>
<jsp:include page="top.jsp" flush="true" />
<jsp:include page="title.jsp" flush="true" />
<% // Get parameters
int start = ParamUtils.getIntParameter(request,"start",0);
int range = ParamUtils.getIntParameter(request,"range",15);
// Get the rooms in the server
List<MUCRoom> rooms = webManager.getMultiUserChatServer().getChatRooms();
Collections.sort(rooms, new Comparator() {
public int compare(Object o1, Object o2) {
MUCRoom room1 = (MUCRoom)o1;
MUCRoom room2 = (MUCRoom)o2;
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>
Below is an overview of the Group Chat Rooms in the system. From here you can view the rooms, edit their
properties, and create new rooms.
</p>
<% 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">
Room destroyed successfully.
</td></tr>
</tbody>
</table>
</div><br>
<% } %>
<p>
Total Rooms: <%= roomsCount %>,
<% if (numPages > 1) { %>
Showing <%= (start+1) %>-<%= (maxRoomIndex) %>,
<% } %>
Sorted by Room ID
</p>
<% if (numPages > 1) { %>
<p>
Pages:
[
<% for (int i=0; i<numPages; i++) {
String sep = ((i+1)<numPages) ? " " : "";
boolean isCurrent = (i+1) == curPage;
%>
<a href="muc-room-summary.jsp?start=<%= (i*range) %>"
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>
<th>Room ID</th>
<th>Description</th>
<th>Lock</th>
<th>Users</th>
<th>Edit</th>
<th>Destroy</th>
</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">
No rooms in the Group Chat service.
</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>
<td width="45%" align="center" valign="middle">
<%= room.getName() %>
</td>
<td width="45%" align="center" valign="middle">
<%= room.getDescription() %>
</td>
<td width="1%" align="center">
<% if (room.isLocked()) { %>
<img src="images/lock-16x16.gif" width="16" height="16" border="0" alt="Room is locked">
<% } else { %>
<img src="images/lock-open-16x16.gif" width="16" height="16" border="0" alt="Room is unlocked">
<% } %>
</td>
<td width="1%" align="center">
<%= room.getOccupantsCount() %> / <%= room.getMaxUsers() %>
</td>
<td width="1%" align="center">
<a href="muc-room-edit-form.jsp?roomName=<%= room.getName() %>"
title="Click to edit..."
><img src="images/edit-16x16.gif" width="17" height="17" border="0"></a>
</td>
<td width="1%" align="center" style="border-right:1px #ccc solid;">
<a href="muc-room-delete.jsp?roomName=<%= room.getName() %>"
title="Click to delete..."
><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
</td>
</tr>
<%
}
%>
</tbody>
</table>
</div>
<% if (numPages > 1) { %>
<p>
Pages:
[
<% for (i=0; i<numPages; i++) {
String sep = ((i+1)<numPages) ? " " : "";
boolean isCurrent = (i+1) == curPage;
%>
<a href="muc-room-summary.jsp?start=<%= (i*range) %>"
class="<%= ((isCurrent) ? "jive-current" : "") %>"
><%= (i+1) %></a><%= sep %>
<% } %>
]
</p>
<% } %>
<jsp:include page="bottom.jsp" flush="true" />
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment