muc-room-occupants.jsp 7.05 KB
Newer Older
1
<%--
2 3
  -	$Revision: 10204 $
  -	$Date: 2008-04-11 18:44:25 -0400 (Fri, 11 Apr 2008) $
4
  -
5
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
6
  -
7 8 9 10 11 12 13 14 15 16 17
  - 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.
18 19
--%>

20
<%@ page import="org.jivesoftware.openfire.muc.MUCRole,
21
                 org.jivesoftware.openfire.muc.MUCRoom,
22
                 org.jivesoftware.util.ParamUtils,
Sven Tantau's avatar
Sven Tantau committed
23
                 org.jivesoftware.util.StringUtils,
24
                 java.net.URLEncoder,
Sven Tantau's avatar
Sven Tantau committed
25
                 java.text.DateFormat"
26 27
    errorPage="error.jsp"
%>
28 29
<%@ page import="org.jivesoftware.openfire.XMPPServer" %>
<%@ page import="org.jivesoftware.openfire.muc.NotAllowedException" %>
30
<%@ page import="org.xmpp.packet.JID" %>
31 32 33 34 35 36 37

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out); %>

<%  // Get parameters
38
    JID roomJID = new JID(ParamUtils.getParameter(request,"roomJID"));
39 40
    String nickName = ParamUtils.getParameter(request,"nickName");
    String kick = ParamUtils.getParameter(request,"kick");
41
    String roomName = roomJID.getNode();
42 43

    // Load the room object
44
    MUCRoom room = webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomName);
45 46
    if (room == null) {
        // The requested room name does not exist so return to the list of the existing rooms
47
        response.sendRedirect("muc-room-summary.jsp?roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8"));
48 49 50
        return;
    }

51 52
    // Kick nick specified
    if (kick != null) {
Sven Tantau's avatar
Sven Tantau committed
53 54
        MUCRole role = room.getOccupant(nickName);
        if (role != null) {
55
            try {
Sven Tantau's avatar
Sven Tantau committed
56
                room.kickOccupant(role.getUserAddress(), XMPPServer.getInstance().createJID(webManager.getUser().getUsername(), null), "");
57 58
                // Log the event
                webManager.logEvent("kicked MUC occupant "+nickName+" from "+roomName, null);
59
                // Done, so redirect
Sven Tantau's avatar
Sven Tantau committed
60
                response.sendRedirect("muc-room-occupants.jsp?roomJID="+URLEncoder.encode(room.getJID().toBareJID(), "UTF-8")+"&nickName="+URLEncoder.encode(role.getNickname(), "UTF-8")+"&deletesuccess=true");
61 62 63 64
                return;
            }
            catch (NotAllowedException e) {
                // Done, so redirect
Sven Tantau's avatar
Sven Tantau committed
65
                response.sendRedirect("muc-room-occupants.jsp?roomJID="+URLEncoder.encode(room.getJID().toBareJID(), "UTF-8")+"&nickName="+URLEncoder.encode(role.getNickname(), "UTF-8")+"&deletefailed=true");
66 67 68 69 70
                return;
            }
        }
    }

71 72 73 74 75 76 77
    // Formatter for dates
    DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
%>

<html>
<head>
<title><fmt:message key="muc.room.occupants.title"/></title>
78
<meta name="subPageID" content="muc-room-occupants"/>
79
<meta name="extraParams" content="<%= "roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8")+"&create=false" %>"/>
80 81 82 83 84 85
</head>
<body>

    <p>
    <fmt:message key="muc.room.occupants.info" />
    </p>
86 87 88 89 90 91 92 93 94

    <%  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" alt=""></td>
            <td class="jive-icon-label">
            <fmt:message key="muc.room.occupants.kicked">
Sven Tantau's avatar
Sven Tantau committed
95
                <fmt:param value="<%= StringUtils.escapeForXML(nickName) %>"/>
96 97 98 99 100 101 102 103 104 105
            </fmt:message>
            </td></tr>
        </tbody>
        </table>
        </div><br>

    <%  } %>

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

Daniel Henninger's avatar
Daniel Henninger committed
106
        <div class="jive-error">
107 108 109 110 111
        <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" alt=""></td>
            <td class="jive-icon-label">
            <fmt:message key="muc.room.occupants.kickfailed">
Sven Tantau's avatar
Sven Tantau committed
112
                <fmt:param value="<%= StringUtils.escapeForXML(nickName) %>"/>
113 114 115 116 117 118 119 120
            </fmt:message>
            </td></tr>
        </tbody>
        </table>
        </div><br>

    <%  } %>

121 122 123 124 125 126 127 128 129 130 131 132
    <div class="jive-table">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <thead>
        <tr>
            <th scope="col"><fmt:message key="muc.room.edit.form.room_id" /></th>
            <th scope="col"><fmt:message key="muc.room.edit.form.users" /></th>
            <th scope="col"><fmt:message key="muc.room.edit.form.on" /></th>
            <th scope="col"><fmt:message key="muc.room.edit.form.modified" /></th>
        </tr>
    </thead>
    <tbody>
        <tr>
Sven Tantau's avatar
Sven Tantau committed
133
            <td><%= StringUtils.escapeHTMLTags(room.getName()) %></td>
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
            <td><%= room.getOccupantsCount() %> / <%= room.getMaxUsers() %></td>
            <td><%= dateFormatter.format(room.getCreationDate()) %></td>
            <td><%= dateFormatter.format(room.getModificationDate()) %></td>
        </tr>
    </tbody>
    </table>
    </div>

    <br>
    <p>
        <fmt:message key="muc.room.occupants.detail.info" />
    </p>

    <div class="jive-table">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <thead>
        <tr>
            <th scope="col"><fmt:message key="muc.room.occupants.user" /></th>
            <th scope="col"><fmt:message key="muc.room.occupants.nickname" /></th>
            <th scope="col"><fmt:message key="muc.room.occupants.role" /></th>
            <th scope="col"><fmt:message key="muc.room.occupants.affiliation" /></th>
155
            <th scope="col"><fmt:message key="muc.room.occupants.kick" /></th>
156 157 158 159 160
        </tr>
    </thead>
    <tbody>
        <% for (MUCRole role : room.getOccupants()) { %>
        <tr>
Sven Tantau's avatar
Sven Tantau committed
161 162 163 164
            <td><%= StringUtils.escapeHTMLTags(role.getUserAddress().toString()) %></td>
            <td><%= StringUtils.escapeHTMLTags(role.getNickname().toString()) %></td>
            <td><%= StringUtils.escapeHTMLTags(role.getRole().toString()) %></td>
            <td><%= StringUtils.escapeHTMLTags(role.getAffiliation().toString()) %></td>
165
            <td><a href="muc-room-occupants.jsp?roomJID=<%= URLEncoder.encode(room.getJID().toBareJID(), "UTF-8") %>&nickName=<%= URLEncoder.encode(role.getNickname(), "UTF-8") %>&kick=1" title="<fmt:message key="muc.room.occupants.kick"/>"><img src="images/delete-16x16.gif" alt="<fmt:message key="muc.room.occupants.kick"/>" border="0" width="16" height="16"/></a></td>
166 167 168 169 170 171 172
        </tr>
        <% } %>
    </tbody>
    </table>
    </div>

    </body>
173
</html>