%--
- $Revision$
- $Date$
-
- Copyright (C) 2004-2005 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.openfire.muc.*,
org.xmpp.packet.IQ,
org.dom4j.Element,
java.net.URLEncoder"
errorPage="error.jsp"
%>
<%@ 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
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 = 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;
}
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="+URLEncoder.encode(roomName, "UTF-8"));
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="+URLEncoder.encode(roomName, "UTF-8"));
return;
}
catch (ConflictException e) {
errors.put("ConflictException","ConflictException");
}
}
%>
"/>
"><%= room.getName() %>.
<% if (errors.size() > 0) { %>
 |
<% if (errors.containsKey("ConflictException")) { %>
<% } else if (errors.containsKey("NotAllowedException")) { %>
<% } else { %>
<% } %>
|
<% } else if (addsuccess || deletesuccess) { %>
 |
<% if (addsuccess) { %>
<% } else if (deletesuccess) { %>
<% } %>
|
<% } %>