<%-- - $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.dom4j.Element, org.jivesoftware.openfire.muc.ConflictException, org.jivesoftware.openfire.muc.MUCRoom, org.jivesoftware.openfire.muc.NotAllowedException, org.jivesoftware.util.ParamUtils, org.xmpp.packet.IQ" errorPage="error.jsp" %> <%@ page import="org.xmpp.packet.JID" %> <%@ page import="java.net.URLEncoder" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.Collections" %> <%@ page import="java.util.HashMap" %> <%@ page import="java.util.Map" %> <%@ page import="org.jivesoftware.openfire.muc.CannotBeInvitedException" %> <%@ 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 JID roomJID = new JID(ParamUtils.getParameter(request,"roomJID")); String affiliation = ParamUtils.getParameter(request,"affiliation"); String userJID = ParamUtils.getParameter(request,"userJID"); String roomName = roomJID.getNode(); 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.getMultiUserChatManager().getMultiUserChatService(roomJID).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?roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8")); return; } Map errors = new HashMap(); // Handle an add if (add) { // do validation if (userJID == null) { errors.put("userJID","userJID"); } if (errors.size() == 0) { try { // Escape username if (userJID.indexOf('@') == -1) { String username = JID.escapeNode(userJID); String domain = webManager.getXMPPServer().getServerInfo().getXMPPDomain(); userJID = username + '@' + domain; } else { String username = JID.escapeNode(userJID.substring(0, userJID.indexOf('@'))); String rest = userJID.substring(userJID.indexOf('@'), userJID.length()); userJID = username + rest.trim(); } 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()); } // Log the event webManager.logEvent("set MUC affilation to "+affiliation+" for "+userJID+" in "+roomName, null); // done, return response.sendRedirect("muc-room-affiliations.jsp?addsuccess=true&roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8")); return; } catch (ConflictException e) { errors.put("ConflictException","ConflictException"); } catch (NotAllowedException e) { errors.put("NotAllowedException","NotAllowedException"); } catch (CannotBeInvitedException e) { errors.put("CannotBeInvitedException", "CannotBeInvitedExcpetion"); } } } 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&roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8")); return; } catch (ConflictException e) { errors.put("ConflictException","ConflictException"); } catch (CannotBeInvitedException e) { errors.put("CannotBeInvitedException", "CannotBeInvitedExcpetion"); } } %> <fmt:message key="muc.room.affiliations.title"/> "/>

"><%= room.getJID().toBareJID() %>.

<% if (errors.size() > 0) { %>
<% if (errors.containsKey("ConflictException")) { %> <% } else if (errors.containsKey("NotAllowedException")) { %> <% } else { %> <% } %>

<% } else if (addsuccess || deletesuccess) { %>
<% if (addsuccess) { %> <% } else if (deletesuccess) { %> <% } %>

<% } %>

" id="memberJID"> ">

<%-- Add owners section --%> <% if (room.getOwners().isEmpty()) { %> <% } else { ArrayList owners = new ArrayList(room.getOwners()); Collections.sort(owners); for (JID user : owners) { String username = JID.unescapeNode(user.getNode()); String userDisplay = username + '@' + user.getDomain(); %> <% } } %> <%-- Add admins section --%> <% if (room.getAdmins().isEmpty()) { %> <% } else { ArrayList admins = new ArrayList(room.getAdmins()); Collections.sort(admins); for (JID user : admins) { String username = JID.unescapeNode(user.getNode()); String userDisplay = username + '@' + user.getDomain(); %> <% } } %> <%-- Add members section --%> <% if (room.getMembers().isEmpty()) { %> <% } else { ArrayList members = new ArrayList(room.getMembers()); Collections.sort(members); for (JID user : members) { String username = JID.unescapeNode(user.getNode()); String userDisplay = username + '@' + user.getDomain(); String nickname = room.getReservedNickname(user); nickname = (nickname == null ? "" : " (" + nickname + ")"); %> <% } } %> <%-- Add outcasts section --%> <% if (room.getOutcasts().isEmpty()) { %> <% } else { ArrayList outcasts = new ArrayList(room.getOutcasts()); Collections.sort(outcasts); for (JID user : outcasts) { String username = JID.unescapeNode(user.getNode()); String userDisplay = username + '@' + user.getDomain(); %> <% } } %>
 
 
  <%= userDisplay %> &userJID=<%= user %>&delete=true&affiliation=owner" title="" onclick="return confirm('');" >
 
 
  <%= userDisplay %> &userJID=<%= user %>&delete=true&affiliation=admin" title="" onclick="return confirm('');" >
 
 
  <%= userDisplay %><%= nickname %> &userJID=<%= user %>&delete=true&affiliation=member" title="" onclick="return confirm('');" >
 
 
  <%= userDisplay %> &userJID=<%= user %>&delete=true&affiliation=outcast" title="" onclick="return confirm('');" >