muc-room-delete.jsp 4.62 KB
Newer Older
Gaston Dombiak's avatar
Gaston Dombiak committed
1 2 3 4
<%--
  -	$Revision$
  -	$Date$
  -
5
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
Gaston Dombiak's avatar
Gaston Dombiak committed
6
  -
7 8 9 10 11 12 13 14 15 16 17 18
  - 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.

Gaston Dombiak's avatar
Gaston Dombiak committed
19 20 21
--%>

<%@ page import="org.jivesoftware.util.*,
22
                 org.jivesoftware.openfire.muc.MUCRoom,
Gaston Dombiak's avatar
Gaston Dombiak committed
23
                 java.net.URLEncoder"
Gaston Dombiak's avatar
Gaston Dombiak committed
24 25
    errorPage="error.jsp"
%>
26
<%@ page import="org.xmpp.packet.JID" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
27 28

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
29
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
30 31 32 33 34 35
<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;
guus's avatar
guus committed
36

37
    JID roomJID = new JID(ParamUtils.getParameter(request,"roomJID"));
38
    String alternateJIDString = ParamUtils.getParameter(request,"alternateJID");
guus's avatar
guus committed
39
    JID alternateJID = null;
40
    if (alternateJIDString != null && alternateJIDString.trim().length() > 0 ) {
guus's avatar
guus committed
41 42 43 44
    	// OF-526: Ignore invalid alternative JIDs.
    	try {
    		alternateJID = new JID(alternateJIDString.trim());
    		if (alternateJID.getNode() == null) {
guus's avatar
guus committed
45
    			alternateJID = null;
guus's avatar
guus committed
46
    		}
guus's avatar
guus committed
47
    	} catch (IllegalArgumentException ex) {
guus's avatar
guus committed
48 49
    		alternateJID = null;
    	}
50 51 52
    } else {
    	alternateJID = null;
    }
Gaston Dombiak's avatar
Gaston Dombiak committed
53
    String reason = ParamUtils.getParameter(request,"reason");
54
    String roomName = roomJID.getNode();
Gaston Dombiak's avatar
Gaston Dombiak committed
55 56 57

    // Handle a cancel
    if (cancel) {
58
        response.sendRedirect("muc-room-summary.jsp?roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8"));
Gaston Dombiak's avatar
Gaston Dombiak committed
59 60 61 62
        return;
    }

    // Load the room object
63
    MUCRoom room = webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomName);
Gaston Dombiak's avatar
Gaston Dombiak committed
64 65 66 67

    // Handle a room delete:
    if (delete) {
        // Delete the room
guus's avatar
guus committed
68
        if (room != null) {
Gaston Dombiak's avatar
Gaston Dombiak committed
69 70
            // If the room still exists then destroy it
            room.destroyRoom(alternateJID, reason);
71
            // Log the event
72
            webManager.logEvent("destroyed MUC room "+roomName, "reason = "+reason+"\nalt jid = "+alternateJID);
Gaston Dombiak's avatar
Gaston Dombiak committed
73 74
        }
        // Done, so redirect
75
        response.sendRedirect("muc-room-summary.jsp?roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8")+"&deletesuccess=true");
Gaston Dombiak's avatar
Gaston Dombiak committed
76 77 78 79
        return;
    }
%>

80 81 82 83
<html>
    <head>
        <title><fmt:message key="muc.room.delete.title"/></title>
        <meta name="subPageID" content="muc-room-delete"/>
84
        <meta name="extraParams" content="<%= "roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8") %>"/>
85 86 87
        <meta name="helpPage" content="delete_a_group_chat_room.html"/>
    </head>
    <body>
Gaston Dombiak's avatar
Gaston Dombiak committed
88 89

<p>
90
<fmt:message key="muc.room.delete.info" />
91
<b><a href="muc-room-edit-form.jsp?roomJID=<%= URLEncoder.encode(room.getJID().toBareJID(), "UTF-8") %>"><%= room.getJID().toBareJID() %></a></b>
92
<fmt:message key="muc.room.delete.detail" />
Gaston Dombiak's avatar
Gaston Dombiak committed
93 94 95
</p>

<form action="muc-room-delete.jsp">
96
<input type="hidden" name="roomJID" value="<%= roomJID.toBareJID() %>">
Gaston Dombiak's avatar
Gaston Dombiak committed
97 98

<fieldset>
99
    <legend><fmt:message key="muc.room.delete.destructon_title" /></legend>
Gaston Dombiak's avatar
Gaston Dombiak committed
100 101 102 103 104
    <div>
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
    <tbody>
        <tr>
            <td class="c1">
105
                <fmt:message key="muc.room.delete.room_id" />
Gaston Dombiak's avatar
Gaston Dombiak committed
106 107
            </td>
            <td>
108
                <%= room.getJID().toBareJID() %>
Gaston Dombiak's avatar
Gaston Dombiak committed
109 110 111 112
            </td>
        </tr>
        <tr>
            <td class="c1">
113
                <fmt:message key="muc.room.delete.reason" />
Gaston Dombiak's avatar
Gaston Dombiak committed
114 115 116 117 118 119 120
            </td>
            <td>
                <input type="text" size="50" maxlength="150" name="reason">
            </td>
        </tr>
        <tr>
            <td class="c1">
121
                <fmt:message key="muc.room.delete.alternate_address" />
Gaston Dombiak's avatar
Gaston Dombiak committed
122 123 124 125 126 127 128 129 130 131 132 133
            </td>
            <td>
                <input type="text" size="30" maxlength="150" name="alternateJID">
            </td>
        </tr>
    </tbody>
    </table>
    </div>
</fieldset>

<br><br>

134 135
<input type="submit" name="delete" value="<fmt:message key="muc.room.delete.destroy_room" />">
<input type="submit" name="cancel" value="<fmt:message key="global.cancel" />">
Gaston Dombiak's avatar
Gaston Dombiak committed
136 137
</form>

138 139
    </body>
</html>