Commit df7944c4 authored by Ryan Graham's avatar Ryan Graham Committed by ryang

* Added the ability to disable specific fields from being searched.

* Added internationalization (i18n) support.
* Updated UI to match later versions of Wildfire.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@7393 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1bd98d8d
......@@ -2,7 +2,7 @@
<html>
<head>
<title>Search Plugin Changelog</title>
<title>Search Plugin Changelog</title>
<style type="text/css">
BODY {
font-size : 100%;
......@@ -44,9 +44,16 @@
Search Plugin Changelog
</h1>
<p><b>1.3.0</b> -- February 28, 2007</p>
<ul>
<li>Added the ability to disable specific fields from being searched.</li>
<li>Added internationalization (i18n) support.</li>
<li>Updated UI to match later versions of Wildfire.</li>
</ul>
<p><b>1.2.1</b> -- September 7, 2006</p>
<ul>
<li>Search results no longer shows edit and delete if users are read-only.</li>
<li>Search results no longer shows edit and delete if users are read-only.</li>
</ul>
<p><b>1.2.1</b> -- October 06, 2006</p>
......
......@@ -3,26 +3,26 @@
<plugin>
<class>org.jivesoftware.wildfire.plugin.SearchPlugin</class>
<name>Search</name>
<description>Provides support for Jabber Search (JEP-0055)</description>
<description>Provides support for Jabber Search (XEP-0055)</description>
<author>Ryan Graham</author>
<version>1.2.1</version>
<date>10/06/2006</date>
<version>1.3.0</version>
<date>02/28/2007</date>
<minServerVersion>3.1.0</minServerVersion>
<adminconsole>
<tab id="tab-server">
<sidebar id="sidebar-server-settings">
<item id="search-props-edit-form" name="Search Properties"
url="search-props-edit-form.jsp"
description="Edit search service properties" />
</sidebar>
<adminconsole>
<tab id="tab-server">
<sidebar id="sidebar-server-settings">
<item id="search-props-edit-form" name="Search Properties"
url="search-props-edit-form.jsp"
description="Edit search service properties" />
</sidebar>
</tab>
<tab id="tab-users">
<sidebar id="sidebar-users">
<item id="advance-user-search" name="Advanced User Search"
url="advance-user-search.jsp"
description="Advanced user search" />
</sidebar>
<tab id="tab-users">
<sidebar id="sidebar-users">
<item id="advance-user-search" name="Advanced User Search"
url="advance-user-search.jsp"
description="Advanced user search" />
</sidebar>
</tab>
</adminconsole>
</plugin>
\ No newline at end of file
</plugin>
......@@ -2,7 +2,7 @@
<html>
<head>
<title>Search Plugin Readme</title>
<title>Search Plugin Readme</title>
<style type="text/css">
BODY {
font-size : 100%;
......@@ -44,15 +44,13 @@ Search Plugin Readme
</h1>
<h2>Overview</h2>
<p>
The search plugin adds Jabber Search <a href="http://www.jabber.org/jeps/jep-0055.html">JEP-0055</a>
The search plugin adds Jabber Search <a href="http://www.xmpp.org/extensions/xep-0055.html">XEP-0055</a>
capabilities to Wildfire. This plugin is designed to work with various Jabber clients to allow
other users to search for users currently registered on the same server they are.
</p>
<h2>Installation</h2>
<p>
Copy the file, &quot;search.jar&quot; into the plugins directory of your Wildfire installation. The plugin will
then be automatically deployed. To upgrade to a new version: 1) go to the plugin screen of the Admin
......@@ -61,15 +59,16 @@ copy the new search.jar into the plugins directory of your Wildfire installation
</p>
<h2>Configuration</h2>
<p>
The search plugin is configured via the "Search Service Properites" sidebar item located under the "Server" tab
in the Wildfire Admin Console. By default, after the search plugin has been deployed all of its features
are enabled. To enable or disable the plugin select the appropirate radio button and then click on the
"Save Properties" button. To change the service name enter the new name for the service and then click on the
"Save Properties" button
"Save Properties" button. To disable a field from being searched by clients un-check the corresponding checkbox
and click on the "Save Properties" button.
</p>
<h2>Using the Plugin</h2>
<p>
Use of this plugin varies from client to client; however, basic instructions for accessing the search screen
for some of the more popular clients are listed below. On the search screen there is a single
......@@ -78,13 +77,16 @@ and/or email that you want to find. As an example, if you want to find your frie
if his last name is spelled "Smith" or "Smyth", try entering "John S*" in the search field and making
sure the name checkbox is selected. The "*" symbol acts as a wildcard so your search might return not
only "John Smith" but all the users whose name begins with "John S", i.e. "John Slater", "John Salazar", etc.
</p>
<li>
Admin Console - Navigate to the "Advance User Search" sidebar item located in under the "Users/Groups" tab.
</li>
<br>
<li>
Spark - Use the search field along the bottom portion of the main Spark window.
</li>
<br>
<li>
Exodus - After clicking on the magnifying glass with the red "+" sign, a screen will appear displaying the search
service that will be used which will be used. Click on the "Next" button and the search screen will
......@@ -109,6 +111,6 @@ view the search screen.
Psi - On the lower left-hand corner of the client, click on the main Psi toolbar, select "Service Discovery", and click on your username. After the service discovery windowappears, select the "User Search" entry and click on
the magnifying glass at the top of the window to view the search screen.
</li>
<br>
</p>
</body>
</html>
login.title=Admin Console
advance.user.search.title=User Search
advance.user.search.search_user=Search For User
advance.user.search.search=Search
advance.user.search.details=The following fields are available for searching. Wildcard (*) characters are allowed as part the of query.
advance.user.search.more_options=More Options
advance.user.search.less_options=Less Options
advance.user.search.users_found=Users Found
advance.user.search.online=Online
advance.user.search.username=Username
advance.user.search.name=Name
advance.user.search.created=Created
advance.user.search.edit=Edit
advance.user.search.delete=Delete
advance.user.search.no_users=No users in the system.
advance.user.search.available=Available
advance.user.search.chat_available=Free to chat
advance.user.search.away=Away
advance.user.search.extended=Extended away
advance.user.search.offline=Offline
search.props.edit.form.title=Search Service Properties
search.props.edit.form.directions=Use the form below to edit search service settings, these settings do not affect the user search in the admin console.
search.props.edit.form.successful_edit=Service properties edited successfully.
search.props.edit.form.error=Error setting the service name.
search.props.edit.form.service_enabled=Service Enabled
search.props.edit.form.service_enabled_directions=You can choose to enable or disable user searches from clients. Disabling this services does not prevent user searches from the admin console.
search.props.edit.form.enabled=Enabled
search.props.edit.form.enabled_details=Clients will be able to search for users.
search.props.edit.form.disabled=Disabled
search.props.edit.form.disabled_details=Clients will not be able to search for users.
search.props.edit.form.service_name=Service Name
search.props.edit.form.search_service_name=Search service Name
search.props.edit.form.search_service_name_details=Please enter a valid name.
search.props.edit.form.searchable_fields=Searchable Fields
search.props.edit.form.searchable_fields_details=Use the form below to enable which fields users can search on.
search.props.edit.form.fields=Fields
search.props.edit.form.save_properties=Save Properties
search.service_unavailable=This service is unavailable.
......@@ -11,9 +11,11 @@ import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.PropertyEventDispatcher;
import org.jivesoftware.util.PropertyEventListener;
import org.jivesoftware.util.StringUtils;
import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.container.Plugin;
import org.jivesoftware.wildfire.container.PluginManager;
......@@ -38,20 +40,21 @@ import java.util.*;
/**
* Provides support for Jabber Search
* (<a href="http://www.jabber.org/jeps/jep-0055.html">JEP-0055</a>).<p>
* (<a href="http://www.xmpp.org/extensions/xep-0055.html">XEP-0055</a>).<p>
*
* The basic functionality is to query an information repository
* regarding the possible search fields, to send a search query,
* and to receive search results. This implementation was primarily designed to use
* <a href="http://www.jabber.org/jeps/jep-0004.html">Data Forms</a>, but
* <a href="http://www.xmpp.org/extensions/xep-0004.html">Data Forms</a>, but
* also supports non-dataform searches.
* <p/>
*
* @author Ryan Graham
* @author <a href="mailto:ryan@version2software.com">Ryan Graham</a>
*/
public class SearchPlugin implements Component, Plugin, PropertyEventListener {
public static final String PLUGIN_SEARCH_SERVICENAME = "plugin.search.serviceName";
public static final String PLUGIN_SEARCH_SERVICEENABLED = "plugin.search.serviceEnabled";
public static final String SERVICENAME = "plugin.search.serviceName";
public static final String SERVICEENABLED = "plugin.search.serviceEnabled";
public static final String EXCLUDEDFIELDS = "plugin.search.excludedFields";
private UserManager userManager;
private ComponentManager componentManager;
......@@ -59,36 +62,22 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
private String serviceName;
private boolean serviceEnabled;
private Collection<String> exculudedFields;
private static String serverName;
private static String instructions = "The following fields are available for search. "
+ "Wildcard (*) characters are allowed as part of the query.";
private static Element probeResult;
private Collection<String> searchFields;
private TreeMap<String, String> fieldLookup = new TreeMap<String, String>(new CaseInsensitiveComparator());
private Map<String, String> reverseFieldLookup = new HashMap<String, String>();
public SearchPlugin() {
serviceName = JiveGlobals.getProperty("plugin.search.serviceName", "search");
serviceEnabled = JiveGlobals.getBooleanProperty("plugin.search.serviceEnabled", true);
serviceName = JiveGlobals.getProperty(SERVICENAME, "search");
serviceEnabled = JiveGlobals.getBooleanProperty(SERVICEENABLED, true);
exculudedFields = StringUtils.stringToCollection(JiveGlobals.getProperty(EXCLUDEDFIELDS, ""));
serverName = XMPPServer.getInstance().getServerInfo().getName();
// See if the installed provider supports searching. If not, workaround
// by providing our own searching.
UserManager manager = UserManager.getInstance();
try {
searchFields = manager.getSearchFields();
userManager = UserManager.getInstance();
searchFields = userManager.getSearchFields();
}
catch (UnsupportedOperationException uoe) {
// Use a SearchPluginUserManager instead.
searchFields = getSearchFields();
}
// Some clients, such as Miranda, are hard-coded to search specific fields,
// so we map those fields to the fields that Wildfire actually supports.
fieldLookup.put("jid", "Username");
fieldLookup.put("username", "Username");
fieldLookup.put("first", "Name");
......@@ -97,7 +86,7 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
fieldLookup.put("name", "Name");
fieldLookup.put("email", "Email");
}
public String getName() {
return pluginManager.getName(this);
}
......@@ -106,53 +95,17 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
return pluginManager.getDescription(this);
}
public void initializePlugin(PluginManager manager, File pluginDirectory) {
public void initializePlugin(PluginManager manager, File pluginDirectory) {
pluginManager = manager;
componentManager = ComponentManagerFactory.getComponentManager();
try {
componentManager.addComponent(serviceName, this);
}
catch (Exception e) {
catch (ComponentException e) {
componentManager.getLog().error(e);
}
PropertyEventDispatcher.addListener(this);
if (probeResult == null) {
probeResult = DocumentHelper.createElement(QName.get("query", "jabber:iq:search"));
//non-data form
probeResult.addElement("instructions").addText(instructions);
XDataFormImpl searchForm = new XDataFormImpl(DataForm.TYPE_FORM);
searchForm.setTitle("User Search");
searchForm.addInstruction(instructions);
XFormFieldImpl field = new XFormFieldImpl("FORM_TYPE");
field.setType(FormField.TYPE_HIDDEN);
field.addValue("jabber:iq:search");
searchForm.addField(field);
field = new XFormFieldImpl("search");
field.setType(FormField.TYPE_TEXT_SINGLE);
field.setLabel("Search");
field.setRequired(true);
searchForm.addField(field);
for (String searchField : searchFields) {
//non-data form
probeResult.addElement(searchField);
field = new XFormFieldImpl(searchField);
field.setType(FormField.TYPE_BOOLEAN);
field.addValue("1");
field.setLabel(searchField);
field.setRequired(false);
searchForm.addField(field);
}
probeResult.add(searchForm.asXMLElement());
}
}
public void initialize(JID jid, ComponentManager componentManager) {
......@@ -174,12 +127,13 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
userManager = null;
fieldLookup = null;
reverseFieldLookup = null;
exculudedFields = null;
}
public void shutdown() {
}
public void processPacket(Packet p) {
public void processPacket(Packet p) {
if (p instanceof IQ) {
IQ packet = (IQ) p;
......@@ -240,12 +194,12 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
}
else if (IQ.Type.set.equals(packet.getType())) {
return processSetPacket(packet);
} else
if (IQ.Type.result.equals(packet.getType()) || IQ.Type.error.equals(packet.getType())) {
}
else if (IQ.Type.result.equals(packet.getType()) || IQ.Type.error.equals(packet.getType())) {
// Ignore
}
else {
// Unknown type was sent so
// Unknown type was sent so return an error
IQ reply = new IQ(IQ.Type.error, packet.getID());
reply.setFrom(packet.getTo());
reply.setTo(packet.getFrom());
......@@ -260,8 +214,8 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
IQ replyPacket = IQ.createResultIQ(packet);
Element reply = replyPacket.setChildElement("query", "jabber:iq:search");
XDataFormImpl unavailableForm = new XDataFormImpl(DataForm.TYPE_CANCEL);
unavailableForm.setTitle("User Search");
unavailableForm.addInstruction("This service is unavailable.");
unavailableForm.setTitle(LocaleUtils.getLocalizedString("advance.user.search.title", "search"));
unavailableForm.addInstruction(LocaleUtils.getLocalizedString("search.service_unavailable", "search"));
reply.add(unavailableForm.asXMLElement());
return replyPacket;
......@@ -269,7 +223,43 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
private IQ processGetPacket(IQ packet) {
IQ replyPacket = IQ.createResultIQ(packet);
replyPacket.setChildElement(probeResult.createCopy());
Element queryResult = DocumentHelper.createElement(QName.get("query", "jabber:iq:search"));
String instructions = LocaleUtils.getLocalizedString("advance.user.search.details", "search");
// non-data form
queryResult.addElement("instructions").addText(instructions);
XDataFormImpl searchForm = new XDataFormImpl(DataForm.TYPE_FORM);
searchForm.setTitle(LocaleUtils.getLocalizedString("advance.user.search.title", "search"));
searchForm.addInstruction(instructions);
XFormFieldImpl field = new XFormFieldImpl("FORM_TYPE");
field.setType(FormField.TYPE_HIDDEN);
field.addValue("jabber:iq:search");
searchForm.addField(field);
field = new XFormFieldImpl("search");
field.setType(FormField.TYPE_TEXT_SINGLE);
field.setLabel(LocaleUtils.getLocalizedString("advance.user.search.search", "search"));
field.setRequired(true);
searchForm.addField(field);
for (String searchField : getFilteredSearchFields()) {
// non-data form
queryResult.addElement(searchField);
field = new XFormFieldImpl(searchField);
field.setType(FormField.TYPE_BOOLEAN);
field.addValue("1");
field.setLabel(searchField);
field.setRequired(false);
searchForm.addField(field);
}
queryResult.add(searchForm.asXMLElement());
replyPacket.setChildElement(queryResult);
return replyPacket;
}
......@@ -297,6 +287,7 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
foundUsers.addAll(findUsers(field, query));
}
//occasionally null a User is returned so filter them out
for (User user : foundUsers) {
if (user != null) {
users.add(user);
......@@ -371,7 +362,7 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
field.setLabel("JID");
searchResults.addReportedField(field);
for (String fieldName : searchFields) {
for (String fieldName : getFilteredSearchFields()) {
field = new XFormFieldImpl(fieldName);
field.setLabel(fieldName);
searchResults.addReportedField(field);
......@@ -444,7 +435,7 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
public void setServiceName(String name) {
changeServiceName(name);
JiveGlobals.setProperty(PLUGIN_SEARCH_SERVICENAME, name);
JiveGlobals.setProperty(SERVICENAME, name);
}
public boolean getServiceEnabled() {
......@@ -453,33 +444,67 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
public void setServiceEnabled(boolean enabled) {
serviceEnabled = enabled;
JiveGlobals.setProperty(PLUGIN_SEARCH_SERVICEENABLED, enabled ? "true" : "false");
JiveGlobals.setProperty(SERVICEENABLED, enabled ? "true" : "false");
}
/**
* Returns the collection of searchable field names that does not include the fields
* listed in the EXCLUDEDFIELDS property list.
*/
public Collection<String> getFilteredSearchFields() {
Collection<String> searchFields;
// See if the installed provider supports searching. If not, workaround
// by providing our own searching.
try {
userManager = UserManager.getInstance();
searchFields = userManager.getSearchFields();
}
catch (UnsupportedOperationException uoe) {
// Use a SearchPluginUserManager instead.
searchFields = getSearchPluginUserManagerSearchFields();
}
searchFields.removeAll(exculudedFields);
return searchFields;
}
public void setExcludedFields(Collection<String> exculudedFields) {
this.exculudedFields = exculudedFields;
JiveGlobals.setProperty(EXCLUDEDFIELDS, StringUtils.collectionToString(exculudedFields));
}
public void propertySet(String property, Map params) {
if (property.equals(PLUGIN_SEARCH_SERVICEENABLED)) {
if (property.equals(SERVICEENABLED)) {
this.serviceEnabled = Boolean.parseBoolean((String)params.get("value"));
}
else if (property.equals(PLUGIN_SEARCH_SERVICENAME)) {
else if (property.equals(SERVICENAME)) {
changeServiceName((String)params.get("value"));
}
else if (property.equals(EXCLUDEDFIELDS)) {
exculudedFields = StringUtils.stringToCollection(JiveGlobals.getProperty(EXCLUDEDFIELDS, (String)params.get("value")));
}
}
public void propertyDeleted(String property, Map params) {
if (property.equals(PLUGIN_SEARCH_SERVICEENABLED)) {
if (property.equals(SERVICEENABLED)) {
this.serviceEnabled = true;
}
else if (property.equals(PLUGIN_SEARCH_SERVICENAME)) {
else if (property.equals(SERVICENAME)) {
changeServiceName("search");
}
else if (property.equals(EXCLUDEDFIELDS)) {
exculudedFields = new ArrayList<String>();
}
}
public void xmlPropertySet(String property, Map params) {
// not used
// not used
}
public void xmlPropertyDeleted(String property, Map params) {
// not used
// not used
}
private void changeServiceName(String serviceName) {
......@@ -509,15 +534,9 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
this.serviceName = serviceName;
}
private class CaseInsensitiveComparator implements Comparator {
public int compare(Object o1, Object o2) {
String s1 = (String) o1;
String s2 = (String) o2;
return s1.toUpperCase().compareTo(s2.toUpperCase());
}
public boolean equals(Object o) {
return compare(this, o) == 0;
private class CaseInsensitiveComparator implements Comparator<String> {
public int compare(String s1, String s2) {
return s1.compareToIgnoreCase(s2);
}
}
......@@ -534,7 +553,7 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
* user. Typical fields are username, name, and email. These values can be
* used to contruct a data form.
*/
public Collection<String> getSearchFields() {
public Collection<String> getSearchPluginUserManagerSearchFields() {
return Arrays.asList("Username", "Name", "Email");
}
......@@ -551,7 +570,7 @@ public class SearchPlugin implements Component, Plugin, PropertyEventListener {
public Collection<User> findUsers(String field, String query) {
List<User> foundUsers = new ArrayList<User>();
if (!getSearchFields().contains(field)) {
if (!getSearchPluginUserManagerSearchFields().contains(field)) {
return foundUsers;
}
......
<%@ page import="java.util.*,
java.net.URLEncoder,
org.jivesoftware.util.*,
org.jivesoftware.wildfire.PresenceManager,
java.net.URLEncoder,
org.jivesoftware.util.*,
org.jivesoftware.wildfire.PresenceManager,
org.jivesoftware.wildfire.user.*,
org.jivesoftware.wildfire.XMPPServer,
org.xmpp.packet.Presence"
......@@ -12,7 +12,7 @@
<html>
<head>
<title>User Search</title>
<title><fmt:message key="advance.user.search.title" /></title>
<meta name="pageID" content="advance-user-search"/>
</head>
<body>
......@@ -48,52 +48,51 @@
<form name="f" action="advance-user-search.jsp">
<input type="hidden" name="search" value="true"/>
<input type="hidden" name="moreOptions" value="<%=moreOptions %>"/>
<fieldset>
<legend><fmt:message key="user.search.search_user" /></legend>
<div>
<table cellpadding="3" cellspacing="1" border="0" width="600">
<div class="jive-contentBoxHeader"><fmt:message key="advance.user.search.search_user" /></div>
<div class="jive-contentBox">
<table cellpadding="3" cellspacing="1" border="0" width="600">
<tr class="c1">
<td width="1%" colspan="2" nowrap>
Search:
<fmt:message key="advance.user.search.search" />
&nbsp;<input type="text" name="criteria" value="<%=(criteria != null ? criteria : "") %>" size="30" maxlength="75"/>
&nbsp;<input type="submit" name="search" value="<fmt:message key="user.search.search" />"/>
</td>
&nbsp;<input type="submit" name="search" value="<fmt:message key="advance.user.search.search" />"/>
</td>
</tr>
<% if (moreOptions) { %>
<tr class="c1">
<td width="1%" colspan="2" nowrap>Wildcard (*) characters are allowed as part the of query. The following fields are available for searching:</td>
<td width="1%" colspan="2" nowrap><fmt:message key="advance.user.search.details" />:</td>
</tr>
<% for (String searchField : searchFields) { %>
<tr class="c1">
<td width="1%" nowrap><%=searchField %>:</td>
<td class="c2">
<% if (criteria == null) { %>
<input type="checkbox" checked name="<%=searchField %>"/>
<% } else { %>
<input type="checkbox" <%=selectedFields.contains(searchField) ? "checked" : "" %> name="<%=searchField %>"/>
<% } %>
</td>
</tr>
<% } %>
<tr>
<td nowrap>&raquo;&nbsp;<a href="advance-user-search.jsp?moreOptions=false">Less Options</a></td>
<td nowrap>&raquo;&nbsp;<a href="advance-user-search.jsp?moreOptions=false"><fmt:message key="advance.user.search.less_options" /></a></td>
</tr>
<% } else { %>
<tr>
<td nowrap>&raquo;&nbsp;<a href="advance-user-search.jsp?moreOptions=true">More Options</a></td>
<td nowrap>&raquo;&nbsp;<a href="advance-user-search.jsp?moreOptions=true"><fmt:message key="advance.user.search.more_options" /></a></td>
</tr>
<% } %>
</table>
</div>
</fieldset>
</form>
</div>
</form>
<% if (criteria != null) { %>
<p>
Users Found: <%=users.size() %>
<fmt:message key="advance.user.search.users_found" />: <%=users.size() %>
</p>
<div class="jive-table">
......@@ -101,14 +100,14 @@ Users Found: <%=users.size() %>
<thead>
<tr>
<th>&nbsp;</th>
<th nowrap><fmt:message key="session.details.online" /></th>
<th nowrap><fmt:message key="user.create.username" /></th>
<th nowrap><fmt:message key="user.create.name" /></th>
<th nowrap><fmt:message key="user.summary.created" /></th>
<th nowrap><fmt:message key="advance.user.search.online" /></th>
<th nowrap><fmt:message key="advance.user.search.username" /></th>
<th nowrap><fmt:message key="advance.user.search.name" /></th>
<th nowrap><fmt:message key="advance.user.search.created" /></th>
<% // Don't allow editing or deleting if users are read-only.
if (!UserManager.getUserProvider().isReadOnly()) { %>
<th nowrap><fmt:message key="user.summary.edit" /></th>
<th nowrap><fmt:message key="global.delete" /></th>
<th nowrap><fmt:message key="advance.user.search.edit" /></th>
<th nowrap><fmt:message key="advance.user.search.delete" /></th>
<% } %>
</tr>
</thead>
......@@ -116,14 +115,14 @@ Users Found: <%=users.size() %>
<% if (users.isEmpty()) { %>
<tr>
<td align="center" colspan="7"><fmt:message key="user.summary.not_user" /></td>
<td align="center" colspan="7"><fmt:message key="advance.user.search.no_users" /></td>
</tr>
<%
<%
} else {
int i = 0;
PresenceManager presenceManager = XMPPServer.getInstance().getPresenceManager();
for (User user : users) {
i++;
%>
......@@ -136,26 +135,26 @@ Users Found: <%=users.size() %>
Presence presence = presenceManager.getPresence(user);
if (presence.getShow() == null) {
%> <img src="images/user-green-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="user.properties.available" />"> <%
}
%> <img src="images/user-green-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="advance.user.search.available" />"> <%
}
if (presence.getShow() == Presence.Show.chat) {
%> <img src="images/user-green-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="session.details.chat_available" />"> <%
%> <img src="images/user-green-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="advance.user.search.chat_available" />"> <%
}
if (presence.getShow() == Presence.Show.away) {
%> <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="session.details.away" />"> <%
}
%> <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="advance.user.search.away" />"> <%
}
if (presence.getShow() == Presence.Show.xa) {
%> <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="session.details.extended" />"> <%
}
%> <img src="images/user-yellow-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="advance.user.search.extended" />"> <%
}
if (presence.getShow() == Presence.Show.dnd) {
%> <img src="images/user-red-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="session.details.not_disturb" />"> <%
%> <img src="images/user-red-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="advance.user.search.not_disturb" />"> <%
}
} else {
%> <img src="images/user-clear-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="user.properties.offline" />"> <%
} else {
%> <img src="images/user-clear-16x16.gif" width="16" height="16" border="0" alt="<fmt:message key="advance.user.search.offline" />"> <%
}
%>
</td>
......
<%@ page import="java.util.*,
org.jivesoftware.wildfire.XMPPServer,
org.jivesoftware.wildfire.plugin.SearchPlugin,
org.jivesoftware.wildfire.plugin.SearchPlugin,
org.jivesoftware.wildfire.user.*,
org.jivesoftware.util.*"
%>
......@@ -11,9 +12,9 @@
boolean save = request.getParameter("save") != null;
boolean success = request.getParameter("success") != null;
String searchName = ParamUtils.getParameter(request, "searchname");
boolean searchEnabled = ParamUtils.getBooleanParameter(request, "searchEnabled");
boolean searchEnabled = ParamUtils.getBooleanParameter(request, "searchEnabled");
SearchPlugin plugin = (SearchPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("search");
SearchPlugin plugin = (SearchPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("search");
// Handle a save
Map errors = new HashMap();
......@@ -23,8 +24,17 @@
}
if (errors.size() == 0) {
plugin.setServiceEnabled(searchEnabled);
plugin.setServiceEnabled(searchEnabled);
plugin.setServiceName(searchName.trim());
ArrayList<String> excludedFields = new ArrayList<String>();
for (String field : UserManager.getInstance().getSearchFields()) {
if (!ParamUtils.getBooleanParameter(request, field)) {
excludedFields.add(field);
}
}
plugin.setExcludedFields(excludedFields);
response.sendRedirect("search-props-edit-form.jsp?success=true");
return;
}
......@@ -38,17 +48,18 @@
}
searchEnabled = plugin.getServiceEnabled();
Collection<String> searchableFields = plugin.getFilteredSearchFields();
%>
<html>
<head>
<title>Search Service Properties</title>
<title><fmt:message key="search.props.edit.form.title" /></title>
<meta name="pageID" content="search-props-edit-form"/>
</head>
<body>
<p>
Use the form below to edit search service settings, these settings do not affect the user search in the admin console.<br>
<fmt:message key="search.props.edit.form.directions" />
</p>
<% if (success) { %>
......@@ -58,7 +69,7 @@ Use the form below to edit search service settings, these settings do not affect
<tbody>
<tr><td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
Service properties edited successfully.
<fmt:message key="search.props.edit.form.successful_edit" />
</td></tr>
</tbody>
</table>
......@@ -71,7 +82,7 @@ Use the form below to edit search service settings, these settings do not affect
<tbody>
<tr><td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">
Error setting the service name.
<fmt:message key="search.props.edit.form.error" />
</td></tr>
</tbody>
</table>
......@@ -81,11 +92,10 @@ Use the form below to edit search service settings, these settings do not affect
<form action="search-props-edit-form.jsp?save" method="post">
<fieldset>
<legend>Service Enabled</legend>
<div>
<div class="jive-contentBoxHeader"><fmt:message key="search.props.edit.form.service_enabled" /></div>
<div class="jive-contentBox">
<p>
You can choose to enable or disable user searches from clients. Disabling this services does not prevent user searches from the admin console.
<fmt:message key="search.props.edit.form.service_enabled_directions" />
</p>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
......@@ -95,7 +105,7 @@ Use the form below to edit search service settings, these settings do not affect
<%= ((searchEnabled) ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb01"><b>Enabled</b></label> - Clients will be able to search for users.
<label for="rb01"><b><fmt:message key="search.props.edit.form.enabled" /></b></label> - <fmt:message key="search.props.edit.form.enabled_details" />
</td>
</tr>
<tr>
......@@ -104,24 +114,21 @@ Use the form below to edit search service settings, these settings do not affect
<%= ((!searchEnabled) ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb02"><b>Disabled</b></label> - Clients will not be able to search for users.
<label for="rb02"><b><fmt:message key="search.props.edit.form.disabled" /></b></label> - <fmt:message key="search.props.edit.form.disabled_details" />
</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
</div>
<br><br>
<br>
<fieldset>
<legend>Service Name</legend>
<div>
<div class="jive-contentBoxHeader"><fmt:message key="search.props.edit.form.service_name" /></div>
<div class="jive-contentBox">
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td class="c1">
Search service name:
<fmt:message key="search.props.edit.form.search_service_name" />:
</td>
<td>
<input type="text" size="30" maxlength="150" name="searchname" value="<%= (searchName != null ? searchName : "") %>">.<%=XMPPServer.getInstance().getServerInfo().getName() %>
......@@ -129,19 +136,39 @@ Use the form below to edit search service settings, these settings do not affect
<% if (errors.containsKey("searchname")) { %>
<span class="jive-error-text">
<br>Please enter a valid name.
<br><fmt:message key="search.props.edit.form.search_service_name_details" />
</span>
<% } %>
</td>
</tr>
</table>
</div>
</fieldset>
</div>
<br>
<div class="jive-contentBoxHeader"><fmt:message key="search.props.edit.form.searchable_fields" /></div>
<div class="jive-contentBox">
<p>
<fmt:message key="search.props.edit.form.searchable_fields_details" />
</p>
<table class="jive-table" cellpadding="3" cellspacing="0" border="0" width="400">
<tr>
<th align="center" width="1%"><fmt:message key="search.props.edit.form.enabled" /></th>
<th align="left" width="99%"><fmt:message key="search.props.edit.form.fields" /></th>
</tr>
<% for (String field : UserManager.getInstance().getSearchFields()) { %>
<tr>
<td align="center" width="1%"><input type="checkbox" <%=searchableFields.contains(field) ? "checked" : "" %> name="<%=field %>"></td>
<td align="left" width="99%"><%=field %></td>
</tr>
<% } %>
</table>
</div>
<br><br>
<br>
<input type="submit" value="Save Properties">
<input type="submit" value="<fmt:message key="search.props.edit.form.save_properties" />">
</form>
</body>
......
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