Commit 6cadc939 authored by Ian Green's avatar Ian Green Committed by Guus der Kinderen

OF-35 Adding Node Configuration page and Service Configuration page

* Page for editing node configuration, uses existing configuration form
  mechanism.
* Form UI is generated from the Data Form.
* Node edit page does not work with PEP service, so node summary page has
  been configured to not show edit options when viewing a PEP node.
* page for editing service configuration, also based on a Data form so
  code can be re-used.
parent 9217686a
...@@ -553,6 +553,8 @@ tab.server.descr=Click to manage server settings ...@@ -553,6 +553,8 @@ tab.server.descr=Click to manage server settings
sidebar.media-proxy=Media Proxy sidebar.media-proxy=Media Proxy
sidebar.media-proxy.descr=Click to view media proxy settings. sidebar.media-proxy.descr=Click to view media proxy settings.
sidebar.sidebar-pubsub=PubSub sidebar.sidebar-pubsub=PubSub
sidebar.pubsub-service-summary=PubSub Service
sidebar.pubsub-service-summary.descr=Click to manage PubSub service
sidebar.pubsub-node-summary=Node Summary sidebar.pubsub-node-summary=Node Summary
sidebar.pubsub-node-summary.descr=Click to manage PubSub nodes sidebar.pubsub-node-summary.descr=Click to manage PubSub nodes
sidebar.sidebar-node-options=Node Options sidebar.sidebar-node-options=Node Options
...@@ -562,6 +564,8 @@ tab.server.descr=Click to manage server settings ...@@ -562,6 +564,8 @@ tab.server.descr=Click to manage server settings
sidebar.pubsub-node-affiliates.descr=Click to view the node affiliates sidebar.pubsub-node-affiliates.descr=Click to view the node affiliates
sidebar.pubsub-node-subscribers=Node Subscribers sidebar.pubsub-node-subscribers=Node Subscribers
sidebar.pubsub-node-subscribers.descr=Click to view the node's subscribers sidebar.pubsub-node-subscribers.descr=Click to view the node's subscribers
sidebar.pubsub-node-edit=Edit Node
sidebar.pubsub-node-edit.descr=Click to edit the node
sidebar.pubsub-node-delete=Delete Node sidebar.pubsub-node-delete=Delete Node
sidebar.pubsub-node-delete.descr=Click to delete the node sidebar.pubsub-node-delete.descr=Click to delete the node
tab.tab-users=Users/Groups tab.tab-users=Users/Groups
...@@ -851,6 +855,7 @@ global.unlimited=Unlimited ...@@ -851,6 +855,7 @@ global.unlimited=Unlimited
global.test=Test global.test=Test
global.click_test=Click to test... global.click_test=Click to test...
global.csrf.failed=CSRF Error: No changes made, you'll need to retry. global.csrf.failed=CSRF Error: No changes made, you'll need to retry.
global.update=Update
# Group Chat Service Properties Page # Group Chat Service Properties Page
...@@ -2660,6 +2665,7 @@ pubsub.node.summary.sorted_id=Sorted by Node ID ...@@ -2660,6 +2665,7 @@ pubsub.node.summary.sorted_id=Sorted by Node ID
pubsub.node.summary.id=Node ID pubsub.node.summary.id=Node ID
pubsub.node.summary.name=Name pubsub.node.summary.name=Name
pubsub.node.summary.description=Description pubsub.node.summary.description=Description
pubsub.node.summary.creator=Creator
pubsub.node.summary.items=Items pubsub.node.summary.items=Items
pubsub.node.summary.affiliates=Affiliates pubsub.node.summary.affiliates=Affiliates
pubsub.node.summary.subscribers=Subscribers pubsub.node.summary.subscribers=Subscribers
...@@ -2671,6 +2677,18 @@ pubsub.node.summary.modified=Last Modified ...@@ -2671,6 +2677,18 @@ pubsub.node.summary.modified=Last Modified
pubsub.node.summary.deleted=Node deleted successfully pubsub.node.summary.deleted=Node deleted successfully
# PubSub Edit Node
pubsub.node.edit.title=Edit Node
pubsub.node.edit.info=Use the form to edit configuration for node
pubsub.node.edit.details_title=Details
pubsub.node.edit.updated=Node configuration successfully updated
pubsub.node.edit.detail.roster_groups_allowed=This information is only used when using the 'Roster' access model.
pubsub.node.edit.detail.owner=Users with owner permission on the node.
pubsub.node.edit.detail.publisher=Users with publisher permission on the node.
# PubSub Delete Node # PubSub Delete Node
pubsub.node.delete.title=Delete Node pubsub.node.delete.title=Delete Node
...@@ -2705,7 +2723,6 @@ pubsub.node.affiliates.table.no_affiliates=The Node has no affiliates. ...@@ -2705,7 +2723,6 @@ pubsub.node.affiliates.table.no_affiliates=The Node has no affiliates.
pubsub.node.affiliates.deleted=Deleted affiliation with {0} from the node. pubsub.node.affiliates.deleted=Deleted affiliation with {0} from the node.
pubsub.node.affiliates.updated=Updated affiliation for {0}. pubsub.node.affiliates.updated=Updated affiliation for {0}.
pubsub.node.affiliates.delete.title=Delete Affiliate pubsub.node.affiliates.delete.title=Delete Affiliate
pubsub.node.affiliates.delete.info=Affiliation details: pubsub.node.affiliates.delete.info=Affiliation details:
pubsub.node.affiliates.delete.info2=Current subscriptions for this affiliation (These will also be deleted): pubsub.node.affiliates.delete.info2=Current subscriptions for this affiliation (These will also be deleted):
...@@ -2732,6 +2749,41 @@ pubsub.node.subscribers.table.info=Current node subscribers are listed in the fo ...@@ -2732,6 +2749,41 @@ pubsub.node.subscribers.table.info=Current node subscribers are listed in the fo
pubsub.node.subscribers.table.no_subscribers=The Node has no subscribers. pubsub.node.subscribers.table.no_subscribers=The Node has no subscribers.
pubsub.node.subscribers.deleted=Deleted subscription owned by {0} from the node. pubsub.node.subscribers.deleted=Deleted subscription owned by {0} from the node.
# PubSub service tab
pubsub.service.summary.title=PubSub Service Configuration
pubsub.service.summary.updated=Service configuration updated successfully
pubsub.service.summary.info=Use the form below to update service settings.
pubsub.service.form.serviceEnabled=Service Enabled
pubsub.service.form.multipleSubscriptionsEnabled=Multiple Subscriptions Enabled
pubsub.service.form.detail.multipleSubscriptionsEnabled=Flag that indicates if a user may have more than one subscription with the node. When multiple subscriptions is enabled each subscription request, event notification and unsubscription request should include a subid attribute.
pubsub.service.form.nodeCreationRestricted=Node Creation Restricted
pubsub.service.form.detail.nodeCreationRestricted=A true value means that not anyone can create a node, only the JIDs listed in 'Allowed to Create' are allowed to create nodes.
pubsub.service.form.allowedToCreate=Allowed to Create
pubsub.service.form.detail.allowedToCreate=Users that are allowed to create nodes. An empty list means that anyone can create nodes.
pubsub.service.form.sysadmins=System Administrators
pubsub.service.form.detail.sysadmins=Users that are system administrators of the PubSub service. A sysadmin has the same permissions as a node owner.
# PubSub generated form
pubsub.form.clearSelection=Clear Selection
pubsub.form.group=Group
pubsub.form.user=User
pubsub.form.not_valid="{0}" is not a valid {1}.
pubsub.form.already_in_list={0} "{1}" already in list.
pubsub.form.no_data=No values set
pubsub.form.add=Add {0}:
# Plugins Admin Page # Plugins Admin Page
plugin.admin.title=Plugins plugin.admin.title=Plugins
......
...@@ -1043,6 +1043,8 @@ public abstract class Node { ...@@ -1043,6 +1043,8 @@ public abstract class Node {
if (isEditing) { if (isEditing) {
formField.setType(FormField.Type.list_single); formField.setType(FormField.Type.list_single);
formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.itemreply")); formField.setLabel(LocaleUtils.getLocalizedString("pubsub.form.conf.itemreply"));
formField.addOption(null, ItemReplyPolicy.owner.name());
formField.addOption(null, ItemReplyPolicy.publisher.name());
} }
if (replyPolicy != null) { if (replyPolicy != null) {
formField.addValue(replyPolicy.name()); formField.addValue(replyPolicy.name());
......
...@@ -315,17 +315,27 @@ public class PubSubModule extends BasicModule implements ServerItemsProvider, Di ...@@ -315,17 +315,27 @@ public class PubSubModule extends BasicModule implements ServerItemsProvider, Di
return sysadmins; return sysadmins;
} }
public void setSysadmins(Collection<String> userJIDs) {
sysadmins.clear();
for (String JID : userJIDs) {
sysadmins.add(JID.trim().toLowerCase());
}
updateSysadminProperty();
}
public void addSysadmin(String userJID) { public void addSysadmin(String userJID) {
sysadmins.add(userJID.trim().toLowerCase()); sysadmins.add(userJID.trim().toLowerCase());
// Update the config. // Update the config.
String[] jids = new String[sysadmins.size()]; updateSysadminProperty();
jids = sysadmins.toArray(jids);
JiveGlobals.setProperty("xmpp.pubsub.sysadmin.jid", fromArray(jids));
} }
public void removeSysadmin(String userJID) { public void removeSysadmin(String userJID) {
sysadmins.remove(userJID.trim().toLowerCase()); sysadmins.remove(userJID.trim().toLowerCase());
// Update the config. // Update the config.
updateSysadminProperty();
}
private void updateSysadminProperty() {
String[] jids = new String[sysadmins.size()]; String[] jids = new String[sysadmins.size()];
jids = sysadmins.toArray(jids); jids = sysadmins.toArray(jids);
JiveGlobals.setProperty("xmpp.pubsub.sysadmin.jid", fromArray(jids)); JiveGlobals.setProperty("xmpp.pubsub.sysadmin.jid", fromArray(jids));
...@@ -345,19 +355,29 @@ public class PubSubModule extends BasicModule implements ServerItemsProvider, Di ...@@ -345,19 +355,29 @@ public class PubSubModule extends BasicModule implements ServerItemsProvider, Di
JiveGlobals.setProperty("xmpp.pubsub.create.anyone", Boolean.toString(nodeCreationRestricted)); JiveGlobals.setProperty("xmpp.pubsub.create.anyone", Boolean.toString(nodeCreationRestricted));
} }
public void setUserAllowedToCreate(Collection<String> userJIDs) {
allowedToCreate.clear();
for (String JID : userJIDs) {
allowedToCreate.add(JID.trim().toLowerCase());
}
updateUserAllowedToCreateProperty();
}
public void addUserAllowedToCreate(String userJID) { public void addUserAllowedToCreate(String userJID) {
// Update the list of allowed JIDs to create nodes. // Update the list of allowed JIDs to create nodes.
allowedToCreate.add(userJID.trim().toLowerCase()); allowedToCreate.add(userJID.trim().toLowerCase());
// Update the config. // Update the config.
String[] jids = new String[allowedToCreate.size()]; updateUserAllowedToCreateProperty();
jids = allowedToCreate.toArray(jids);
JiveGlobals.setProperty("xmpp.pubsub.create.jid", fromArray(jids));
} }
public void removeUserAllowedToCreate(String userJID) { public void removeUserAllowedToCreate(String userJID) {
// Update the list of allowed JIDs to create nodes. // Update the list of allowed JIDs to create nodes.
allowedToCreate.remove(userJID.trim().toLowerCase()); allowedToCreate.remove(userJID.trim().toLowerCase());
// Update the config. // Update the config.
updateUserAllowedToCreateProperty();
}
private void updateUserAllowedToCreateProperty() {
String[] jids = new String[allowedToCreate.size()]; String[] jids = new String[allowedToCreate.size()];
jids = allowedToCreate.toArray(jids); jids = allowedToCreate.toArray(jids);
JiveGlobals.setProperty("xmpp.pubsub.create.jid", fromArray(jids)); JiveGlobals.setProperty("xmpp.pubsub.create.jid", fromArray(jids));
......
...@@ -285,6 +285,12 @@ ...@@ -285,6 +285,12 @@
<!-- PubSub Node Administration --> <!-- PubSub Node Administration -->
<sidebar id="sidebar-pubsub" name="${sidebar.sidebar-pubsub}"> <sidebar id="sidebar-pubsub" name="${sidebar.sidebar-pubsub}">
<!-- PubSub Service -->
<item id="pubsub-service-summary" name="${sidebar.pubsub-service-summary}"
url="pubsub-service-summary.jsp"
description="${sidebar.pubsub-service-summary.descr}"/>
<!-- PubSub Node Summary --> <!-- PubSub Node Summary -->
<item id="pubsub-node-summary" name="${sidebar.pubsub-node-summary}" <item id="pubsub-node-summary" name="${sidebar.pubsub-node-summary}"
url="pubsub-node-summary.jsp" url="pubsub-node-summary.jsp"
...@@ -308,6 +314,11 @@ ...@@ -308,6 +314,11 @@
url="pubsub-node-subscribers.jsp" url="pubsub-node-subscribers.jsp"
description="${sidebar.pubsub-node-subscribers.descr}"/> description="${sidebar.pubsub-node-subscribers.descr}"/>
<!-- Edit Node -->
<item id="pubsub-node-edit" name="${sidebar.pubsub-node-edit}"
url="pubsub-node-edit.jsp"
description="${sidebar.pubsub-node-edit.descr}"/>
<!-- Delete Node --> <!-- Delete Node -->
<item id="pubsub-node-delete" name="${sidebar.pubsub-node-delete}" <item id="pubsub-node-delete" name="${sidebar.pubsub-node-delete}"
url="pubsub-node-delete.jsp" url="pubsub-node-delete.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"%>
<!--
Parameters:
fields - fields from a data form (needs to be set as request scope)
nonDisplayFields - a list of field names that shouldn't be displayed (needs to be set as request scope)
listTypes - a map of field.variables to listType (user or group)
errors - a map of field.variable to error strings
detailPreFix - property prefix for additional detail to be displayed against the fields on the form
-->
<script>
function clearSelected(id) {
var elements = document.getElementById(id).options;
for (var i = 0; i < elements.length; i++) {
elements[i].selected = false;
}
}
function deleteTableRow(rowId) {
var row = document.getElementById(rowId);
row.parentNode.removeChild(row);
}
function detect_enter_keyboard(event) {
var key_board_keycode = event.which || event.keyCode;
if (key_board_keycode == 13) {
event.preventDefault();
var target = event.target || event.srcElement;
var buttonId = target.id.split('-')[0] + '-Add';
document.getElementById(buttonId).click();
}
}
</script>
<c:if test="${not empty errors}">
<c:forEach var="error" items="${errors}">
<div class="jive-error">
<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"><c:out value="${error.value}" />
</td>
</tr>
</tbody>
</table>
</div>
<br>
</c:forEach>
</c:if>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<c:forEach var="field" items="${requestScope.fields}">
<c:if
test="${not requestScope.nonDisplayFields.contains(field.variable)}">
<tr>
<td nowrap width="1%"><label for="${field.variable}">${field.label}</label></td>
<c:set var="isList"
value="${field.type.name() eq 'list_multi' or field.type.name() eq 'jid_multi'}" />
<c:choose>
<c:when test="${field.type.name() eq 'boolean_type'}">
<td width="1%" colspan="2"><input type="checkbox"
name="${field.variable}" id="${field.variable}"
${field.firstValue == 1 ? 'checked="checked"' : '' } />
</td>
</c:when>
<c:when test="${field.type.name() eq 'text_single'}">
<td width="1%" colspan="2"><input type="text"
name="${field.variable}" id="${field.variable}"
value="${field.firstValue}" style="width: 200px;" /></td>
</c:when>
<c:when test="${field.type.name() eq 'list_single'}">
<td width="1%" colspan="2"><select name="${field.variable}"
id="${field.variable}" style="width: 200px;">
<c:forEach var="option" items="${field.options}">
<option value="${option.value}"
${option.value == field.firstValue ? 'selected' : '' }>
${option.label ? option.label : option.value }
</option>
</c:forEach>
</select></td>
</c:when>
<c:when test="${isList and not empty field.options}">
<td width="1%" colspan="2"><select name="${field.variable}"
id="${field.variable}" style="width: 200px;" multiple>
<c:forEach var="option" items="${field.options}">
<option value="${option.value}"
${ field.values.contains(option.value) ? 'selected' : '' }>
${option.label ? option.label : option.value }
</option>
</c:forEach>
</select>
<button type="button"
onclick="clearSelected('${field.variable}')">
<fmt:message key="pubsub.form.clearSelection" />
</button></td>
</c:when>
<c:when test="${isList and empty field.options}">
<td>
<div class="jive-table">
<table id="${field.variable}" cellpadding="0" cellspacing="0"
border="0" width="100%">
<thead>
<tr>
<th scope="col">value</th>
<th scope="col">remove</th>
</tr>
</thead>
<tbody>
<c:if test="${empty field.values}">
<tr>
<td align="center" colspan="2"><fmt:message
key="pubsub.form.no_data" /></td>
</tr>
</c:if>
<c:forEach var="value" items="${field.values}"
varStatus="loop">
<tr id="${field.variable}${loop.index}">
<td><input type="hidden" name="${field.variable}"
value="${value}" />${value}</td>
<td>
<button type="button"
onclick="deleteTableRow('${field.variable}${loop.index}')">Remove</button>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</td>
<td><fmt:message var="paramVal"
key="pubsub.form.${listTypes[field.variable]}" /> <fmt:message
key="pubsub.form.add">
<fmt:param value="${paramVal}" />
</fmt:message> <br> <input type="text" size="45"
id="${field.variable}-Additional"
name="${field.variable}-Additional"
onkeypress="detect_enter_keyboard(event)" /> <br> <input
type="submit" id="${field.variable}-Add"
name="${field.variable}-Add"
value="<fmt:message key="global.add" />"></td>
</c:when>
</c:choose>
<td><fmt:message var="detail"
key="${param.detailPreFix}.${fn:substringAfter(field.variable, '#')}" />
<c:if test="${not fn:startsWith(detail, '???')}">
<c:out value="${detail}" />
</c:if></td>
</tr>
</c:if>
</c:forEach>
</tbody>
</table>
\ No newline at end of file
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.openfire.group.Group,
org.jivesoftware.openfire.pubsub.Node,
org.jivesoftware.openfire.pubsub.LeafNode,
org.jivesoftware.openfire.pubsub.PubSubServiceInfo,
org.jivesoftware.openfire.pubsub.PubSubServiceInfo.listType,
org.jivesoftware.openfire.user.User,
org.xmpp.forms.DataForm,
org.xmpp.forms.FormField,
org.xmpp.forms.FormField.Type,
org.xmpp.packet.JID,
java.net.URLEncoder,
java.util.*"
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" %>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters //
boolean cancel = ParamUtils.getParameter(request,"cancel") != null;
boolean update = ParamUtils.getParameter(request,"update") != null;
Cookie csrfCookie = CookieUtils.getCookie(request, "csrf");
String csrfParam = ParamUtils.getParameter(request, "csrf");
boolean formSubmitted = false;
if (csrfParam != null) {
formSubmitted = true;
}
if (update) {
if (csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals(csrfParam)) {
update = false;
}
}
csrfParam = StringUtils.randomString(15);
CookieUtils.setCookie(request, response, "csrf", csrfParam, -1);
pageContext.setAttribute("csrf", csrfParam);
String nodeID = ParamUtils.getParameter(request,"nodeID");
String reason = ParamUtils.getParameter(request,"reason");
// Handle a cancel
if (cancel) {
response.sendRedirect("pubsub-node-summary.jsp");
return;
}
final PubSubServiceInfo pubSubServiceInfo = webManager.getPubSubInfo();
// Load the node object
Node node = pubSubServiceInfo.getNode(nodeID);
DataForm form = ((LeafNode) node).getConfigurationForm();
//Field that will not be returned to the server, i.e. cannot be edited on this page
ArrayList<String> nonReturnFields = new ArrayList<String>();
//This is the parent collection, this form is not a great way to edit this,
//and the back end has issues when the root Collection is the parent.
nonReturnFields.add("pubsub#collection");
//owner and publishers are more easily managed through the affiliates admin pages
nonReturnFields.add("pubsub#owner");
nonReturnFields.add("pubsub#publisher");
//replyto and replyroom were removed from XEP-60 at version 1.13
nonReturnFields.add("pubsub#replyto");
nonReturnFields.add("pubsub#replyroom");
//nodes that will not be displayed in the form.
ArrayList<String> nonDisplayFields = new ArrayList<String>();
//changing nodes from leaf to collection is a bad idea, but the value is required in the returned form.
nonDisplayFields.add("pubsub#node_type");
//fields not being returned are not shown
nonDisplayFields.addAll(nonReturnFields);
// Handle update:
if (update) {
// Delete the node
if (node != null) {
node.configure(pubSubServiceInfo.processForm(form, request, nonReturnFields));
// Log the event
webManager.logEvent("Configuration updated for " + nodeID, null);
}
// Done, so redirect
response.sendRedirect("pubsub-node-edit.jsp?nodeID=" + nodeID + "&updateSuccess=true");
return;
}
if (formSubmitted) {
form = pubSubServiceInfo.processForm(form, request, nonReturnFields);
}
Map<String,listType> listTypes = new HashMap<>();
listTypes.put("pubsub#contact", listType.user);
listTypes.put("pubsub#replyto", listType.user);
listTypes.put("pubsub#roster_groups_allowed", listType.group);
Map<String,String> errors = new HashMap<>();
pubSubServiceInfo.validateAdditions(form, request, listTypes, errors);
pageContext.setAttribute("node", node);
pageContext.setAttribute("fields", form.getFields());
pageContext.setAttribute("nonDisplayFields", nonDisplayFields);
pageContext.setAttribute("listTypes", listTypes);
pageContext.setAttribute("errors", errors);
%>
<html>
<head>
<title><fmt:message key="pubsub.node.edit.title"/></title>
<meta name="subPageID" content="pubsub-node-edit"/>
<meta name="extraParams" content="nodeID=${node.nodeID}"/>
<script>
function clearSelected(name){
var elements = document.getElementById(name).options;
for(var i = 0; i < elements.length; i++){
elements[i].selected = false;
}
}
</script>
</head>
<body>
<p>
<fmt:message key="pubsub.node.edit.info" />
<b>
<c:out value="${node.nodeID}"/>
</b>
</p>
<c:if test="${param.updateSuccess}">
<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="pubsub.node.edit.updated" />
</td></tr>
</tbody>
</table>
</div><br>
</c:if>
<div class="jive-table">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th scope="col"><fmt:message key="pubsub.node.summary.id" /></th>
<th scope="col"><fmt:message key="pubsub.node.summary.creator" /></th>
<th scope="col"><fmt:message key="pubsub.node.summary.items" /></th>
<th scope="col"><fmt:message key="pubsub.node.summary.affiliates" /></th>
<th scope="col"><fmt:message key="pubsub.node.summary.subscribers" /></th>
<th scope="col"><fmt:message key="pubsub.node.summary.created" /></th>
<th scope="col"><fmt:message key="pubsub.node.summary.modified" /></th>
</tr>
</thead>
<tbody>
<tr>
<td><c:out value="${node.getNodeID()}"/></td>
<td><c:out value="${node.getCreator()}"/></td>
<td><c:out value="${node.getPublishedItems().size()}"/></td>
<td><c:out value="${node.getAllAffiliates().size()}"/></td>
<td><c:out value="${node.getAllSubscriptions().size()}"/></td>
<td><fmt:formatDate type="both" dateStyle="medium" timeStyle="short" value="${node.getCreationDate()}" /></td>
<td><fmt:formatDate type="both" dateStyle="medium" timeStyle="short" value="${node.getModificationDate()}" /></td>
</tr>
</tbody>
</table>
</div>
<form action="pubsub-node-edit.jsp">
<input type="hidden" name="csrf" value="${csrf}">
<input type="hidden" name="nodeID" value="${node.nodeID}">
<br>
<fieldset>
<legend><fmt:message key="pubsub.node.edit.details_title" /></legend>
<div>
<c:set var="fields" value="${fields}" scope="request"/>
<c:set var="nonDisplayFields" value="${nonDisplayFields}" scope="request"/>
<c:set var="listTypes" value="${listTypes}" scope="request"/>
<c:set var="errors" value="${errors}" scope="request"/>
<c:import url="pubsub-form-table.jsp">
<c:param name="detailPreFix" value ="pubsub.node.edit.detail"/>
</c:import>
</div>
</fieldset>
<br>
<input type="submit" name="update" value="<fmt:message key="global.update" />">
<input type="submit" name="cancel" value="<fmt:message key="global.cancel" />">
</form>
</body>
</html>
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
webManager.setRowsPerPage("pubsub-node-summary", range); webManager.setRowsPerPage("pubsub-node-summary", range);
} }
boolean PEPMode = false;
PubSubServiceInfo pubSubServiceInfo; PubSubServiceInfo pubSubServiceInfo;
if ( owner == null ) if ( owner == null )
{ {
...@@ -51,6 +52,7 @@ ...@@ -51,6 +52,7 @@
} }
else if ( new PEPServiceManager().getPEPService( owner.toBareJID() ) != null ) else if ( new PEPServiceManager().getPEPService( owner.toBareJID() ) != null )
{ {
PEPMode = true;
pubSubServiceInfo = new PEPServiceInfo( owner ); pubSubServiceInfo = new PEPServiceInfo( owner );
} }
else else
...@@ -94,6 +96,7 @@ ...@@ -94,6 +96,7 @@
pageContext.setAttribute("maxNodeIndex", maxNodeIndex); pageContext.setAttribute("maxNodeIndex", maxNodeIndex);
pageContext.setAttribute("nodes", nodes.subList(start, maxNodeIndex)); pageContext.setAttribute("nodes", nodes.subList(start, maxNodeIndex));
pageContext.setAttribute("owner", owner ); pageContext.setAttribute("owner", owner );
pageContext.setAttribute("PEPMode", PEPMode);
%> %>
<html> <html>
...@@ -171,6 +174,9 @@ ...@@ -171,6 +174,9 @@
<th nowrap><fmt:message key="pubsub.node.summary.items" /></th> <th nowrap><fmt:message key="pubsub.node.summary.items" /></th>
<th nowrap><fmt:message key="pubsub.node.summary.affiliates" /></th> <th nowrap><fmt:message key="pubsub.node.summary.affiliates" /></th>
<th nowrap><fmt:message key="pubsub.node.summary.subscribers" /></th> <th nowrap><fmt:message key="pubsub.node.summary.subscribers" /></th>
<c:if test="${not PEPMode}" >
<th nowrap><fmt:message key="global.edit" /></th>
</c:if>
<th nowrap><fmt:message key="global.delete" /></th> <th nowrap><fmt:message key="global.delete" /></th>
</tr> </tr>
</thead> </thead>
...@@ -178,7 +184,7 @@ ...@@ -178,7 +184,7 @@
<c:if test="${nodeCount lt 1}"> <c:if test="${nodeCount lt 1}">
<tr> <tr>
<td align="center" colspan="7"> <td align="center" colspan="${PEPMode ? 8 : 9}">
<fmt:message key="pubsub.node.summary.table.no_nodes" /> <fmt:message key="pubsub.node.summary.table.no_nodes" />
</td> </td>
</tr> </tr>
...@@ -226,6 +232,16 @@ ...@@ -226,6 +232,16 @@
<c:out value="${node.getAllSubscriptions().size()}" /> <c:out value="${node.getAllSubscriptions().size()}" />
</a> </a>
</td> </td>
<c:if test="${not PEPMode}" >
<td width="1%" align="center">
<c:url value="pubsub-node-edit.jsp" var="url">
<c:param name="nodeID" value="${node.getNodeID()}" />
</c:url>
<a href="${url}" title="<fmt:message key="global.click_edit" />">
<img src="images/edit-16x16.gif" width="16" height="16" border="0" alt="">
</a>
</td>
</c:if>
<td width="1%" align="center" style="border-right:1px #ccc solid;"> <td width="1%" align="center" style="border-right:1px #ccc solid;">
<c:url value="pubsub-node-delete.jsp" var="url"> <c:url value="pubsub-node-delete.jsp" var="url">
<c:param name="nodeID" value="${node.getNodeID()}" /> <c:param name="nodeID" value="${node.getNodeID()}" />
......
<%@ page import="org.jivesoftware.util.*,
org.jivesoftware.openfire.pubsub.Node,
org.jivesoftware.openfire.pubsub.PubSubServiceInfo,
org.jivesoftware.openfire.pubsub.PubSubServiceInfo.listType,
org.xmpp.forms.DataForm,
org.xmpp.forms.FormField,
org.xmpp.forms.FormField.Type,
java.net.URLEncoder,
java.util.*"
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" %>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %>
<% // Get parameters //
boolean cancel = ParamUtils.getParameter(request,"cancel") != null;
boolean update = ParamUtils.getParameter(request,"update") != null;
Cookie csrfCookie = CookieUtils.getCookie(request, "csrf");
String csrfParam = ParamUtils.getParameter(request, "csrf");
boolean formSubmitted = false;
if (csrfParam != null) {
formSubmitted = true;
}
if (update) {
if (csrfCookie == null || csrfParam == null || !csrfCookie.getValue().equals(csrfParam)) {
update = false;
}
}
csrfParam = StringUtils.randomString(15);
CookieUtils.setCookie(request, response, "csrf", csrfParam, -1);
pageContext.setAttribute("csrf", csrfParam);
// Handle a cancel
if (cancel) {
response.sendRedirect("pubsub-node-summary.jsp");
return;
}
final PubSubServiceInfo pubSubServiceInfo = webManager.getPubSubInfo();
DataForm form = pubSubServiceInfo.getServiceConfigurationForm();
// Handle a service update:
if (update) {
pubSubServiceInfo.configureService(pubSubServiceInfo.processForm(form, request, null));
// Done, so redirect
response.sendRedirect("pubsub-service-summary.jsp?updateSuccess=true");
return;
}
if (formSubmitted) {
form = pubSubServiceInfo.processForm(form, request, null);
}
Map<String,listType> listTypes = new HashMap<>();
listTypes.put("pubsub#allowedToCreate", listType.user);
listTypes.put("pubsub#sysadmins", listType.user);
Map<String,String> errors = new HashMap<>();
pubSubServiceInfo.validateAdditions(form, request, listTypes, errors);
pageContext.setAttribute("fields", form.getFields());
pageContext.setAttribute("listTypes", listTypes);
pageContext.setAttribute("errors", errors);
%>
<html>
<head>
<title><fmt:message key="pubsub.service.summary.title"/></title>
<meta name="pageID" content="pubsub-service-summary"/>
</head>
<body>
<p>
<fmt:message key="pubsub.service.summary.info" />
</p>
<c:if test="${param.updateSuccess}">
<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="pubsub.service.summary.updated" />
</td></tr>
</tbody>
</table>
</div><br>
</c:if>
<form action="pubsub-service-summary.jsp">
<input type="hidden" name="csrf" value="${csrf}">
<fieldset>
<legend><fmt:message key="pubsub.node.delete.details_title" /></legend>
<div>
<c:set var="fields" value="${fields}" scope="request"/>
<c:set var="listTypes" value="${listTypes}" scope="request"/>
<c:set var="errors" value="${errors}" scope="request"/>
<c:import url="pubsub-form-table.jsp">
<c:param name="detailPreFix" value ="pubsub.service.form.detail"/>
</c:import>
</div>
</fieldset>
<br><br>
<input type="submit" name="update" value="<fmt:message key="global.update" />">
<input type="submit" name="cancel" value="<fmt:message key="global.cancel" />">
</form>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment