Commit bd06fdaa authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Group Edit Admin


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@806 b35dd754-fafc-0310-a699-88a17e54d16e
parent dc032158
...@@ -22,7 +22,8 @@ import ="org.jivesoftware.util.*, ...@@ -22,7 +22,8 @@ import ="org.jivesoftware.util.*,
java.io.PrintStream, java.io.PrintStream,
org.dom4j.xpath.DefaultXPath, org.dom4j.xpath.DefaultXPath,
org.dom4j.*, org.dom4j.*,
org.jivesoftware.messenger.group.*" org.jivesoftware.messenger.group.*,
java.net.URLEncoder"
errorPage="error.jsp"%> errorPage="error.jsp"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/> <jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/>
...@@ -35,7 +36,7 @@ errorPage="error.jsp"%> ...@@ -35,7 +36,7 @@ errorPage="error.jsp"%>
boolean cancel = request.getParameter("cancel") != null; boolean cancel = request.getParameter("cancel") != null;
String name = ParamUtils.getParameter(request, "name"); String name = ParamUtils.getParameter(request, "name");
String description = ParamUtils.getParameter(request, "description"); String description = ParamUtils.getParameter(request, "description");
String users = ParamUtils.getParameter(request, "users"); String users = ParamUtils.getParameter(request, "users", true);
// Handle a cancel // Handle a cancel
if (cancel) { if (cancel) {
response.sendRedirect("group-summary.jsp"); response.sendRedirect("group-summary.jsp");
...@@ -54,18 +55,21 @@ errorPage="error.jsp"%> ...@@ -54,18 +55,21 @@ errorPage="error.jsp"%>
if (description != null) { if (description != null) {
newGroup.setDescription(description); newGroup.setDescription(description);
} }
String hostName = webManager.getXMPPServer().getServerInfo().getName();
StringTokenizer tokenizer = new StringTokenizer(users, ","); if(users.length() > 0){
while (tokenizer.hasMoreTokens()) { String hostName = webManager.getXMPPServer().getServerInfo().getName();
String tok = tokenizer.nextToken(); StringTokenizer tokenizer = new StringTokenizer(users, ",");
String address = tok; while (tokenizer.hasMoreTokens()) {
if (address.indexOf("@") == -1) { String tok = tokenizer.nextToken();
address = address + "@" + hostName; String address = tok;
if (address.indexOf("@") == -1) {
address = address + "@" + hostName;
}
newGroup.getMembers().add(address);
} }
newGroup.getMembers().add(address);
} }
// Successful, so redirect // Successful, so redirect
response.sendRedirect("group-properties.jsp?success=true&group=" + newGroup.getName()); response.sendRedirect("group-properties.jsp?success=true&group=" + URLEncoder.encode(newGroup.getName(), "UTF-8"));
return; return;
} }
catch (GroupAlreadyExistsException e) { catch (GroupAlreadyExistsException e) {
......
...@@ -6,7 +6,9 @@ import="java.text.DateFormat, ...@@ -6,7 +6,9 @@ import="java.text.DateFormat,
org.jivesoftware.admin.*, org.jivesoftware.admin.*,
org.xmpp.packet.JID, org.xmpp.packet.JID,
org.jivesoftware.messenger.group.GroupManager, org.jivesoftware.messenger.group.GroupManager,
org.jivesoftware.messenger.group.Group"%> org.jivesoftware.messenger.group.Group,
java.net.URLEncoder,
java.net.URLDecoder"%>
<!-- Define Administration Bean --> <!-- Define Administration Bean -->
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/> <jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/>
<% <%
...@@ -22,7 +24,18 @@ import="java.text.DateFormat, ...@@ -22,7 +24,18 @@ import="java.text.DateFormat,
String [] deleteMembers = ParamUtils.getParameters(request, "delete"); String [] deleteMembers = ParamUtils.getParameters(request, "delete");
String groupName = ParamUtils.getParameter(request, "group"); String groupName = ParamUtils.getParameter(request, "group");
GroupManager groupManager = webManager.getGroupManager(); GroupManager groupManager = webManager.getGroupManager();
boolean edit = ParamUtils.getBooleanParameter(request, "edit", false);
String newName = ParamUtils.getParameter(request, "newName");
Group group = groupManager.getGroup(groupName); Group group = groupManager.getGroup(groupName);
boolean nameChanged = false;
if(newName != null && newName.length() > 0){
group.setName(newName);
groupName = newName;
nameChanged = true;
}
if (update) { if (update) {
Set adminIDSet = new HashSet(); Set adminIDSet = new HashSet();
for (int i = 0; i < adminIDs.length; i++) { for (int i = 0; i < adminIDs.length; i++) {
...@@ -50,7 +63,7 @@ import="java.text.DateFormat, ...@@ -50,7 +63,7 @@ import="java.text.DateFormat,
group.getMembers().add(m); group.getMembers().add(m);
} }
// Get admin list and compare it the admin posted list. // Get admin list and compare it the admin posted list.
response.sendRedirect("group-edit-form.jsp?group=" + groupName + "&updatesuccess=true"); response.sendRedirect("group-edit.jsp?group=" + URLEncoder.encode(groupName, "UTF-8") + "&updatesuccess=true");
return; return;
} }
else if (add && users != null) { else if (add && users != null) {
...@@ -67,7 +80,7 @@ import="java.text.DateFormat, ...@@ -67,7 +80,7 @@ import="java.text.DateFormat,
group.getMembers().add(address); group.getMembers().add(address);
} }
} }
response.sendRedirect("group-edit-form.jsp?group=" + groupName + "&success=true"); response.sendRedirect("group-edit.jsp?group=" + URLEncoder.encode(groupName, "UTF-8") + "&success=true");
return; return;
} }
else if (delete) { else if (delete) {
...@@ -76,7 +89,7 @@ import="java.text.DateFormat, ...@@ -76,7 +89,7 @@ import="java.text.DateFormat,
group.getMembers().remove(member); group.getMembers().remove(member);
group.getAdmins().remove(member); group.getAdmins().remove(member);
} }
response.sendRedirect("group-edit-form.jsp?group=" + groupName + "&deletesuccess=true"); response.sendRedirect("group-edit.jsp?group=" + URLEncoder.encode(groupName, "UTF-8") + "&deletesuccess=true");
return; return;
} }
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM); DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM);
...@@ -86,9 +99,9 @@ import="java.text.DateFormat, ...@@ -86,9 +99,9 @@ import="java.text.DateFormat,
String title = "Edit Group"; String title = "Edit Group";
pageinfo.setTitle(title); pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp")); pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-edit-form.jsp")); pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-edit.jsp"));
pageinfo.setPageID("group-edit"); pageinfo.setPageID("group-summary");
pageinfo.setExtraParams("group=" + groupName); pageinfo.setExtraParams("group="+groupName);
%> %>
<jsp:include page="top.jsp" flush="true"/> <jsp:include page="top.jsp" flush="true"/>
<jsp:include page="title.jsp" flush="true"/> <jsp:include page="title.jsp" flush="true"/>
...@@ -103,6 +116,15 @@ import="java.text.DateFormat, ...@@ -103,6 +116,15 @@ import="java.text.DateFormat,
Below is a summary of properties for the group as well as admins and members. Use the forms on the page to add Below is a summary of properties for the group as well as admins and members. Use the forms on the page to add
members and optionally designate them as groups administrators. members and optionally designate them as groups administrators.
</p> </p>
<%
if (nameChanged){
%>
<p class="jive-success-text">
Name has been changed successfully.
</p>
<%
}
%>
<% <%
if ("true".equals(request.getParameter("success"))) { if ("true".equals(request.getParameter("success"))) {
%> %>
...@@ -128,30 +150,43 @@ import="java.text.DateFormat, ...@@ -128,30 +150,43 @@ import="java.text.DateFormat,
%> %>
<fieldset> <fieldset>
<legend> <legend>
User Group Summary Group Summary
</legend> </legend><form name="ff" action="group-edit.jsp">
<input type="hidden" name="group" value="<%= groupName %>"/>
<table cellpadding="3" cellspacing="1" border="0"> <table cellpadding="3" cellspacing="1" border="0">
<tr> <tr>
<td class="c1"> <td width="1%">
Name: Name:
</td> </td>
<td class="c2"> <td align=left nowrap width="1%">
<b><%= group.getName() %></b> <b><%= group.getName() %></b>
</td> </td>
</tr> <% if(!edit) { %>
<td>
<a href="group-edit.jsp?edit=true&group=<%= URLEncoder.encode(groupName, "UTF-8") %>">
<img src="images/edit-16x16.gif" border="0">
</a>
</td>
<% }else { %>
<td>
New Name:<input type="text" name="newName"><input type="submit" value="Change">
</td>
<% } %>
<tr> <tr>
<td class="c1"> <td width="1%">
Description: Description:
</td> </td>
<td class="c2"> <td colspan="3">
<%= ((group.getDescription() != null) ? group.getDescription() : "No Description") %> <%= ((group.getDescription() != null) ? group.getDescription() : "No Description") %>
</td> </td>
</tr> </tr>
</table> </table>
</fieldset> </fieldset> </form>
<br> <br>
<form action="group-edit-form.jsp" method="post" name="f"> <form action="group-edit.jsp" method="post" name="f">
<input type="hidden" name="group" value="<%= groupName %>"> <input type="hidden" name="group" value="<%= groupName %>">
<input type="hidden" name="add" value="Add"/> <input type="hidden" name="add" value="Add"/>
<table cellpadding="3" cellspacing="1" border="0"> <table cellpadding="3" cellspacing="1" border="0">
...@@ -173,7 +208,7 @@ import="java.text.DateFormat, ...@@ -173,7 +208,7 @@ import="java.text.DateFormat,
</table> </table>
</form> </form>
<form action="group-edit-form.jsp" method="post" name="main"> <form action="group-edit.jsp" method="post" name="main">
<input type="hidden" name="group" value="<%= groupName %>"> <input type="hidden" name="group" value="<%= groupName %>">
<table class="jive-table" cellpadding="3" cellspacing="0" border="0" width="600"> <table class="jive-table" cellpadding="3" cellspacing="0" border="0" width="600">
<tr> <tr>
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
org.jivesoftware.admin.*, org.jivesoftware.admin.*,
org.jivesoftware.messenger.*, org.jivesoftware.messenger.*,
org.jivesoftware.messenger.group.Group, org.jivesoftware.messenger.group.Group,
org.jivesoftware.messenger.group.GroupNotFoundException" org.jivesoftware.messenger.group.GroupNotFoundException,
java.net.URLEncoder"
errorPage="error.jsp" errorPage="error.jsp"
%> %>
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
// Handle a delete // Handle a delete
if (delete) { if (delete) {
response.sendRedirect("group-delete.jsp?group=" + groupName); response.sendRedirect("group-delete.jsp?group=" + URLEncoder.encode(groupName, "UTF-8"));
return; return;
} }
...@@ -61,7 +62,7 @@ ...@@ -61,7 +62,7 @@
String title = "Group Properties"; String title = "Group Properties";
pageinfo.setTitle(title); pageinfo.setTitle(title);
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp")); pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb("Main", "index.jsp"));
pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-properties.jsp?group="+groupName)); pageinfo.getBreadcrumbs().add(new AdminPageBean.Breadcrumb(title, "group-properties.jsp?group="+URLEncoder.encode(groupName)));
pageinfo.setSubPageID("group-properties"); pageinfo.setSubPageID("group-properties");
pageinfo.setExtraParams("group="+groupName); pageinfo.setExtraParams("group="+groupName);
%> %>
...@@ -140,8 +141,8 @@ Below is a summary of the group. To edit properties, click the "Edit" button bel ...@@ -140,8 +141,8 @@ Below is a summary of the group. To edit properties, click the "Edit" button bel
<br><br> <br><br>
<form action="group-edit-form.jsp"> <form action="group-edit.jsp">
<input type="hidden" name="group" value="<%= group.getName() %>"> <input type="hidden" name="group" value="<%= URLEncoder.encode(group.getName(), "UTF-8") %>">
<input type="submit" value="Edit Properties"> <input type="submit" value="Edit Properties">
</form> </form>
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
java.util.*, java.util.*,
java.text.DateFormat, java.text.DateFormat,
org.jivesoftware.admin.*, org.jivesoftware.admin.*,
org.jivesoftware.messenger.group.*" org.jivesoftware.messenger.group.*,
java.net.URLDecoder,
java.net.URLEncoder"
%> %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
...@@ -120,6 +122,7 @@ Total Groups: <%= webManager.getGroupManager().getGroupCount() %>, ...@@ -120,6 +122,7 @@ Total Groups: <%= webManager.getGroupManager().getGroupCount() %>,
} }
int i = start; int i = start;
for (Group group : groups) { for (Group group : groups) {
String groupName = URLEncoder.encode(group.getName(), "UTF-8");
i++; i++;
%> %>
<tr class="jive-<%= (((i%2)==0) ? "even" : "odd") %>"> <tr class="jive-<%= (((i%2)==0) ? "even" : "odd") %>">
...@@ -127,7 +130,7 @@ Total Groups: <%= webManager.getGroupManager().getGroupCount() %>, ...@@ -127,7 +130,7 @@ Total Groups: <%= webManager.getGroupManager().getGroupCount() %>,
<%= i %> <%= i %>
</td> </td>
<td width="60%"> <td width="60%">
<a href="group-properties.jsp?group=<%= group.getName() %>"><%= group.getName() %></a> <a href="group-edit.jsp?group=<%= groupName %>"><%= group.getName() %></a>
<% if (group.getDescription() != null) { %> <% if (group.getDescription() != null) { %>
<br> <br>
<span class="jive-description"> <span class="jive-description">
...@@ -142,12 +145,12 @@ Total Groups: <%= webManager.getGroupManager().getGroupCount() %>, ...@@ -142,12 +145,12 @@ Total Groups: <%= webManager.getGroupManager().getGroupCount() %>,
<%= group.getAdmins().size() %> <%= group.getAdmins().size() %>
</td> </td>
<td width="1%" align="center"> <td width="1%" align="center">
<a href="group-edit-form.jsp?group=<%= group.getName() %>" <a href="group-edit.jsp?group=<%= groupName %>"
title="Click to edit..." title="Click to edit..."
><img src="images/edit-16x16.gif" width="17" height="17" border="0"></a> ><img src="images/edit-16x16.gif" width="17" height="17" border="0"></a>
</td> </td>
<td width="1%" align="center" style="border-right:1px #ccc solid;"> <td width="1%" align="center" style="border-right:1px #ccc solid;">
<a href="group-delete.jsp?group=<%= group.getName() %>" <a href="group-delete.jsp?group=<%= groupName %>"
title="Click to delete..." title="Click to delete..."
><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a> ><img src="images/delete-16x16.gif" width="16" height="16" border="0"></a>
</td> </td>
......
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