-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathmuc-room-edit-form.jsp
More file actions
801 lines (759 loc) · 44.3 KB
/
Copy pathmuc-room-edit-form.jsp
File metadata and controls
801 lines (759 loc) · 44.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
<%@ page contentType="text/html; charset=UTF-8" %>
<%--
-
- Copyright (C) 2004-2008 Jive Software, 2017-2026 Ignite Realtime Foundation. 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="gnu.inet.encoding.Stringprep,
gnu.inet.encoding.StringprepException,
java.net.URLEncoder,
java.nio.charset.StandardCharsets,
java.util.*,
org.dom4j.Element,
org.jivesoftware.openfire.muc.MUCRoom,
org.jivesoftware.openfire.muc.NotAllowedException,
org.jivesoftware.openfire.muc.Role,
org.jivesoftware.openfire.muc.spi.MUCPersistenceManager,
org.jivesoftware.openfire.vcard.VCardBean,
org.jivesoftware.openfire.vcard.VCardManager,
org.jivesoftware.util.CookieUtils,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.StringUtils,
org.xmpp.forms.*,
org.xmpp.packet.IQ,
org.xmpp.packet.JID,
org.xmpp.packet.Message"
errorPage="error.jsp"
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="admin" prefix="admin" %>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out); %>
<% // Get parameters
Map<String, String> errors = new HashMap<>();
boolean create = ParamUtils.getBooleanParameter(request,"create");
boolean save = ParamUtils.getBooleanParameter(request,"save");
boolean success = ParamUtils.getBooleanParameter(request,"success");
boolean addsuccess = ParamUtils.getBooleanParameter(request,"addsuccess");
boolean clearchatsuccess = ParamUtils.getBooleanParameter(request,"clearchatsuccess");
String roomName = ParamUtils.getParameter(request,"roomName");
String mucName = ParamUtils.getParameter(request,"mucName");
if (mucName == null) {
mucName = ParamUtils.getParameter(request,"mucname");
}
String roomJIDStr = ParamUtils.getParameter(request,"roomJID");
JID roomJID = null;
if (roomName != null && mucName != null) {
try {
JID.nodeprep( roomName );
} catch ( IllegalArgumentException e ) {
errors.put("roomName","roomName");
}
try {
JID.domainprep( mucName );
} catch ( IllegalArgumentException e ) {
errors.put("mucName","mucName");
}
if ( errors.isEmpty() )
{
roomJID = new JID( roomName, mucName, null );
}
}
else if (roomJIDStr != null) {
try {
roomJID = new JID( roomJIDStr );
} catch ( IllegalArgumentException e ) {
errors.put( "roomJID", "roomJID" );
}
if ( roomJID != null )
{
roomName = roomJID.getNode();
mucName = roomJID.getDomain();
}
}
String naturalName = ParamUtils.getParameter(request,"roomconfig_roomname");
String description = ParamUtils.getParameter(request,"roomconfig_roomdesc");
String maxUsers = ParamUtils.getParameter(request, "roomconfig_maxusers");
boolean broadcastModerator = ParamUtils.getBooleanParameter(request, "roomconfig_presencebroadcast");
boolean broadcastParticipant = ParamUtils.getBooleanParameter(request, "roomconfig_presencebroadcast2");
boolean broadcastVisitor = ParamUtils.getBooleanParameter(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 allowpm = ParamUtils.getParameter(request, "roomconfig_allowpm");
boolean publicRoom = ParamUtils.getBooleanParameter(request, "roomconfig_publicroom");
boolean persistentRoom = ParamUtils.getBooleanParameter(request, "roomconfig_persistentroom");
boolean retireOnDeletion = ParamUtils.getBooleanParameter(request, "roomconfig_retireondel");
boolean moderatedRoom = ParamUtils.getBooleanParameter(request, "roomconfig_moderatedroom");
boolean membersOnly = ParamUtils.getBooleanParameter(request, "roomconfig_membersonly");
boolean allowInvites = ParamUtils.getBooleanParameter(request, "roomconfig_allowinvites");
boolean changeSubject = ParamUtils.getBooleanParameter(request, "roomconfig_changesubject");
boolean enableLog = ParamUtils.getBooleanParameter(request, "roomconfig_enablelogging");
boolean preserveHistOnRoomDeletion = ParamUtils.getBooleanParameter(request, "roomconfig_preservehistondel");
boolean reservedNick = ParamUtils.getBooleanParameter(request, "roomconfig_reservednick");
boolean canchangenick = ParamUtils.getBooleanParameter(request, "roomconfig_canchangenick");
boolean registration = ParamUtils.getBooleanParameter(request, "roomconfig_registration");
String roomSubject = ParamUtils.getParameter(request, "room_topic", true);
if (webManager.getMultiUserChatManager().getMultiUserChatServicesCount() < 1) {
// No services exist, so redirect to where one can configure the services
response.sendRedirect("muc-service-summary.jsp");
return;
}
// Handle a cancel
if (request.getParameter("cancel") != null) {
if (roomJID == null) {
// case when canceling creating a new room
response.sendRedirect("muc-room-summary.jsp");
} else {
// case when canceling a room edit, used on summary to set service
response.sendRedirect("muc-room-summary.jsp?roomJID="+URLEncoder.encode(roomJID.toBareJID(), StandardCharsets.UTF_8));
}
return;
}
// Load the room object
MUCRoom room = null;
if (!create) {
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(), StandardCharsets.UTF_8));
return;
}
}
// Handle an save
Cookie csrfCookie = CookieUtils.getCookie(request, "csrf");
String csrfParam = ParamUtils.getParameter(request, "csrf");
if (save) {
if (csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals(csrfParam)) {
save = false;
errors.put("csrf", "CSRF Failure!");
}
}
csrfParam = StringUtils.randomString(15);
CookieUtils.setCookie(request, response, "csrf", csrfParam, -1);
pageContext.setAttribute("csrf", csrfParam);
if (save) {
// do validation
if (naturalName == null) {
errors.put("roomconfig_roomname","roomconfig_roomname");
}
if (description == null) {
errors.put("roomconfig_roomdesc","roomconfig_roomdesc");
}
if (maxUsers == null || maxUsers.isEmpty()) {
maxUsers = "0"; // 0 indicates no limit.
}
try {
Integer.parseInt(maxUsers);
} catch ( NumberFormatException e ) {
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");
}
if ( allowpm == null || !( allowpm.equals( "anyone" ) || allowpm.equals( "moderators" ) || allowpm.equals( "participants" ) || allowpm.equals( "none" )) ) {
errors.put("roomconfig_allowpm","romconfig_allowpm");
}
if (roomSubject != null && roomSubject.length() > 100) {
errors.put("room_topic_longer","room_topic_longer");
}
if (create && errors.isEmpty()) {
if (roomName == null || roomName.contains("@")) {
errors.put("roomName","roomName");
}
else {
// Check that the room name is a valid node
try {
roomName = Stringprep.nodeprep(roomName);
}
catch (StringprepException e) {
errors.put("roomName","roomName");
}
}
if (errors.isEmpty()) {
// Check that the requested room ID is available
room = webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomName);
if (room != null) {
errors.put("room_already_exists", "room_already_exists");
}
else {
// Try to create a new room
JID address = new JID(webManager.getUser().getUsername(), webManager.getServerInfo().getXMPPDomain(), null);
try {
room = webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).getChatRoom(roomName, address);
// Check if the room was created concurrently by another user
if (!room.getOwners().contains(address.asBareJID())) {
errors.put("room_already_exists", "room_already_exists");
}
}
catch (NotAllowedException e) {
// This user is not allowed to create rooms, or it has been retired
String cause = switch(e.getReason()) {
case ROOM_RETIRED -> "room_retired";
case INSUFFICIENT_PERMISSIONS -> "not_enough_permissions";
};
errors.put(cause, cause);
}
}
}
}
if (errors.isEmpty()) {
// Set the new configuration sending an IQ packet with an dataform
final DataForm dataForm = new DataForm(DataForm.Type.submit);
dataForm.addField("FORM_TYPE", null, FormField.Type.hidden).addValue("http://jabber.org/protocol/muc#roomconfig");
dataForm.addField("muc#roomconfig_roomname", null, null).addValue(naturalName);
dataForm.addField("muc#roomconfig_roomdesc", null, null).addValue(description);
dataForm.addField("muc#roomconfig_changesubject", null, null).addValue(changeSubject ? "1": "0");
dataForm.addField("muc#roomconfig_maxusers", null, null).addValue(maxUsers);
final FormField broadcastField = dataForm.addField("muc#roomconfig_presencebroadcast", null, null);
if (broadcastModerator) {
broadcastField.addValue(Role.moderator);
}
if (broadcastParticipant) {
broadcastField.addValue(Role.participant);
}
if (broadcastVisitor) {
broadcastField.addValue(Role.visitor);
}
dataForm.addField("muc#roomconfig_publicroom", null, null).addValue(publicRoom ? "1": "0");
dataForm.addField("muc#roomconfig_persistentroom", null, null).addValue(persistentRoom ? "1": "0");
dataForm.addField("{http://igniterealtime.org}muc#roomconfig_retireondel", null, null).addValue(retireOnDeletion ? "1": "0");
dataForm.addField("muc#roomconfig_moderatedroom", null, null).addValue(moderatedRoom ? "1": "0");
dataForm.addField("muc#roomconfig_membersonly", null, null).addValue(membersOnly ? "1": "0");
dataForm.addField("muc#roomconfig_allowinvites", null, null).addValue(allowInvites ? "1": "0");
dataForm.addField("muc#roomconfig_passwordprotectedroom", null, null).addValue((password == null) ? "0": "1");
dataForm.addField("muc#roomconfig_roomsecret", null, null).addValue(password);
dataForm.addField("muc#roomconfig_whois", null, null).addValue(whois);
dataForm.addField("muc#roomconfig_allowpm", null, null).addValue(allowpm);
dataForm.addField("muc#roomconfig_enablelogging", null, null).addValue(enableLog ? "1": "0");
dataForm.addField("{http://igniterealtime.org}muc#roomconfig_preservehistondel", null, null).addValue(preserveHistOnRoomDeletion ? "1": "0");
dataForm.addField("x-muc#roomconfig_reservednick", null, null).addValue(reservedNick ? "1": "0");
dataForm.addField("x-muc#roomconfig_canchangenick", null, null).addValue(canchangenick ? "1": "0");
dataForm.addField("x-muc#roomconfig_registration", null, null).addValue(registration ? "1": "0");
final FormField roomAdminsField = dataForm.addField("muc#roomconfig_roomadmins", null, null);
room.getAdmins().forEach( admin -> roomAdminsField.addValue( admin.toString() ));
// Keep the existing list of owners
final FormField roomOwnersField = dataForm.addField("muc#roomconfig_roomowners", null, null);
room.getOwners().forEach( owner -> roomOwnersField.addValue( owner.toString() ));
// update subject before sending IQ (to include subject with cluster update)
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.getSelfRepresentation().getOccupantJID());
message.setTo(room.getSelfRepresentation().getOccupantJID());
room.changeSubject(message, room.getSelfRepresentation());
}
// 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.getElement());
// Send the IQ packet that will modify the room's configuration
room.getIQOwnerHandler().handleIQ(iq, room.getSelfRepresentation());
webManager.getMultiUserChatManager().getMultiUserChatService(roomJID).syncChatRoom(room);
// Changes good, so redirect
String params;
if (create) {
params = "addsuccess=true&roomJID=" + URLEncoder.encode(roomJID.toBareJID(), StandardCharsets.UTF_8);
// Log the event
webManager.logEvent("created new MUC room "+roomName, "subject = "+roomSubject+"\nroomdesc = "+description+"\nroomname = "+naturalName+"\nmaxusers = "+maxUsers);
}
else {
params = "success=true&roomJID=" + URLEncoder.encode(roomJID.toBareJID(), StandardCharsets.UTF_8);
// Log the event
webManager.logEvent("updated MUC room "+roomName, "subject = "+roomSubject+"\nroomdesc = "+description+"\nroomname = "+naturalName+"\nmaxusers = "+maxUsers);
}
response.sendRedirect("muc-room-edit-form.jsp?" + params);
return;
}
}
else {
if (create) {
// OF-31: Retrieve and validate the candidate service context parameter (mucName).
// Fall back to the alphabetically first service if missing, invalid, or does not exist.
// This ensures backwards compatibility and graceful fallback when accessed directly.
String resolvedServiceName = null;
if (mucName != null) {
if (webManager.getMultiUserChatManager().isServiceRegistered(mucName)) {
resolvedServiceName = mucName;
} else {
try {
org.jivesoftware.openfire.muc.MultiUserChatService service = webManager.getMultiUserChatManager().getMultiUserChatService(new JID(null, mucName, null));
if (service != null) {
resolvedServiceName = service.getServiceName();
}
} catch (Exception e) {
// ignore
}
}
}
if (resolvedServiceName == null) {
resolvedServiceName = webManager.getMultiUserChatManager().getMultiUserChatServices().iterator().next().getServiceName();
}
final String serviceName = resolvedServiceName;
org.jivesoftware.openfire.muc.MultiUserChatService resolvedService = webManager.getMultiUserChatManager().getMultiUserChatService(serviceName);
if (resolvedService != null) {
mucName = resolvedService.getServiceDomain();
}
maxUsers = MUCPersistenceManager.getProperty(serviceName, "room.maxUsers", "30");
broadcastModerator = MUCPersistenceManager.getBooleanProperty(serviceName, "room.broadcastModerator", true);
broadcastParticipant = MUCPersistenceManager.getBooleanProperty(serviceName, "room.broadcastParticipant", true);
broadcastVisitor = MUCPersistenceManager.getBooleanProperty(serviceName, "room.broadcastVisitor", true);
whois = MUCPersistenceManager.getBooleanProperty(serviceName, "room.canAnyoneDiscoverJID", true) ? "anyone" : "moderator";
allowpm = MUCPersistenceManager.getProperty(serviceName, "room.allowpm", "anyone");
publicRoom = MUCPersistenceManager.getBooleanProperty(serviceName, "room.publicRoom", true);
persistentRoom = true; // Rooms created from the admin console are always persistent
retireOnDeletion = MUCPersistenceManager.getBooleanProperty(serviceName, "room.retireOnDeletion", false);
moderatedRoom = MUCPersistenceManager.getBooleanProperty(serviceName, "room.moderated", false);
membersOnly = MUCPersistenceManager.getBooleanProperty(serviceName, "room.membersOnly", false);
allowInvites = MUCPersistenceManager.getBooleanProperty(serviceName, "room.canOccupantsInvite", false);
changeSubject = MUCPersistenceManager.getBooleanProperty(serviceName, "room.canOccupantsChangeSubject", false);
enableLog = MUCPersistenceManager.getBooleanProperty(serviceName, "room.logEnabled", true);
preserveHistOnRoomDeletion = MUCPersistenceManager.getBooleanProperty(serviceName, "room.preserveHistOnRoomDeletion", true);
reservedNick = MUCPersistenceManager.getBooleanProperty(serviceName, "room.loginRestrictedToNickname", false);
canchangenick = MUCPersistenceManager.getBooleanProperty(serviceName, "room.canChangeNickname", true);
registration = MUCPersistenceManager.getBooleanProperty(serviceName, "room.registrationEnabled", true);
}
else {
naturalName = room.getNaturalLanguageName();
description = room.getDescription();
roomSubject = room.getSubject();
maxUsers = Integer.toString(room.getMaxUsers());
broadcastModerator = room.canBroadcastPresence(Role.moderator);
broadcastParticipant = room.canBroadcastPresence(Role.participant);
broadcastVisitor = room.canBroadcastPresence(Role.visitor);
password = room.getPassword();
confirmPassword = room.getPassword();
whois = (room.canAnyoneDiscoverJID() ? "anyone" : "moderator");
allowpm = room.canSendPrivateMessage();
publicRoom = room.isPublicRoom();
persistentRoom = room.isPersistent();
retireOnDeletion = room.isRetireOnDeletion();
moderatedRoom = room.isModerated();
membersOnly = room.isMembersOnly();
allowInvites = room.canOccupantsInvite();
changeSubject = room.canOccupantsChangeSubject();
enableLog = room.isLogEnabled();
preserveHistOnRoomDeletion = room.isPreserveHistOnRoomDeletionEnabled();
reservedNick = room.isLoginRestrictedToNickname();
canchangenick = room.canChangeNickname();
registration = room.isRegistrationEnabled();
}
}
roomName = roomName == null ? "" : roomName;
if (roomJID != null) {
final Element vCardElement = VCardManager.getInstance().getVCard(roomJID.toString());
VCardBean vCardBean = new VCardBean();
vCardBean.loadFromElement(vCardElement);
pageContext.setAttribute("vCard", vCardBean);
}
pageContext.setAttribute("errors", errors);
pageContext.setAttribute("create", create);
pageContext.setAttribute("success", success);
pageContext.setAttribute("addsuccess", addsuccess);
pageContext.setAttribute("clearchatsuccess", clearchatsuccess);
pageContext.setAttribute("room", room);
pageContext.setAttribute("roomJID", roomJID);
pageContext.setAttribute("roomJIDBare", roomJID != null ? roomJID.toBareJID() : null);
pageContext.setAttribute("persistentRoom", persistentRoom);
pageContext.setAttribute("roomName", roomName);
pageContext.setAttribute("mucName", mucName);
pageContext.setAttribute("naturalName", naturalName);
pageContext.setAttribute("description", description);
pageContext.setAttribute("roomSubject", roomSubject);
pageContext.setAttribute("maxUser", maxUsers);
pageContext.setAttribute("broadcastModerator", broadcastModerator);
pageContext.setAttribute("broadcastParticipant", broadcastParticipant);
pageContext.setAttribute("broadcastVisitor", broadcastVisitor);
pageContext.setAttribute("password", password);
pageContext.setAttribute("confirmPassword", confirmPassword);
pageContext.setAttribute("whois", whois);
pageContext.setAttribute("allowpm", allowpm);
pageContext.setAttribute("publicRoom", publicRoom);
pageContext.setAttribute("retireOnDeletion", retireOnDeletion);
pageContext.setAttribute("moderatedRoom", moderatedRoom);
pageContext.setAttribute("membersonly", membersOnly);
pageContext.setAttribute("allowInvites", allowInvites);
pageContext.setAttribute("changeSubject", changeSubject);
pageContext.setAttribute("reservedNick", reservedNick);
pageContext.setAttribute("canchangenick", canchangenick);
pageContext.setAttribute("registration", registration);
pageContext.setAttribute("enableLog", enableLog);
pageContext.setAttribute("preserveHistOnRoomDeletion", preserveHistOnRoomDeletion);
%>
<html>
<head>
<c:choose>
<c:when test="${create}">
<title><fmt:message key="muc.room.edit.form.create.title"/></title>
<meta name="pageID" content="muc-room-create"/>
</c:when>
<c:otherwise>
<title><fmt:message key="muc.room.edit.form.edit.title"/></title>
<meta name="subPageID" content="muc-room-edit-form"/>
</c:otherwise>
</c:choose>
<meta name="extraParams" content="<%= "roomJID="+(roomJID != null ? URLEncoder.encode(roomJID.toBareJID(), StandardCharsets.UTF_8) : "")+"&create="+create %>"/>
<meta name="helpPage" content="view_group_chat_room_summary.html"/>
<style>
/* Inspired by https://www.w3schools.com/howto/howto_css_modal_images.asp */
#photo {
border-radius: 2px;
cursor: pointer;
transition: 0.3s;
}
#photo:hover {opacity: 0.7;}
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
}
/* Modal Content (Image) */
.modal-content {
margin: auto;
display: block;
width: 80%;
max-width: 700px;
animation-name: zoom;
animation-duration: 0.6s;
}
@keyframes zoom {
from {transform:scale(0)}
to {transform:scale(1)}
}
/* The Close Button */
.close {
position: absolute;
top: 15px;
right: 35px;
color: #f1f1f1;
font-size: 40px;
font-weight: bold;
transition: 0.3s;
}
.close:hover,
.close:focus {
color: #bbb;
text-decoration: none;
cursor: pointer;
}
/* 100% Image Width on Smaller Screens */
@media only screen and (max-width: 700px) {
.modal-content {
width: 100%;
}
}
</style>
</head>
<body>
<c:choose>
<c:when test="${not empty errors}">
<c:forEach var="err" items="${errors}">
<admin:infobox type="error">
<c:choose>
<c:when test="${err.key eq 'csrf'}"><fmt:message key="global.csrf.failed" /></c:when>
<c:when test="${err.key eq 'roomconfig_roomname'}"><fmt:message key="muc.room.edit.form.valid_hint_name" /></c:when>
<c:when test="${err.key eq 'roomconfig_roomdesc'}"><fmt:message key="muc.room.edit.form.valid_hint_description" /></c:when>
<c:when test="${err.key eq 'roomconfig_maxusers'}"><fmt:message key="muc.room.edit.form.valid_hint_max_room" /></c:when>
<c:when test="${err.key eq 'roomconfig_roomsecret2'}"><fmt:message key="muc.room.edit.form.new_password" /></c:when>
<c:when test="${err.key eq 'roomconfig_whois'}"><fmt:message key="muc.room.edit.form.role" /></c:when>
<c:when test="${err.key eq 'roomconfig_allowpm'}"><fmt:message key="muc.room.edit.form.role" /></c:when>
<c:when test="${err.key eq 'roomName'}"><fmt:message key="muc.room.edit.form.valid_hint" /></c:when>
<c:when test="${err.key eq 'room_already_exists'}"><fmt:message key="muc.room.edit.form.error_created_id" /></c:when>
<c:when test="${err.key eq 'not_enough_permissions'}"><fmt:message key="muc.room.edit.form.error_created_privileges" /></c:when>
<c:when test="${err.key eq 'room_retired'}"><fmt:message key="muc.room.edit.form.error_room_retired" /></c:when>
<c:when test="${err.key eq 'room_topic'}"><fmt:message key="muc.room.edit.form.valid_hint_subject" /></c:when>
<c:when test="${err.key eq 'room_topic_longer'}"><fmt:message key="muc.room.edit.form.valid_hint_subject_too_long" /></c:when>
<c:otherwise>
<c:if test="${not empty err.value}">
<fmt:message key="admin.error"/>: <c:out value="${err.value}"/>
</c:if>
(<c:out value="${err.key}"/>)
</c:otherwise>
</c:choose>
</admin:infobox>
</c:forEach>
</c:when>
<c:when test="${success}">
<admin:infobox type="success">
<fmt:message key="muc.room.edit.form.edited" />
</admin:infobox>
</c:when>
<c:when test="${addsuccess}">
<admin:infobox type="success">
<fmt:message key="muc.room.edit.form.created" />
</admin:infobox>
</c:when>
<c:when test="${clearchatsuccess}">
<admin:infoBox type="success">
<fmt:message key="muc.room.summary.cleared_chat" />
</admin:infoBox>
</c:when>
</c:choose>
<c:if test="${room.locked}">
<admin:infobox type="warning">
<fmt:message key="muc.room.edit.form.warning.room_is_locked">
<fmt:param>
<fmt:formatDate value="${room.lockedDate}" type="both" dateStyle="medium" timeStyle="short"/>
</fmt:param>
</fmt:message>
</admin:infobox>
</c:if>
<c:choose>
<c:when test="${not create}">
<p>
<fmt:message key="muc.room.edit.form.info" />
</p>
<div class="jive-table">
<table>
<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>
<c:if test="${not empty vCard.photo}">
<td style="width: 5em;" rowspan="2">
<img id="photo" src="/user/vcard/photo/?username=${admin:urlEncode(roomJID)}" alt="${admin:escapeHTMLTags(room.name)}" style="height: 4em" onclick="document.getElementById('photoModal').style.display='block';"/>
</td>
</c:if>
</tr>
<tr>
<td>
<c:out value="${room.name}"/>
</td>
<td>
<c:choose>
<c:when test="${room.occupantsCount eq 0}">
<c:out value="${room.occupantsCount}"/>
<c:if test="${room.maxUsers gt 0}">
/ <c:out value="${room.maxUsers}"/>
</c:if>
</c:when>
<c:otherwise>
<c:url var="mucroomoccupantslink" value="muc-room-occupants.jsp">
<c:param name="roomJID" value="${roomJIDBare}"/>
</c:url>
<a href="${mucroomoccupantslink}">
<c:out value="${room.occupantsCount}"/>
<c:if test="${room.maxUsers gt 0}">
/ <c:out value="${room.maxUsers}"/>
</c:if>
</a>
</c:otherwise>
</c:choose>
</td>
<td>
<fmt:formatDate value="${room.creationDate}" dateStyle="medium" timeStyle="short"/>
</td>
<td>
<fmt:formatDate value="${room.modificationDate}" dateStyle="medium" timeStyle="short"/>
</td>
</tr>
</table>
</div>
<br>
<p><fmt:message key="muc.room.edit.form.change_room" /></p>
</c:when>
<c:otherwise>
<p><fmt:message key="muc.room.edit.form.persistent_room" /></p>
</c:otherwise>
</c:choose>
<form action="muc-room-edit-form.jsp" autocomplete="off">
<c:if test="${not create}">
<input type="hidden" name="roomJID" value="${fn:escapeXml(roomJIDBare)}">
</c:if>
<input type="hidden" name="csrf" value="${csrf}">
<input type="hidden" name="save" value="true">
<input type="hidden" name="create" value="${create}">
<input type="hidden" name="roomconfig_persistentroom" value="${persistentRoom}">
<table style="width: 100%">
<tr>
<td style="width: 70%">
<table style="width: 100%">
<tbody>
<tr>
<c:choose>
<c:when test="${create}">
<td><label for="roomName"><fmt:message key="muc.room.edit.form.room_id" /></label>: *</td>
<td><input type="text" name="roomName" id="roomName" value="${fn:escapeXml(roomName)}">
<c:choose>
<c:when test="${webManager.multiUserChatManager.multiUserChatServicesCount gt 1}">
@<select name="mucName">
<c:forEach var="service" items="${webManager.multiUserChatManager.multiUserChatServices}">
<c:if test="${not service.hidden}">
<option value="${fn:escapeXml(service.serviceDomain)}" ${service.serviceDomain eq mucName ? "selected='selected'" : ""}>
<c:out value="${service.serviceDomain}"/>
</option>
</c:if>
</c:forEach>
</select>
</c:when>
<c:otherwise>
<c:forEach var="service" items="${webManager.multiUserChatManager.multiUserChatServices}">
<c:if test="${not service.hidden}">
<input type="hidden" name="mucName" value="${fn:escapeXml(service.serviceDomain)}"/>
@<c:out value="${service.serviceDomain}"/>
</c:if>
</c:forEach>
</c:otherwise>
</c:choose>
</td>
</c:when>
<c:otherwise>
<td><fmt:message key="muc.room.edit.form.service" />:</td>
<td><c:out value="${roomJID.domain}"/></td>
</c:otherwise>
</c:choose>
</tr>
<tr>
<td><label for="roomconfig_roomname"><fmt:message key="muc.room.edit.form.room_name" /></label>: *</td>
<td><input type="text" name="roomconfig_roomname" id="roomconfig_roomname" value="${fn:escapeXml(naturalName)}"></td>
</tr>
<tr>
<td><label for="roomconfig_roomdesc"><fmt:message key="muc.room.edit.form.description" /></label>: *</td>
<td><input name="roomconfig_roomdesc" id="roomconfig_roomdesc" value="${fn:escapeXml(description)}" type="text" size="40"></td>
</tr>
<tr>
<td><label for="room_topic"><fmt:message key="muc.room.edit.form.topic" /></label>:</td>
<td><input name="room_topic" id="room_topic" value="${fn:escapeXml(roomSubject)}" type="text" size="40"></td>
</tr>
<tr>
<td><label for="roomconfig_maxusers"><fmt:message key="muc.room.edit.form.max_room" /></label>:</td>
<td><input type="number" name="roomconfig_maxusers" id="roomconfig_maxusers" min="1" value="${empty maxUser or maxUser eq '0' ? "" : fn:escapeXml(maxUser)}" size="5">
<fmt:message key="muc.room.edit.form.empty_nolimit" />
</td>
</tr>
<tr>
<td style="vertical-align: top"><fmt:message key="muc.room.edit.form.broadcast" />:</td>
<td>
<input name="roomconfig_presencebroadcast" type="checkbox" value="true" id="moderator" ${broadcastModerator ? 'checked' : ''}>
<label for="moderator"><fmt:message key="muc.room.edit.form.moderator" /></label>
<input name="roomconfig_presencebroadcast2" type="checkbox" value="true" id="participant" ${broadcastParticipant ? 'checked' : ''}>
<label for="participant"><fmt:message key="muc.room.edit.form.participant" /></label>
<input name="roomconfig_presencebroadcast3" type="checkbox" value="true" id="visitor" ${broadcastVisitor ? 'checked' : ''}>
<label for="visitor"><fmt:message key="muc.room.edit.form.visitor" /></label>
</td>
</tr>
<tr>
<td><label for="roomconfig_roomsecret"><fmt:message key="muc.room.edit.form.required_password" /></label>:</td>
<td><input type="password" name="roomconfig_roomsecret" id="roomconfig_roomsecret" <c:if test="${not empty password}">value="${fn:escapeXml(password)}"</c:if>></td>
</tr>
<tr>
<td><label for="roomconfig_roomsecret2"><fmt:message key="muc.room.edit.form.confirm_password" /></label>:</td>
<td><input type="password" name="roomconfig_roomsecret2" id="roomconfig_roomsecret2" <c:if test="${not empty confirmPassword}">value="${fn:escapeXml(confirmPassword)}"</c:if>></td>
</tr>
<tr>
<td><label for="roomconfig_whois"><fmt:message key="muc.room.edit.form.discover_jid" /></label>:</td>
<td>
<select name="roomconfig_whois" id="roomconfig_whois">
<option value="moderator" ${whois eq 'moderator' ? 'selected' : ''}><fmt:message key="muc.room.edit.form.moderator" /></option>
<option value="anyone" ${whois eq 'anyone' ? 'selected' : ''}><fmt:message key="muc.room.edit.form.anyone" /></option>
</select>
</td>
</tr>
<tr>
<td><label for="roomconfig_allowpm"><fmt:message key="muc.room.edit.form.allowpm" /></label>:</td>
<td>
<select name="roomconfig_allowpm" id="roomconfig_allowpm">
<option value="none" ${allowpm eq 'none' ? 'selected' : ''}><fmt:message key="muc.form.conf.none" /></option>
<option value="moderators" ${allowpm eq 'moderators' ? 'selected' : ''}><fmt:message key="muc.room.edit.form.moderator" /></option>
<option value="participants" ${allowpm eq 'participants' ? 'selected' : ''}><fmt:message key="muc.room.edit.form.participant" /></option>
<option value="anyone" ${allowpm eq 'anyone' ? 'selected' : ''}><fmt:message key="muc.room.edit.form.anyone" /></option>
</select>
</td>
</tr>
</tbody>
</table>
</td>
<td style="width: 100%; vertical-align: top">
<fieldset>
<legend><fmt:message key="muc.room.edit.form.room_options" /></legend>
<table style="width: 100%">
<tbody>
<tr>
<td><input type="checkbox" name="roomconfig_publicroom" value="true" id="public" ${publicRoom ? 'checked' : ''}>
<label for="public"><fmt:message key="muc.room.edit.form.list_room" /></label></td>
</tr>
<tr>
<td><input name="roomconfig_retireondel" value="true" id="retireOnDeletion" type="checkbox" ${retireOnDeletion ? 'checked' : ''}>
<label for="retireOnDeletion"><fmt:message key="muc.default.settings.retire" /></label></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_moderatedroom" value="true" id="moderated" ${moderatedRoom ? 'checked' : ''}>
<label for="moderated"><fmt:message key="muc.room.edit.form.room_moderated" /></label></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_membersonly" value="true" id="membersonly" ${membersonly ? 'checked' : ''}>
<label for="membersonly"><fmt:message key="muc.room.edit.form.moderated_member_only" /></label></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_allowinvites" value="true" id="allowinvites" ${allowInvites ? 'checked' : ''}>
<label for="allowinvites"><fmt:message key="muc.room.edit.form.invite_other" /></label></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_changesubject" value="true" id="changesubject" ${changeSubject ? 'checked' : ''}>
<label for="changesubject"><fmt:message key="muc.room.edit.form.change_subject" /></label></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_reservednick" value="true" id="reservednick"${reservedNick ? '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" ${canchangenick ? '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" ${registration ? 'checked' : ''}>
<label for="registration"><fmt:message key="muc.room.edit.form.registration" /></label></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_enablelogging" value="true" id="enablelogging" ${enableLog ? 'checked' : ''}>
<label for="enablelogging"><fmt:message key="muc.room.edit.form.log" /></label></td>
</tr>
<tr>
<td><input type="checkbox" name="roomconfig_preservehistondel" value="true" id="preserveHistOnRoomDeletion" ${preserveHistOnRoomDeletion ? 'checked' : ''}>
<label for="preserveHistOnRoomDeletion"><fmt:message key="muc.room.edit.form.preserve_hist_on_room_deletion" /></label></td>
</tr>
</tbody>
</table>
</fieldset>
</td>
</tr>
<tr style="text-align: center">
<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>
</tr>
</table>
<span class="jive-description">* <fmt:message key="muc.room.edit.form.required_field" /> </span>
</form>
<div id="photoModal" class="modal">
<span class="close" onclick="document.getElementById('photoModal').style.display='none';">×</span>
<img class="modal-content" src="/user/vcard/photo/?username=${admin:urlEncode(roomJID)}" alt="${admin:escapeHTMLTags(room.name)}"/>
</div>
</body>
</html>