Commit 5190e1d8 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Added ability to set display name of group in roster and to configure if the...

Added ability to set display name of group in roster and to configure if the group should be considered a shared group in members' rosters. JM-109


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@839 b35dd754-fafc-0310-a699-88a17e54d16e
parent 12ec829b
...@@ -38,6 +38,8 @@ errorPage="error.jsp"%> ...@@ -38,6 +38,8 @@ 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");
boolean showInRoster = ParamUtils.getBooleanParameter(request, "show", false);
String displayName = ParamUtils.getParameter(request, "display");
String users = ParamUtils.getParameter(request, "users", true); String users = ParamUtils.getParameter(request, "users", true);
// Handle a cancel // Handle a cancel
if (cancel) { if (cancel) {
...@@ -50,6 +52,9 @@ errorPage="error.jsp"%> ...@@ -50,6 +52,9 @@ errorPage="error.jsp"%>
if (name == null) { if (name == null) {
errors.put("name", ""); errors.put("name", "");
} }
if (showInRoster && (displayName == null || displayName.length() == 0)) {
errors.put("display", "");
}
// do a create if there were no errors // do a create if there were no errors
if (errors.size() == 0) { if (errors.size() == 0) {
try { try {
...@@ -57,6 +62,14 @@ errorPage="error.jsp"%> ...@@ -57,6 +62,14 @@ errorPage="error.jsp"%>
if (description != null) { if (description != null) {
newGroup.setDescription(description); newGroup.setDescription(description);
} }
if (showInRoster) {
newGroup.getProperties().put("showInRoster", "true");
newGroup.getProperties().put("displayName", displayName);
}
else {
newGroup.getProperties().put("showInRoster", "false");
newGroup.getProperties().put("displayName", "");
}
if(users.length() > 0){ if(users.length() > 0){
StringTokenizer tokenizer = new StringTokenizer(users, ","); StringTokenizer tokenizer = new StringTokenizer(users, ",");
...@@ -162,6 +175,29 @@ errorPage="error.jsp"%> ...@@ -162,6 +175,29 @@ errorPage="error.jsp"%>
<span class="jive-error-text"> Invalid description. </span> <span class="jive-error-text"> Invalid description. </span>
<% <%
} }
%>
</td>
</tr>
<tr>
<td width="1%" nowrap>
<label for="gshow">Show group in group members' rosters:</label>
</td>
<td width="99%">
<input type="checkbox" name="show" value="true" id="gshow"/>
</td>
</tr>
<tr>
<td nowrap width="1%">
<label for="gdisplay">Display name in roster:</label>
</td>
<td nowrap class="c1" align="left">
<input type="text" size="40" name="display" id="gdisplay"/>
<%
if (errors.get("display") != null) {
%>
<span class="jive-error-text"> Please enter a display name. </span>
<%
}
%> %>
</td> </td>
</tr> </tr>
......
...@@ -14,6 +14,7 @@ import="java.text.DateFormat, ...@@ -14,6 +14,7 @@ import="java.text.DateFormat,
org.jivesoftware.stringprep.Stringprep"%> org.jivesoftware.stringprep.Stringprep"%>
<!-- Define Administration Bean --> <!-- Define Administration Bean -->
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/> <jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"/>
<jsp:useBean id="errors" class="java.util.HashMap"/>
<% <%
webManager.init(pageContext); webManager.init(pageContext);
%> %>
...@@ -30,6 +31,8 @@ import="java.text.DateFormat, ...@@ -30,6 +31,8 @@ import="java.text.DateFormat,
boolean edit = ParamUtils.getBooleanParameter(request, "edit", false); boolean edit = ParamUtils.getBooleanParameter(request, "edit", false);
String newName = ParamUtils.getParameter(request, "newName"); String newName = ParamUtils.getParameter(request, "newName");
String newDescription = ParamUtils.getParameter(request, "newDescription"); String newDescription = ParamUtils.getParameter(request, "newDescription");
boolean newShowInRoster = ParamUtils.getBooleanParameter(request, "newShow", false);
String newDisplayName = ParamUtils.getParameter(request, "newDisplay");
boolean groupInfoChanged = ParamUtils.getBooleanParameter(request, "groupChanged", false); boolean groupInfoChanged = ParamUtils.getBooleanParameter(request, "groupChanged", false);
Group group = groupManager.getGroup(groupName); Group group = groupManager.getGroup(groupName);
...@@ -38,14 +41,31 @@ import="java.text.DateFormat, ...@@ -38,14 +41,31 @@ import="java.text.DateFormat,
if (newName != null && newName.length() > 0) { if (newName != null && newName.length() > 0) {
if (newShowInRoster && (newDisplayName == null || newDisplayName.length() == 0)) {
errors.put("display", "");
}
if (errors.isEmpty()) {
group.setName(newName); group.setName(newName);
group.setDescription(newDescription); group.setDescription(newDescription);
if (newShowInRoster) {
group.getProperties().put("showInRoster", "true");
group.getProperties().put("displayName", newDisplayName);
}
else {
group.getProperties().put("showInRoster", "false");
group.getProperties().put("displayName", "");
}
groupName = newName; groupName = newName;
groupInfoChanged = true; groupInfoChanged = true;
// Get admin list and compare it the admin posted list. // Get admin list and compare it the admin posted list.
response.sendRedirect("group-edit.jsp?group=" + URLEncoder.encode(groupName, "UTF-8") + "&groupChanged=true"); response.sendRedirect("group-edit.jsp?group=" + URLEncoder.encode(groupName, "UTF-8") + "&groupChanged=true");
return; return;
} }
else {
// Continue editing since there are some errors
edit = true;
}
}
if (update) { if (update) {
...@@ -219,7 +239,7 @@ import="java.text.DateFormat, ...@@ -219,7 +239,7 @@ import="java.text.DateFormat,
Description: Description:
</td> </td>
<% if(!edit) { %> <% if(!edit) { %>
<td colspan="3"> <td colspan="2">
<%= ((group.getDescription() != null) ? group.getDescription() : "<i>No Description</i>") %> <%= ((group.getDescription() != null) ? group.getDescription() : "<i>No Description</i>") %>
</td> </td>
<% } else { %> <% } else { %>
...@@ -230,6 +250,47 @@ import="java.text.DateFormat, ...@@ -230,6 +250,47 @@ import="java.text.DateFormat,
<% } %> <% } %>
</tr> </tr>
<tr>
<td width="1%" nowrap>
Show group in group members' rosters:
</td>
<% boolean showInRoster = "true".equals(group.getProperties().get("showInRoster"));
if(!edit) { %>
<td colspan="2">
<%= (showInRoster ? "Enabled" : "Disabled") %>
</td>
<% } else { %>
<td>
<input type="checkbox" name="newShow" value="true" <%= (showInRoster ? "checked" : "") %>/>
</td>
<% } %>
</tr>
<tr>
<td width="1%" nowrap>
Display name in roster:
</td>
<% String displayName = (group.getProperties().get("displayName") == null ? "" : group.getProperties().get("displayName"));
if(!edit) { %>
<td colspan="2">
<%= displayName %>
</td>
<% } else { %>
<td>
<input type="text" size="40" name="newDisplay" value="<%= displayName %>"/>
<%
if (errors.get("display") != null) {
%>
<span class="jive-error-text"> Please enter a display name. </span>
<%
}
%>
</td>
<% } %>
</tr>
<% if(edit) { %> <% if(edit) { %>
<tr> <tr>
<td colspan="3"> <td colspan="3">
......
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