groups = new ArrayList<>(webManager.getGroupManager().getGroups());
// Remove already joined groups
groups.removeAll(userGroups);
int groupCount = groups.size();
int groupIndex = start + range;
String search = null;
if (webManager.getGroupManager().isSearchSupported() && request.getParameter("search") != null
&& !request.getParameter("search").trim().isEmpty()) {
search = request.getParameter("search");
search = StringUtils.escapeHTMLTags(search);
// Use the search terms to get the list of groups.
groups = new ArrayList<>(webManager.getGroupManager().search(search));
// Count already joined groups in the search result
int userGroupCount = 0;
for(Group group : groups) {
if(userGroups.contains(group)) {
userGroupCount++;
}
}
groups.removeAll(userGroups);
groupCount = groups.size() - userGroupCount;
}
if(groupIndex >= groupCount) {
groupIndex = groupCount;
}
// paginator vars
int numPages = (int)Math.ceil((double)groupCount/(double)range);
int curPage = (start/range) + 1;
if(success) {
%>
<%
}
%>
<%=username%>.
| |
|
|
<%
// Print the list of groups
if (userGroups.isEmpty()) {
%>
|
<%
}
int x = 0;
for (Group group : userGroups) {
String groupName = URLEncoder.encode(group.getName(), StandardCharsets.UTF_8);
x++;
%>
| <%=x%> |
<%=StringUtils.escapeHTMLTags(group.getName())%>
<%
if (group.getDescription() != null) {
%> <%=StringUtils.escapeHTMLTags(group.getDescription())%>
<%
}
%> |
"> "> |
<%
}
%>
<%=username%>.
<%
if (webManager.getGroupManager().isSearchSupported()) {
%>
<%
}
// Otherwise, searching is not supported.
else {
%>
<%=groupCount%>
<%
if (numPages > 1) {
%>
,
<%=(start + 1)%>-<%=(start + range)%>
<%
}
%>
<%
}
%>
<%
if (numPages > 1) {
%>
[
<%
for (int i = 0; i < numPages; i++) {
String sep = ((i + 1) < numPages) ? " " : "";
boolean isCurrent = (i + 1) == curPage;
%>
"
class="<%=((isCurrent) ? "jive-current" : "")%>"><%=(i + 1)%><%=sep%>
<%
}
%>
]
<%
}
%>
| |
|
|
<%
// Print the list of groups
if (groups.isEmpty()) {
%>
|
<%
}
int i = 0;
for (Group group : groups.subList(start, groupIndex)) {
String groupName = URLEncoder.encode(group.getName(), StandardCharsets.UTF_8);
i++;
%>
| <%=i%> |
<%=StringUtils.escapeHTMLTags(group.getName())%>
<%
if (group.getDescription() != null) {
%> <%=StringUtils.escapeHTMLTags(group.getDescription())%>
<%
}
%> |
"> "> |
<%
}
%>
<%
if (numPages > 1) {
%>
[
<%
for (i = 0; i < numPages; i++) {
String sep = ((i + 1) < numPages) ? " " : "";
boolean isCurrent = (i + 1) == curPage;
%>
"
class="<%=((isCurrent) ? "jive-current" : "")%>"><%=(i + 1)%><%=sep%>
<%
}
%>
]
<%
}
%>