muc-room-edit-form.jsp 29.3 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
  - 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
18 19 20
--%>

<%@ page import="org.jivesoftware.util.ParamUtils,
Sven Tantau's avatar
Sven Tantau committed
21
                 org.jivesoftware.util.StringUtils,
Gaston Dombiak's avatar
Gaston Dombiak committed
22 23
                 java.text.DateFormat,
                 java.util.*,
24 25 26
                 org.jivesoftware.openfire.muc.MUCRoom,
                 org.jivesoftware.openfire.forms.spi.*,
                 org.jivesoftware.openfire.forms.*,
Gaston Dombiak's avatar
Gaston Dombiak committed
27 28
                 org.dom4j.Element,
                 org.xmpp.packet.IQ,
29 30
                 org.xmpp.packet.Message,
                 org.xmpp.packet.JID,
31 32
                 gnu.inet.encoding.Stringprep,
                 gnu.inet.encoding.StringprepException,
Gaston Dombiak's avatar
Gaston Dombiak committed
33
                 java.net.URLEncoder"
Gaston Dombiak's avatar
Gaston Dombiak committed
34 35
    errorPage="error.jsp"
%>
36
<%@ page import="org.jivesoftware.openfire.muc.NotAllowedException"%>
37
<%@ page import="org.jivesoftware.openfire.muc.MultiUserChatService" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
38

39 40
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
Gaston Dombiak's avatar
Gaston Dombiak committed
41
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
42
<% webManager.init(request, response, session, application, out); %>
Gaston Dombiak's avatar
Gaston Dombiak committed
43 44

<%  // Get parameters
45
    boolean create = ParamUtils.getBooleanParameter(request,"create");
Gaston Dombiak's avatar
Gaston Dombiak committed
46 47 48
    boolean save = ParamUtils.getBooleanParameter(request,"save");
    boolean success = ParamUtils.getBooleanParameter(request,"success");
    boolean addsuccess = ParamUtils.getBooleanParameter(request,"addsuccess");
49 50 51 52 53 54 55 56 57 58 59 60
    String roomName = ParamUtils.getParameter(request,"roomName");
    String mucName = ParamUtils.getParameter(request,"mucName");
    String roomJIDStr = ParamUtils.getParameter(request,"roomJID");
    JID roomJID = null;
    if (roomName != null && mucName != null) {
        roomJID = new JID(roomName, mucName, null);
    }
    else if (roomJIDStr != null) {
        roomJID = new JID(roomJIDStr);
        roomName = roomJID.getNode();
        mucName = roomJID.getDomain();
    }
Gaston Dombiak's avatar
Gaston Dombiak committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
    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");
77 78 79
    String reservedNick = ParamUtils.getParameter(request, "roomconfig_reservednick");
    String canChangeNick = ParamUtils.getParameter(request, "roomconfig_canchangenick");
    String registrationEnabled = ParamUtils.getParameter(request, "roomconfig_registration");
80
    String roomSubject = ParamUtils.getParameter(request, "room_topic", true);
Gaston Dombiak's avatar
Gaston Dombiak committed
81

82 83 84 85 86 87
    if (webManager.getMultiUserChatManager().getMultiUserChatServicesCount() < 1) {
        // No services exist, so redirect to where one can configure the services
        response.sendRedirect("muc-service-summary.jsp");
        return;
    }

Gaston Dombiak's avatar
Gaston Dombiak committed
88 89
    // Handle a cancel
    if (request.getParameter("cancel") != null) {
90
        response.sendRedirect("muc-room-summary.jsp?roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8"));
Gaston Dombiak's avatar
Gaston Dombiak committed
91 92 93 94
        return;
    }

    // Load the room object
95 96
    MUCRoom room = null;
    if (!create) {
97
        room = webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomName);
Gaston Dombiak's avatar
Gaston Dombiak committed
98

99 100
        if (room == null) {
            // The requested room name does not exist so return to the list of the existing rooms
101
            response.sendRedirect("muc-room-summary.jsp?roomJID="+URLEncoder.encode(roomJID.toBareJID(), "UTF-8"));
102 103
            return;
        }
Gaston Dombiak's avatar
Gaston Dombiak committed
104 105
    }

106
    // Handle an save
107
    Map<String, String> errors = new HashMap<String, String>();
Gaston Dombiak's avatar
Gaston Dombiak committed
108 109
    if (save) {
        // do validation
110

Gaston Dombiak's avatar
Gaston Dombiak committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
        if (naturalName == null) {
            errors.put("roomconfig_roomname","roomconfig_roomname");
        }
        if (description == null) {
            errors.put("roomconfig_roomdesc","roomconfig_roomdesc");
        }
        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");
        }
126 127 128 129 130
        if (create && errors.size() == 0) {
            if (roomName == null || roomName.contains("@")) {
                errors.put("roomName","roomName");
            }
            else {
131 132 133 134 135 136 137 138 139 140
                // Check that the room name is a valid node
                try {
                    roomName = Stringprep.nodeprep(roomName);
                }
                catch (StringprepException e) {
                    errors.put("roomName","roomName");
                }
            }

            if (errors.size() == 0) {
141
                // Check that the requested room ID is available
142
                room = webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomName);
143 144 145 146 147
                if (room != null) {
                    errors.put("room_already_exists", "room_already_exists");
                }
                else {
                    // Try to create a new room
148
                    JID address = new JID(webManager.getUser().getUsername(), webManager.getServerInfo().getXMPPDomain(), null);
149
                    try {
150
                        room = webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomName, address);
151
                        // Check if the room was created concurrently by another user
152
                        if (!room.getOwners().contains(address.asBareJID())) {
153 154 155
                            errors.put("room_already_exists", "room_already_exists");
                        }
                    }
156
                    catch (NotAllowedException e) {
157 158 159 160 161 162 163
                        // This user is not allowed to create rooms
                        errors.put("not_enough_permissions", "not_enough_permissions");
                    }
                }
            }
        }

Gaston Dombiak's avatar
Gaston Dombiak committed
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
        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);

238 239 240 241 242 243 244 245 246 247 248 249
            field = new XFormFieldImpl("x-muc#roomconfig_reservednick");
            field.addValue((reservedNick == null) ? "0": "1");
            dataForm.addField(field);

            field = new XFormFieldImpl("x-muc#roomconfig_canchangenick");
            field.addValue((canChangeNick == null) ? "0": "1");
            dataForm.addField(field);

            field = new XFormFieldImpl("x-muc#roomconfig_registration");
            field.addValue((registrationEnabled == null) ? "0": "1");
            dataForm.addField(field);

Gaston Dombiak's avatar
Gaston Dombiak committed
250 251
            // Keep the existing list of admins
            field = new XFormFieldImpl("muc#roomconfig_roomadmins");
252 253
            for (JID jid : room.getAdmins()) {
                field.addValue(jid.toString());
Gaston Dombiak's avatar
Gaston Dombiak committed
254 255 256 257 258
            }
            dataForm.addField(field);

            // Keep the existing list of owners
            field = new XFormFieldImpl("muc#roomconfig_roomowners");
259 260
            for (JID jid : room.getOwners()) {
                field.addValue(jid.toString());
Gaston Dombiak's avatar
Gaston Dombiak committed
261 262 263
            }
            dataForm.addField(field);

264
            // update subject before sending IQ (to include subject with cluster update)
265 266 267 268 269 270 271
            if (roomSubject != null) {
                // 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());
                message.setTo(room.getRole().getRoleAddress());
272
                message.setID("local-only");
273 274
                room.changeSubject(message, room.getRole());
            }
Gaston Dombiak's avatar
Gaston Dombiak committed
275

276 277 278 279 280 281 282
            // 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());

Gaston Dombiak's avatar
Gaston Dombiak committed
283
            // Changes good, so redirect
284
            String params;
285
            if (create) {
286
                params = "addsuccess=true&roomJID=" + URLEncoder.encode(roomJID.toBareJID(), "UTF-8");
287 288
                // Log the event
                webManager.logEvent("created new MUC room "+roomName, "subject = "+roomSubject+"\nroomdesc = "+description+"\nroomname = "+naturalName+"\nmaxusers = "+maxUsers);
289 290
            }
            else {
291
                params = "success=true&roomJID=" + URLEncoder.encode(roomJID.toBareJID(), "UTF-8");
292 293
                // Log the event
                webManager.logEvent("updated MUC room "+roomName, "subject = "+roomSubject+"\nroomdesc = "+description+"\nroomname = "+naturalName+"\nmaxusers = "+maxUsers);
294 295
            }
            response.sendRedirect("muc-room-edit-form.jsp?" + params);
Gaston Dombiak's avatar
Gaston Dombiak committed
296 297 298 299
            return;
        }
    }
    else {
300 301 302 303 304 305 306 307 308 309
        if (create) {
            // TODO Make this default values configurable (see JM-79)
            maxUsers = "30";
            broadcastModerator = "true";
            broadcastParticipant = "true";
            broadcastVisitor = "true";
            whois = "moderator";
            publicRoom = "true";
            // Rooms created from the admin console are always persistent
            persistentRoom = "true";
310 311
            canChangeNick = "true";
            registrationEnabled = "true";
312 313 314 315 316 317 318 319 320 321 322 323 324
        }
        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());
Gaston Dombiak's avatar
Gaston Dombiak committed
325
            persistentRoom = Boolean.toString(room.isPersistent());
326 327 328 329 330
            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());
331 332 333
            reservedNick = Boolean.toString(room.isLoginRestrictedToNickname());
            canChangeNick = Boolean.toString(room.canChangeNickname());
            registrationEnabled = Boolean.toString(room.isRegistrationEnabled());
Gaston Dombiak's avatar
Gaston Dombiak committed
334 335 336 337
        }
    }
    // Formatter for dates
    DateFormat dateFormatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
Gaston Dombiak's avatar
Gaston Dombiak committed
338
    roomName = roomName == null ? "" : roomName;
Gaston Dombiak's avatar
Gaston Dombiak committed
339 340
%>

341
<html>
Ryan Graham's avatar
Ryan Graham committed
342 343
<head>
<% if (create) { %>
344
<title><fmt:message key="muc.room.edit.form.create.title"/></title>
Ryan Graham's avatar
Ryan Graham committed
345 346
<meta name="pageID" content="muc-room-create"/>
<% } else { %>
347
<title><fmt:message key="muc.room.edit.form.edit.title"/></title>
Ryan Graham's avatar
Ryan Graham committed
348 349
<meta name="subPageID" content="muc-room-edit-form"/>
<% } %>
350
<meta name="extraParams" content="<%= "roomJID="+(roomJID != null ? URLEncoder.encode(roomJID.toBareJID(), "UTF-8") : "")+"&create="+create %>"/>
Ryan Graham's avatar
Ryan Graham committed
351 352 353
<meta name="helpPage" content="view_group_chat_room_summary.html"/>
</head>
<body>
Gaston Dombiak's avatar
Gaston Dombiak committed
354

355 356 357 358 359 360
<%  if (!errors.isEmpty()) { %>

    <div class="jive-error">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
        <tr>
361
            <td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0" alt=""/></td>
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
            <td class="jive-icon-label">

            <% if (errors.get("roomconfig_roomname") != null) { %>
                <fmt:message key="muc.room.edit.form.valid_hint_name" />
            <% } else if (errors.get("roomconfig_roomdesc") != null) { %>
                <fmt:message key="muc.room.edit.form.valid_hint_description" />
            <% } else if (errors.get("roomconfig_maxusers") != null) { %>
                <fmt:message key="muc.room.edit.form.valid_hint_max_room" />
            <% } else if (errors.get("roomconfig_roomsecret2") != null) { %>
                <fmt:message key="muc.room.edit.form.new_password" />
            <% } else if (errors.get("roomconfig_whois") != null) { %>
                <fmt:message key="muc.room.edit.form.role" />
            <% } else if (errors.get("roomName") != null) { %>
                <fmt:message key="muc.room.edit.form.valid_hint" />
            <% } else if (errors.get("room_already_exists") != null) { %>
                <fmt:message key="muc.room.edit.form.error_created_id" />
            <% } else if (errors.get("not_enough_permissions") != null) { %>
                <fmt:message key="muc.room.edit.form.error_created_privileges" />
            <% } else if (errors.get("room_topic") != null) { %>
                <fmt:message key="muc.room.edit.form.valid_hint_subject" />
            <% } %>
            </td>
        </tr>
    </tbody>
    </table>
Ryan Graham's avatar
Ryan Graham committed
387
    </div><br>
388 389

<%  } else if (success || addsuccess) { %>
Gaston Dombiak's avatar
Gaston Dombiak committed
390 391 392 393

    <div class="jive-success">
    <table cellpadding="0" cellspacing="0" border="0">
    <tbody>
394
        <tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0" alt=""></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
395 396 397
        <td class="jive-icon-label">
        <%  if (success) { %>

398
        <fmt:message key="muc.room.edit.form.edited" />
Gaston Dombiak's avatar
Gaston Dombiak committed
399 400 401

        <%  } else if (addsuccess) { %>

402
        <fmt:message key="muc.room.edit.form.created" />
Gaston Dombiak's avatar
Gaston Dombiak committed
403 404 405 406 407

        <%  } %>
        </td></tr>
    </tbody>
    </table>
408
    </div><br>
Gaston Dombiak's avatar
Gaston Dombiak committed
409 410 411

<%  } %>

412 413
<%  if (!create) { %>
    <p>
414
    <fmt:message key="muc.room.edit.form.info" />
415 416 417 418 419
    </p>
    <div class="jive-table">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <thead>
        <tr>
420 421 422 423
            <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>
424 425 426 427
        </tr>
    </thead>
    <tbody>
        <tr>
Sven Tantau's avatar
Sven Tantau committed
428
            <td><%= StringUtils.escapeHTMLTags(room.getName()) %></td>
429
            <% if (room.getOccupantsCount() == 0) { %>
430
            <td><%= room.getOccupantsCount() %> / <%= room.getMaxUsers() %></td>
431
            <% } else { %>
432
            <td><a href="muc-room-occupants.jsp?roomJID=<%= URLEncoder.encode(roomJID.toBareJID(), "UTF-8")%>"><%= room.getOccupantsCount() %> / <%= room.getMaxUsers() %></a></td>
433
            <% } %>
434 435 436 437 438 439 440
            <td><%= dateFormatter.format(room.getCreationDate()) %></td>
            <td><%= dateFormatter.format(room.getModificationDate()) %></td>
        </tr>
    </tbody>
    </table>
    </div>
    <br>
441
    <p><fmt:message key="muc.room.edit.form.change_room" /></p>
442
<%  } else { %>
443
    <p><fmt:message key="muc.room.edit.form.persistent_room" /></p>
444 445 446
<%  } %>
<form action="muc-room-edit-form.jsp">
<% if (!create) { %>
Sven Tantau's avatar
Sven Tantau committed
447
    <input type="hidden" name="roomJID" value="<%= StringUtils.escapeForXML(roomJID.toBareJID()) %>">
448
<% } %>
Gaston Dombiak's avatar
Gaston Dombiak committed
449
<input type="hidden" name="save" value="true">
450 451
<input type="hidden" name="create" value="<%= create %>">
<input type="hidden" name="roomconfig_persistentroom" value="<%= persistentRoom %>">
Gaston Dombiak's avatar
Gaston Dombiak committed
452 453

    <table width="100%" border="0"> <tr>
454 455
         <td width="70%">
            <table width="100%" border="0">
Gaston Dombiak's avatar
Gaston Dombiak committed
456
                <tbody>
457 458
                <% if (create) { %>
                <tr>
459
                    <td><fmt:message key="muc.room.edit.form.room_id" />:</td>
Sven Tantau's avatar
Sven Tantau committed
460
                    <td><input type="text" name="roomName" value="<%= StringUtils.escapeForXML(roomName) %>">
461
                        <% if (webManager.getMultiUserChatManager().getMultiUserChatServicesCount() > 1) { %>
462
                        @<select name="mucName">
463
                        <% for (MultiUserChatService service : webManager.getMultiUserChatManager().getMultiUserChatServices()) { %>
464
                        <%      if (service.isHidden()) continue; %>
Sven Tantau's avatar
Sven Tantau committed
465
                        <option value="<%= StringUtils.escapeForXML(service.getServiceDomain()) %>"<%= service.getServiceDomain().equals(mucName) ? " selected='selected'" : "" %>><%= StringUtils.escapeHTMLTags(service.getServiceDomain()) %></option>
466 467 468 469 470 471
                        <% } %>
                        </select>
                        <% } else { %>
                        @<%
                            // We only have one service, none-the-less, we have to run through the list to get the first
                            for (MultiUserChatService service : webManager.getMultiUserChatManager().getMultiUserChatServices()) {
472
                                if (service.isHidden()) {
473 474 475
                                    // Private and hidden, skip it.
                                    continue;
                                }
Sven Tantau's avatar
Sven Tantau committed
476
                                out.print("<input type='hidden' name='mucName' value='"+StringUtils.escapeForXML(service.getServiceDomain())+"'/>"+StringUtils.escapeHTMLTags(service.getServiceDomain()));
477 478 479 480
                                break;
                            }
                        %>
                        <% } %>
481 482
                    </td>
                </tr>
483 484 485
                <% } else { %>
                <tr>
                   <td><fmt:message key="muc.room.edit.form.service" />:</td>
Sven Tantau's avatar
Sven Tantau committed
486
                   <td><%= StringUtils.escapeHTMLTags(roomJID.getDomain()) %></td>
487
               </tr>
488
                <% } %>
Gaston Dombiak's avatar
Gaston Dombiak committed
489
                 <tr>
490
                    <td><fmt:message key="muc.room.edit.form.room_name" />:</td>
Sven Tantau's avatar
Sven Tantau committed
491
                    <td><input type="text" name="roomconfig_roomname" value="<%= (naturalName == null ? "" : StringUtils.escapeForXML(naturalName)) %>">
Gaston Dombiak's avatar
Gaston Dombiak committed
492 493 494
                    </td>
                </tr>
                 <tr>
495
                    <td><fmt:message key="muc.room.edit.form.description" />:</td>
Sven Tantau's avatar
Sven Tantau committed
496
                    <td><input name="roomconfig_roomdesc" value="<%= (description == null ? "" : StringUtils.escapeForXML(description)) %>" type="text" size="40">
Gaston Dombiak's avatar
Gaston Dombiak committed
497 498 499
                    </td>
                </tr>
                 <tr>
500
                    <td><fmt:message key="muc.room.edit.form.topic" />:</td>
Sven Tantau's avatar
Sven Tantau committed
501
                    <td><input name="room_topic" value="<%= (roomSubject == null ? "" : StringUtils.escapeForXML(roomSubject)) %>" type="text" size="40">
Gaston Dombiak's avatar
Gaston Dombiak committed
502 503 504
                    </td>
                </tr>
                 <tr>
505
                    <td><fmt:message key="muc.room.edit.form.max_room" />:</td>
Gaston Dombiak's avatar
Gaston Dombiak committed
506 507 508 509 510 511
                    <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>
512
                            <option value="0" <% if ("0".equals(maxUsers)) out.write("selected");%>><fmt:message key="muc.room.edit.form.none" /></option>
Gaston Dombiak's avatar
Gaston Dombiak committed
513 514 515 516
                        </select>
                    </td>
                </tr>
                 <tr>
517
                    <td valign="top"><fmt:message key="muc.room.edit.form.broadcast" />:</td>
Gaston Dombiak's avatar
Gaston Dombiak committed
518 519
                    <td><fieldset>
                        <input name="roomconfig_presencebroadcast" type="checkbox" value="true" id="moderator" <% if ("true".equals(broadcastModerator)) out.write("checked");%>>
520
                        <LABEL FOR="moderator"><fmt:message key="muc.room.edit.form.moderator" /></LABEL>
Gaston Dombiak's avatar
Gaston Dombiak committed
521
                        <input name="roomconfig_presencebroadcast2" type="checkbox" value="true" id="participant" <% if ("true".equals(broadcastParticipant)) out.write("checked");%>>
522
                        <LABEL FOR="participant"><fmt:message key="muc.room.edit.form.participant" /></LABEL>
Gaston Dombiak's avatar
Gaston Dombiak committed
523
                        <input name="roomconfig_presencebroadcast3" type="checkbox" value="true" id="visitor" <% if ("true".equals(broadcastVisitor)) out.write("checked");%>>
524
                        <LABEL FOR="visitor"><fmt:message key="muc.room.edit.form.visitor" /></LABEL>
Gaston Dombiak's avatar
Gaston Dombiak committed
525 526 527
                        </fieldset></td>
                </tr>
                 <tr>
528
                    <td><fmt:message key="muc.room.edit.form.required_password" />:</td>
Gaston Dombiak's avatar
Gaston Dombiak committed
529 530 531
                    <td><input type="password" name="roomconfig_roomsecret" <% if(password != null) { %> value="<%= password %>" <% } %>></td>
                </tr>
                 <tr>
532
                    <td><fmt:message key="muc.room.edit.form.confirm_password" />:</td>
Gaston Dombiak's avatar
Gaston Dombiak committed
533 534 535 536
                    <td><input type="password" name="roomconfig_roomsecret2" <% if(confirmPassword != null) { %> value="<%= confirmPassword %>" <% } %>>
                    </td>
                </tr>
                 <tr>
537
                    <td><fmt:message key="muc.room.edit.form.discover_jid" />:</td>
Gaston Dombiak's avatar
Gaston Dombiak committed
538
                    <td><select name="roomconfig_whois">
539 540
                            <option value="moderator" <% if ("moderator".equals(whois)) out.write("selected");%>><fmt:message key="muc.room.edit.form.moderator" /></option>
                            <option value="anyone" <% if ("anyone".equals(whois)) out.write("selected");%>><fmt:message key="muc.room.edit.form.anyone" /></option>
Gaston Dombiak's avatar
Gaston Dombiak committed
541 542 543 544
                        </select>
                    </td>
                 </tr>
         </tbody>
545 546 547
         </table>

         </td>
Gaston Dombiak's avatar
Gaston Dombiak committed
548 549
        <td width="30%" valign="top" >
        <fieldset>
550
        <legend><fmt:message key="muc.room.edit.form.room_options" /></legend>
Gaston Dombiak's avatar
Gaston Dombiak committed
551 552 553 554
        <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");%>>
555
                    <LABEL FOR="public"><fmt:message key="muc.room.edit.form.list_room" /></LABEL></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
556 557 558
            </tr>
            <tr>
                <td><input type="checkbox" name="roomconfig_moderatedroom" value="true" id="moderated" <% if ("true".equals(moderatedRoom)) out.write("checked");%>>
559
                    <LABEL FOR="moderated"><fmt:message key="muc.room.edit.form.room_moderated" /></LABEL></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
560 561 562
            </tr>
            <tr>
                <td><input type="checkbox" name="roomconfig_membersonly" value="true" id="membersOnly" <% if ("true".equals(membersOnly)) out.write("checked");%>>
563
                    <LABEL FOR="membersOnly"><fmt:message key="muc.room.edit.form.moderated_member_only" /></LABEL></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
564 565 566
            </tr>
            <tr>
                <td><input type="checkbox" name="roomconfig_allowinvites" value="true" id="allowinvites" <% if ("true".equals(allowInvites)) out.write("checked");%>>
567
                    <LABEL FOR="allowinvites"><fmt:message key="muc.room.edit.form.invite_other" /></LABEL></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
568 569 570
            </tr>
            <tr>
                <td><input type="checkbox" name="roomconfig_changesubject" value="true" id="changesubject" <% if ("true".equals(changeSubject)) out.write("checked");%>>
571
                    <LABEL FOR="changesubject"><fmt:message key="muc.room.edit.form.change_subject" /></LABEL></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
572
            </tr>
573 574 575 576 577 578 579 580 581 582 583 584
            <tr>
                <td><input type="checkbox" name="roomconfig_reservednick" value="true" id="reservednick" <% if ("true".equals(reservedNick)) out.write("checked");%>>
                    <LABEL FOR="reservednick"><fmt:message key="muc.room.edit.form.reservednick" /></LABEL></td>
            </tr>
            <tr>
                <td><input type="checkbox" name="roomconfig_canchangenick" value="true" id="canchangenick" <% if ("true".equals(canChangeNick)) out.write("checked");%>>
                    <LABEL FOR="canchangenick"><fmt:message key="muc.room.edit.form.canchangenick" /></LABEL></td>
            </tr>
            <tr>
                <td><input type="checkbox" name="roomconfig_registration" value="true" id="registration" <% if ("true".equals(registrationEnabled)) out.write("checked");%>>
                    <LABEL FOR="registration"><fmt:message key="muc.room.edit.form.registration" /></LABEL></td>
            </tr>
Gaston Dombiak's avatar
Gaston Dombiak committed
585 586
            <tr>
                <td><input type="checkbox" name="roomconfig_enablelogging" value="true" id="enablelogging" <% if ("true".equals(enableLog)) out.write("checked");%>>
587
                    <LABEL FOR="enablelogging"><fmt:message key="muc.room.edit.form.log" /></LABEL></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
588
            </tr>
589
        </tbody>
Gaston Dombiak's avatar
Gaston Dombiak committed
590 591 592 593
        </table>
        </fieldset>
        </tr>
         <tr align="center">
594 595
            <td colspan="2"><input type="submit" name="Submit" value="<fmt:message key="global.save_changes" />">
            <input type="submit" name="cancel" value="<fmt:message key="global.cancel" />"></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
596 597 598 599
        </tr>
    </table>
</form>

600
    </body>
601
</html>