%@ page contentType="text/html; charset=UTF-8" %>
<%--
-
- Copyright (C) 2004-2010 Jive Software, 2017-2025 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="org.jivesoftware.util.*,
java.util.*,
org.jivesoftware.openfire.muc.spi.MUCPersistenceManager"
errorPage="error.jsp"
%>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.nio.charset.StandardCharsets" %>
<%@ 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" %>
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters
boolean save = request.getParameter("save") != null;
boolean success = request.getParameter("success") != null;
String mucname = ParamUtils.getParameter(request,"mucname");
String publicRoom = ParamUtils.getParameter(request, "roomconfig_publicroom");
String persistentRoom = ParamUtils.getParameter(request, "roomconfig_persistentroom");
String retireOnDeletion = ParamUtils.getParameter(request, "roomconfig_retireondel");
String moderatedRoom = ParamUtils.getParameter(request, "roomconfig_moderatedroom");
String membersOnly = ParamUtils.getParameter(request, "roomconfig_membersonly");
String nonanonymous = ParamUtils.getParameter(request, "roomconfig_nonanonymous");
String allowInvites = ParamUtils.getParameter(request, "roomconfig_allowinvites");
String changeSubject = ParamUtils.getParameter(request, "roomconfig_changesubject");
String reservedNick = ParamUtils.getParameter(request, "roomconfig_reservednick");
String canChangeNick = ParamUtils.getParameter(request, "roomconfig_canchangenick");
String registrationEnabled = ParamUtils.getParameter(request, "roomconfig_registration");
String enableLog = ParamUtils.getParameter(request, "roomconfig_enablelogging");
String preserveHistOnRoomDeletion = ParamUtils.getParameter(request, "roomconfig_preservehistondel");
String maxUsers = ParamUtils.getParameter(request, "roomconfig_maxusers");
String broadcastModerator = ParamUtils.getParameter(request, "roomconfig_broadcastmoderator");
String broadcastParticipant = ParamUtils.getParameter(request, "roomconfig_broadcastparticipant");
String broadcastVisitor = ParamUtils.getParameter(request, "roomconfig_broadcastvisitor");
String allowpm = ParamUtils.getParameter(request, "roomconfig_allowpm");
if (!webManager.getMultiUserChatManager().isServiceRegistered(mucname)) {
// The requested service name does not exist so return to the list of the existing rooms
response.sendRedirect("muc-service-summary.jsp");
return;
}
// Handle a save
Map errors = new HashMap<>();
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) {
try {
if (maxUsers == null || maxUsers.isEmpty()) {
maxUsers = "0"; // 0 indicates no limit.
}
Integer.parseInt(maxUsers);
MUCPersistenceManager.setProperty(mucname, "room.maxUsers", maxUsers);
}
catch (Exception e) {
errors.put("max_users", "max_users");
}
if ( Arrays.asList("anyone", "moderators", "participants", "none").contains(allowpm)) {
MUCPersistenceManager.setProperty(mucname, "room.allowpm", allowpm);
} else {
errors.put("allowpm", "allowpm");
}
if (errors.isEmpty()) {
if (publicRoom != null && !publicRoom.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.publicRoom", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.publicRoom", "false");
}
if (persistentRoom != null && !persistentRoom.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.persistent", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.persistent", "false");
}
if (retireOnDeletion != null && !retireOnDeletion.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.retireOnDeletion", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.retireOnDeletion", "false");
}
if (moderatedRoom != null && !moderatedRoom.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.moderated", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.moderated", "false");
}
if (membersOnly != null && !membersOnly.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.membersOnly", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.membersOnly", "false");
}
if (nonanonymous != null && !nonanonymous.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.canAnyoneDiscoverJID", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.canAnyoneDiscoverJID", "false");
}
if (allowInvites != null && !allowInvites.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.canOccupantsInvite", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.canOccupantsInvite", "false");
}
if (changeSubject != null && !changeSubject.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.canOccupantsChangeSubject", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.canOccupantsChangeSubject", "false");
}
if (reservedNick != null && !reservedNick.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.loginRestrictedToNickname", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.loginRestrictedToNickname", "false");
}
if (canChangeNick != null && !canChangeNick.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.canChangeNickname", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.canChangeNickname", "false");
}
if (registrationEnabled != null && !registrationEnabled.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.registrationEnabled", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.registrationEnabled", "false");
}
if (enableLog != null && !enableLog.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.logEnabled", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.logEnabled", "false");
}
if (preserveHistOnRoomDeletion != null && !preserveHistOnRoomDeletion.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.preserveHistOnRoomDeletion", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.preserveHistOnRoomDeletion", "false");
}
if (broadcastModerator != null && !broadcastModerator.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.broadcastModerator", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.broadcastModerator", "false");
}
if (broadcastParticipant != null && !broadcastParticipant.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.broadcastParticipant", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.broadcastParticipant", "false");
}
if (broadcastVisitor != null && !broadcastVisitor.trim().isEmpty()) {
MUCPersistenceManager.setProperty(mucname, "room.broadcastVisitor", "true");
}
else {
MUCPersistenceManager.setProperty(mucname, "room.broadcastVisitor", "false");
}
}
response.sendRedirect("muc-default-settings.jsp?success=true&mucname="+URLEncoder.encode(mucname, StandardCharsets.UTF_8));
return;
}
pageContext.setAttribute("errors", errors);
pageContext.setAttribute("success", success);
pageContext.setAttribute("mucname", mucname);
pageContext.setAttribute("publicRoom", MUCPersistenceManager.getBooleanProperty(mucname, "room.publicRoom", true));
pageContext.setAttribute("persistent", MUCPersistenceManager.getBooleanProperty(mucname, "room.persistent", false));
pageContext.setAttribute("retireOnDeletion", MUCPersistenceManager.getBooleanProperty(mucname, "room.retireOnDeletion", false));
pageContext.setAttribute("moderated", MUCPersistenceManager.getBooleanProperty(mucname, "room.moderated", false));
pageContext.setAttribute("membersOnly", MUCPersistenceManager.getBooleanProperty(mucname, "room.membersOnly", false));
pageContext.setAttribute("canAnyoneDiscoverJID", MUCPersistenceManager.getBooleanProperty(mucname, "room.canAnyoneDiscoverJID", true));
pageContext.setAttribute("canOccupantsInvite", MUCPersistenceManager.getBooleanProperty(mucname, "room.canOccupantsInvite", false));
pageContext.setAttribute("canOccupantsChangeSubject", MUCPersistenceManager.getBooleanProperty(mucname, "room.canOccupantsChangeSubject", false));
pageContext.setAttribute("loginRestrictedToNickname", MUCPersistenceManager.getBooleanProperty(mucname, "room.loginRestrictedToNickname", false));
pageContext.setAttribute("canChangeNickname", MUCPersistenceManager.getBooleanProperty(mucname, "room.canChangeNickname", true));
pageContext.setAttribute("registrationEnabled", MUCPersistenceManager.getBooleanProperty(mucname, "room.registrationEnabled", true));
pageContext.setAttribute("logEnabled", MUCPersistenceManager.getBooleanProperty(mucname, "room.logEnabled", true));
pageContext.setAttribute("preserveHistOnRoomDeletion", MUCPersistenceManager.getBooleanProperty(mucname, "room.preserveHistOnRoomDeletion", true));
pageContext.setAttribute("maxUsers", MUCPersistenceManager.getIntProperty(mucname, "room.maxUsers", 30));
pageContext.setAttribute("broadcastModerator", MUCPersistenceManager.getBooleanProperty(mucname, "room.broadcastModerator", true));
pageContext.setAttribute("broadcastParticipant", MUCPersistenceManager.getBooleanProperty(mucname, "room.broadcastParticipant", true));
pageContext.setAttribute("broadcastVisitor", MUCPersistenceManager.getBooleanProperty(mucname, "room.broadcastVisitor", true));
pageContext.setAttribute("allowpm", MUCPersistenceManager.getProperty(mucname, "room.allowpm", "anyone"));
pageContext.setAttribute("xxx", MUCPersistenceManager.getBooleanProperty(mucname, "room.xxx", true));
pageContext.setAttribute("xxx", MUCPersistenceManager.getBooleanProperty(mucname, "room.xxx", true));
pageContext.setAttribute("xxx", MUCPersistenceManager.getBooleanProperty(mucname, "room.xxx", true));
%>