<%@ page contentType="text/html; charset=UTF-8" %> <%-- - - Copyright (C) 2005-2008 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.ParamUtils, org.jivesoftware.openfire.user.UserNotFoundException" errorPage="error.jsp" %> <%@ page import="java.net.URLEncoder"%> <%@ page import="org.jivesoftware.openfire.roster.Roster" %> <%@ page import="org.jivesoftware.openfire.roster.RosterItem" %> <%@ page import="org.jivesoftware.util.LocaleUtils" %> <%@ page import="org.jivesoftware.util.StringUtils" %> <%@ page import="java.util.*" %> <%@ page import="org.jivesoftware.openfire.group.Group" %> <%@ page import="org.xmpp.packet.JID" %> <%@ page import="java.nio.charset.StandardCharsets" %> <%! final int DEFAULT_RANGE = 15; final int[] RANGE_PRESETS = {15, 25, 50, 75, 100}; %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <%@ taglib prefix="admin" uri="admin" %> <% class RosterItemComparator implements Comparator { public int compare(RosterItem itemA, RosterItem itemB) { return itemA.getJid().toBareJID().compareTo(itemB.getJid().toBareJID()); } } %> <% // Get parameters int start = ParamUtils.getIntParameter(request,"start",0); int range = ParamUtils.getIntParameter(request,"range",webManager.getRowsPerPage("user-roster", DEFAULT_RANGE)); int filter = ParamUtils.getIntParameter(request,"filter",webManager.getPageProperty("user-roster", "filter", 0)); if (request.getParameter("range") != null) { webManager.setRowsPerPage("user-roster", range); } if (request.getParameter("filter") != null) { webManager.setPageProperty("user-roster", "filter", filter); } // Get parameters // String username = ParamUtils.getParameter(request, "username"); String usernameUrlEncoded = URLEncoder.encode(username, StandardCharsets.UTF_8); pageContext.setAttribute( "usernameUrlEncoded", usernameUrlEncoded); pageContext.setAttribute( "usernameHtmlEscaped", StringUtils.escapeHTMLTags(JID.unescapeNode(username)) ); // Load the roster object Roster roster = null; int rosterCount = 0; try { roster = webManager.getRosterManager().getRoster(username); if (filter == 2) { for (RosterItem item : roster.getRosterItems()) { if (item.isOnlyShared()) { rosterCount++; } } } else if (filter == 1) { for (RosterItem item : roster.getRosterItems()) { if (!item.isOnlyShared()) { rosterCount++; } } } else { rosterCount = roster.getRosterItems().size(); } } catch (UserNotFoundException unfe) { // ignore } // paginator vars int numPages = (int)Math.ceil((double)rosterCount/(double)range); int curPage = (start/range) + 1; %> <fmt:message key="user.roster.title"/> <% if (request.getParameter("addsuccess") != null) { %> <% } %> <% if (request.getParameter("editsuccess") != null) { %> <% } %> <% if (request.getParameter("deletesuccess") != null) { %> <% } %>

: <%= LocaleUtils.getLocalizedNumber(rosterCount) %> -- <% if (numPages > 1) { %> <%= LocaleUtils.getLocalizedNumber(start+1) %>-<%= LocaleUtils.getLocalizedNumber(Math.min(start + range, rosterCount)) %>, <% } %> <% if (numPages > 1) { %> -- : [ <% int num = 15 + curPage; int s = curPage-1; if (s > 5) { s -= 5; } if (s < 5) { s = 0; } if (s > 2) { %> 1 ... <% } int i; for (i = s; i < numPages && i < num; i++) { String sep = ((i + 1) < numPages) ? " " : ""; boolean isCurrent = (i + 1) == curPage; %> " ><%= (i+1) %><%= sep %> <% } %> <% if (i < numPages) { %> ... <%= numPages %> <% } %> ] <% } %>

: -- :

<% if (roster == null) { %> <% } else if (rosterCount < 1) { %> <% } else { List rosterItems = new ArrayList<>(roster.getRosterItems()); rosterItems.sort(new RosterItemComparator()); int i = 0; for (RosterItem rosterItem : rosterItems) { if (filter == 2 && !rosterItem.isOnlyShared()) { continue; } if (filter == 1 && rosterItem.isOnlyShared()) { continue; } i++; if (i < start) { continue; } if (i > start+range) { break; } %> <% } } %>
 
<%= i %> " ><%= rosterItem.getJid() %> <%= (rosterItem.getNickname() != null ? StringUtils.escapeHTMLTags(rosterItem.getNickname()) : "None") %> <% List groups = rosterItem.getGroups(); int count = 0; if (!groups.isEmpty()) { for (String group : groups) { if (count != 0) { out.print(", "); } out.print(StringUtils.escapeHTMLTags(group)); count++; } } Collection sharedGroups = rosterItem.getSharedGroups(); if (filter != 1) { if (!sharedGroups.isEmpty()) { for (Group group : sharedGroups) { if (count != 0) { out.print(", "); } out.print(""); out.print(StringUtils.escapeHTMLTags(group.getName())); out.print(""); count++; } } } if (count == 0) { %> None <% } %> <%= rosterItem.getSubStatus().getName() %> " ><fmt:message key="> <% if (sharedGroups.isEmpty()) { %> " ><fmt:message key="> <% } else { %> <% } %>