added "Find Users," including back-end functionality and some bugfixes
This commit is contained in:
parent
4f62066e6b
commit
3fa600206e
|
@ -169,6 +169,12 @@
|
|||
<database connection="data"/>
|
||||
</object>
|
||||
|
||||
<object name="adv-users" classname="com.silverwrist.venice.app.AdvancedUserManager" priority="100">
|
||||
<database connection="data" namespaces="nscache"/>
|
||||
<security object="srm"/>
|
||||
<user-manager object="users"/>
|
||||
</object>
|
||||
|
||||
<object name="communities" classname="com.silverwrist.venice.community.CommunityManager" priority="101">
|
||||
<database connection="data" namespaces="nscache"/>
|
||||
<security object="srm"/>
|
||||
|
|
|
@ -168,6 +168,12 @@
|
|||
<database connection="data"/>
|
||||
</object>
|
||||
|
||||
<object name="adv-users" classname="com.silverwrist.venice.app.AdvancedUserManager" priority="100">
|
||||
<database connection="data" namespaces="nscache"/>
|
||||
<security object="srm"/>
|
||||
<user-manager object="users"/>
|
||||
</object>
|
||||
|
||||
<object name="communities" classname="com.silverwrist.venice.community.CommunityManager" priority="101">
|
||||
<database connection="data" namespaces="nscache"/>
|
||||
<security object="srm"/>
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#macro( encodeURL $data )$std.encodeURL($data)#end
|
||||
|
||||
#macro( getProperty $obj $namespace $name )$std.getProperty($data,$namespace,$name)#end
|
||||
|
||||
#macro( render $obj )$std.renderObject($obj)#end
|
||||
|
||||
#macro( renderDialog $dlg )$std.renderDialog($dlg)#end
|
||||
|
|
|
@ -1130,4 +1130,5 @@ INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link, perm_ns
|
|||
INSERT INTO menus (menuid, menu_nsid, menu_name, title, subtitle)
|
||||
VALUES (4, 6, 'find.menu', 'Find', NULL);
|
||||
INSERT INTO menuitems (menuid, sequence, itemtype, text, linktype, link) VALUES
|
||||
(4, 0, 'TEXT', 'Categories', 'SERVLET', 'find_categories.js.vs');
|
||||
(4, 0, 'TEXT', 'Users', 'SERVLET', 'find_users.js.vs' ),
|
||||
(4, 1, 'TEXT', 'Categories', 'SERVLET', 'find_categories.js.vs');
|
||||
|
|
|
@ -75,6 +75,12 @@ public class StdObject
|
|||
|
||||
} // end if
|
||||
|
||||
public Object getProperty(ObjectProvider obj, String namespace, String name)
|
||||
{
|
||||
return PropertyUtils.getPropertyNoErr(obj,namespace,name);
|
||||
|
||||
} // end getProperty
|
||||
|
||||
public String renderObject(Object obj) throws IOException, RenderingException
|
||||
{
|
||||
BufferTextRenderControl bufctrl = new BufferTextRenderControl(m_control);
|
||||
|
|
75
src/venice-base/com/silverwrist/venice/UserSearchField.java
Normal file
75
src/venice-base/com/silverwrist/venice/UserSearchField.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (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.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.commons.lang.enum.*;
|
||||
|
||||
public final class UserSearchField extends Enum
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* The actual enumeration values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static final UserSearchField USERNAME = new UserSearchField("USERNAME");
|
||||
public static final UserSearchField DESCRIPTION = new UserSearchField("DESCRIPTION");
|
||||
public static final UserSearchField FIRSTNAME = new UserSearchField("FIRSTNAME");
|
||||
public static final UserSearchField LASTNAME = new UserSearchField("LASTNAME");
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private UserSearchField(String name)
|
||||
{
|
||||
super(name);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Standard static method implementations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static UserSearchField getEnum(String name)
|
||||
{
|
||||
return (UserSearchField)getEnum(UserSearchField.class,name);
|
||||
|
||||
} // end getEnum
|
||||
|
||||
public static Map getEnumMap()
|
||||
{
|
||||
return getEnumMap(UserSearchField.class);
|
||||
|
||||
} // end getEnumMap
|
||||
|
||||
public static List getEnumList()
|
||||
{
|
||||
return getEnumList(UserSearchField.class);
|
||||
|
||||
} // end getEnumList
|
||||
|
||||
public static Iterator iterator()
|
||||
{
|
||||
return iterator(UserSearchField.class);
|
||||
|
||||
} // end iterator
|
||||
|
||||
} // end class UserSearchField
|
|
@ -0,0 +1,278 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (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.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.app;
|
||||
|
||||
import java.util.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.w3c.dom.*;
|
||||
import com.silverwrist.util.xml.*;
|
||||
import com.silverwrist.dynamo.db.NamespaceCache;
|
||||
import com.silverwrist.dynamo.db.UserManagement;
|
||||
import com.silverwrist.dynamo.db.UserProxyManagement;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
|
||||
import com.silverwrist.dynamo.util.*;
|
||||
import com.silverwrist.venice.SearchMode;
|
||||
import com.silverwrist.venice.UserSearchField;
|
||||
import com.silverwrist.venice.VeniceNamespaces;
|
||||
|
||||
public class AdvancedUserManager implements NamedObject, ComponentInitialize, ComponentShutdown, AdvancedUserService
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static Logger logger = Logger.getLogger(AdvancedUserManager.class);
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private String m_name; // this object's name
|
||||
private AdvancedUserOps m_ops; // database operations
|
||||
private NamespaceCache m_ns_cache; // namespace cache object
|
||||
private SecurityReferenceMonitor m_srm; // security reference monitor
|
||||
private UserManagement m_users; // user management object
|
||||
private UserProxyManagement m_proxy; // user proxy management object
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public AdvancedUserManager()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final List translateUIDArray(int[] uids)
|
||||
{
|
||||
if ((uids==null) || (uids.length==0))
|
||||
return Collections.EMPTY_LIST;
|
||||
ArrayList rc = new ArrayList(uids.length);
|
||||
for (int i=0; i<uids.length; i++)
|
||||
rc.add(m_proxy.getUserProxy(uids[i]));
|
||||
return Collections.unmodifiableList(rc);
|
||||
|
||||
} // end translateUIDArray
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface NamedObject
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return m_name;
|
||||
|
||||
} // end getName
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentInitialize
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
*
|
||||
* @param config_root Pointer to the section of the Dynamo XML configuration file that configures this
|
||||
* particular component. This is to be considered "read-only" by the component.
|
||||
* @param services An implementation of {@link com.silverwrist.dynamo.iface.ServiceProvider ServiceProvider}
|
||||
* which provides initialization services to the component. This will include an implementation
|
||||
* of {@link com.silverwrist.dynamo.iface.ObjectProvider ObjectProvider} which may be used to
|
||||
* get information about other objects previously initialized by the application.
|
||||
* @exception com.silverwrist.dynamo.except.ConfigException If an error is encountered in the component
|
||||
* configuration.
|
||||
*/
|
||||
public void initialize(Element config_root, ServiceProvider services) throws ConfigException
|
||||
{
|
||||
logger.info("AdvancedUserManager initializing");
|
||||
|
||||
XMLLoader loader = XMLLoader.get();
|
||||
String name_pool = null, name_nscache = null, name_srm = null, name_users = null;
|
||||
try
|
||||
{ // verify the right node name
|
||||
loader.verifyNodeName(config_root,"object");
|
||||
|
||||
// get the object's name
|
||||
m_name = loader.getAttribute(config_root,"name");
|
||||
|
||||
// get the name of the database pool and namespace cache
|
||||
DOMElementHelper config_root_h = new DOMElementHelper(config_root);
|
||||
Element foo = loader.getSubElement(config_root_h,"database");
|
||||
name_pool = loader.getAttribute(foo,"connection");
|
||||
name_nscache = loader.getAttribute(foo,"namespaces");
|
||||
|
||||
// get the name of the security reference monitor
|
||||
foo = loader.getSubElement(config_root_h,"security");
|
||||
name_srm = loader.getAttribute(foo,"object");
|
||||
|
||||
// get the name of the user manager
|
||||
foo = loader.getSubElement(config_root_h,"user-manager");
|
||||
name_users = loader.getAttribute(foo,"object");
|
||||
|
||||
} // end try
|
||||
catch (XMLLoadException e)
|
||||
{ // error loading XML config data
|
||||
logger.fatal("XML loader exception in CommunityManager",e);
|
||||
throw new ConfigException(e);
|
||||
|
||||
} // end catch
|
||||
|
||||
// Get the database connection pool.
|
||||
DBConnectionPool pool = GetObjectUtils.getDatabaseConnection(services,name_pool);
|
||||
|
||||
// Get the database operations object.
|
||||
m_ops = AdvancedUserOps.get(pool);
|
||||
|
||||
// Get the namespace cache.
|
||||
m_ns_cache = (NamespaceCache)(GetObjectUtils.getDynamoComponent(services,NamespaceCache.class,name_nscache));
|
||||
|
||||
// Get the security reference monitor.
|
||||
m_srm = (SecurityReferenceMonitor)(GetObjectUtils.getDynamoComponent(services,SecurityReferenceMonitor.class,
|
||||
name_srm));
|
||||
|
||||
// Get the user management object.
|
||||
m_users = (UserManagement)(GetObjectUtils.getDynamoComponent(services,UserManagement.class,name_users));
|
||||
m_proxy = (UserProxyManagement)(GetObjectUtils.getDynamoComponent(services,UserProxyManagement.class,name_users));
|
||||
|
||||
} // end initialize
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ComponentShutdown
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
m_proxy = null;
|
||||
m_users = null;
|
||||
m_srm = null;
|
||||
m_ns_cache = null;
|
||||
m_ops.dispose();
|
||||
m_ops = null;
|
||||
|
||||
} // end shutdown
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface UserManagement
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public DynamoUser getAnonymousUser() throws DatabaseException
|
||||
{
|
||||
return m_users.getAnonymousUser();
|
||||
|
||||
} // end getAnonymousUser
|
||||
|
||||
public DynamoUser getUser(int id) throws DatabaseException
|
||||
{
|
||||
return m_users.getUser(id);
|
||||
|
||||
} // end getUser
|
||||
|
||||
public DynamoUser getUser(String username) throws DatabaseException
|
||||
{
|
||||
return m_users.getUser(username);
|
||||
|
||||
} // end getUser
|
||||
|
||||
public DynamoUser createUser(String username, String email) throws DatabaseException
|
||||
{
|
||||
return m_users.createUser(username,email);
|
||||
|
||||
} // end createUser
|
||||
|
||||
public DynamoGroup getGroup(int id) throws DatabaseException
|
||||
{
|
||||
return m_users.getGroup(id);
|
||||
|
||||
} // end getGroup
|
||||
|
||||
public DynamoGroup getGroup(String groupname) throws DatabaseException
|
||||
{
|
||||
return m_users.getGroup(groupname);
|
||||
|
||||
} // end getGroup
|
||||
|
||||
public DynamoGroup createGroup(String groupname) throws DatabaseException
|
||||
{
|
||||
return m_users.createGroup(groupname);
|
||||
|
||||
} // end createGroup
|
||||
|
||||
public void loadUserDefaults(DynamoUser user, Collection namespaces) throws DatabaseException
|
||||
{
|
||||
m_users.loadUserDefaults(user,namespaces);
|
||||
|
||||
} // end loadUserDefaults
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface AdvancedUserService
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public List searchForUsers(DynamoUser caller, UserSearchField field, SearchMode mode, String term,
|
||||
int offset, int count) throws DatabaseException
|
||||
{
|
||||
int[] rc = null;
|
||||
String prop = null;
|
||||
if (UserSearchField.USERNAME.equals(field))
|
||||
rc = m_ops.searchName(mode,term,offset,count);
|
||||
else if (UserSearchField.DESCRIPTION.equals(field))
|
||||
prop = "description";
|
||||
else if (UserSearchField.FIRSTNAME.equals(field))
|
||||
prop = "name.given";
|
||||
else if (UserSearchField.LASTNAME.equals(field))
|
||||
prop = "name.family";
|
||||
else
|
||||
throw new IllegalArgumentException("invalid search field (shouldn't happen)");
|
||||
if ((rc==null) && (prop!=null))
|
||||
rc = m_ops.searchProperty(m_ns_cache.namespaceNameToId(VeniceNamespaces.USER_PROFILE_NAMESPACE),prop,mode,
|
||||
term,offset,count);
|
||||
return translateUIDArray(rc);
|
||||
|
||||
} // end searchForUsers
|
||||
|
||||
public int getSearchUserCount(DynamoUser caller, UserSearchField field, SearchMode mode, String term)
|
||||
throws DatabaseException
|
||||
{
|
||||
String prop = null;
|
||||
if (UserSearchField.USERNAME.equals(field))
|
||||
return m_ops.searchNameCount(mode,term);
|
||||
else if (UserSearchField.DESCRIPTION.equals(field))
|
||||
prop = "description";
|
||||
else if (UserSearchField.FIRSTNAME.equals(field))
|
||||
prop = "name.given";
|
||||
else if (UserSearchField.LASTNAME.equals(field))
|
||||
prop = "name.family";
|
||||
else
|
||||
throw new IllegalArgumentException("invalid search field (shouldn't happen)");
|
||||
return m_ops.searchPropertyCount(m_ns_cache.namespaceNameToId(VeniceNamespaces.USER_PROFILE_NAMESPACE),
|
||||
prop,mode,term);
|
||||
|
||||
} // end getSearchUserCount
|
||||
|
||||
} // end class AdvancedUserManager
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (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.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.app;
|
||||
|
||||
import com.silverwrist.dynamo.db.OpsBase;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.SearchMode;
|
||||
|
||||
abstract class AdvancedUserOps extends OpsBase
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
protected AdvancedUserOps(DBConnectionPool pool)
|
||||
{
|
||||
super(pool);
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
abstract int[] searchProperty(int nsid, String name, SearchMode mode, String term, int offset, int count)
|
||||
throws DatabaseException;
|
||||
|
||||
abstract int searchPropertyCount(int nsid, String name, SearchMode mode, String term) throws DatabaseException;
|
||||
|
||||
abstract int[] searchName(SearchMode mode, String term, int offset, int count) throws DatabaseException;
|
||||
|
||||
abstract int searchNameCount(SearchMode mode, String term) throws DatabaseException;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static AdvancedUserOps get(DBConnectionPool pool) throws ConfigException
|
||||
{
|
||||
return (AdvancedUserOps)get(pool,AdvancedUserOps.class.getClassLoader(),
|
||||
AdvancedUserOps.class.getName() + "_","AdvancedUserOps");
|
||||
|
||||
} // end get
|
||||
|
||||
} // end class AdvancedUserOps
|
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (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.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.app;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.*;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.SearchMode;
|
||||
|
||||
public class AdvancedUserOps_mysql extends AdvancedUserOps
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private DBUtilities m_utils;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public AdvancedUserOps_mysql(DBConnectionPool pool)
|
||||
{
|
||||
super(pool);
|
||||
m_utils = (DBUtilities)(pool.queryService(DBUtilities.class));
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Internal operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private final String preparePropertySearchTerm(SearchMode mode, String term)
|
||||
{
|
||||
StringBuffer buf = new StringBuffer();
|
||||
if (SearchMode.PREFIX.equals(mode))
|
||||
buf.append("LIKE '!").append(m_utils.encodeStringWildcards(term)).append("%'");
|
||||
else if (SearchMode.SUBSTRING.equals(mode))
|
||||
buf.append("LIKE '!%").append(m_utils.encodeStringWildcards(term)).append("%'");
|
||||
else if (SearchMode.REGEXP.equals(mode))
|
||||
{ // for regular expressions, if we're matching the start of the string, we have to include the ! prefix
|
||||
buf.append("REGEXP '");
|
||||
if (term.startsWith("^"))
|
||||
buf.append("^!").append(m_utils.encodeString(term.substring(1)));
|
||||
else
|
||||
buf.append(m_utils.encodeString(term));
|
||||
buf.append('\'');
|
||||
|
||||
} // end else if
|
||||
|
||||
return buf.toString();
|
||||
|
||||
} // end preparePropertySearchTerm
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Overrides from class OpsBase
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
m_utils = null;
|
||||
super.dispose();
|
||||
|
||||
} // end dispose
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Abstract implementations from class AdvancedUserOps
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int[] searchProperty(int nsid, String name, SearchMode mode, String term, int offset, int count)
|
||||
throws DatabaseException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{ // get a connection
|
||||
conn = getConnection();
|
||||
|
||||
// prepare and execute a query (note that we assemble it in SQL form)
|
||||
StringBuffer sql = new StringBuffer("SELECT u.uid FROM users u, userprop p WHERE u.uid = p.uid "
|
||||
+ "AND u.is_anon = 0 AND p.nsid = ");
|
||||
sql.append(nsid).append(" AND p.prop_name = '").append(m_utils.encodeString(name)).append("' AND p.prop_value ");
|
||||
sql.append(preparePropertySearchTerm(mode,term));
|
||||
sql.append(" ORDER BY u.name LIMIT ").append(offset).append(", ").append(count+1).append(';');
|
||||
stmt = conn.createStatement();
|
||||
rs = stmt.executeQuery(sql.toString());
|
||||
|
||||
// We *know* the maximum number of indexes that can be returned, so allocate a temporary array big
|
||||
// enough to hold them all.
|
||||
int[] tmp = new int[count+1];
|
||||
int ct = 0;
|
||||
while (rs.next())
|
||||
tmp[ct++] = rs.getInt(1);
|
||||
|
||||
// Create the actual return array and fill it.
|
||||
int[] rc = new int[ct];
|
||||
System.arraycopy(tmp,0,rc,0,ct);
|
||||
return rc;
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
{ // translate to a general DatabaseException
|
||||
throw generalException(e);
|
||||
|
||||
} // end catch
|
||||
finally
|
||||
{ // shut everything down
|
||||
SQLUtils.shutdown(rs);
|
||||
SQLUtils.shutdown(stmt);
|
||||
SQLUtils.shutdown(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end searchProperty
|
||||
|
||||
int searchPropertyCount(int nsid, String name, SearchMode mode, String term) throws DatabaseException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{ // get a connection
|
||||
conn = getConnection();
|
||||
|
||||
// prepare and execute a query (note that we assemble it in SQL form)
|
||||
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM users u, userprop p WHERE u.uid = p.uid "
|
||||
+ "AND u.is_anon = 0 AND p.nsid = ");
|
||||
sql.append(nsid).append(" AND p.prop_name = '").append(m_utils.encodeString(name)).append("' AND p.prop_value ");
|
||||
sql.append(preparePropertySearchTerm(mode,term));
|
||||
sql.append(';');
|
||||
stmt = conn.createStatement();
|
||||
rs = stmt.executeQuery(sql.toString());
|
||||
return SQLUtils.getReturnCountInt(rs,1);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
{ // translate to a general DatabaseException
|
||||
throw generalException(e);
|
||||
|
||||
} // end catch
|
||||
finally
|
||||
{ // shut everything down
|
||||
SQLUtils.shutdown(rs);
|
||||
SQLUtils.shutdown(stmt);
|
||||
SQLUtils.shutdown(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end searchPropertyCount
|
||||
|
||||
int[] searchName(SearchMode mode, String term, int offset, int count) throws DatabaseException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{ // get a connection
|
||||
conn = getConnection();
|
||||
|
||||
// prepare and execute a query (note that we assemble it in SQL form)
|
||||
StringBuffer sql = new StringBuffer("SELECT uid FROM users WHERE is_anon = 0 AND username ");
|
||||
if (SearchMode.PREFIX.equals(mode))
|
||||
sql.append("LIKE '").append(m_utils.encodeStringWildcards(term)).append("%'");
|
||||
else if (SearchMode.SUBSTRING.equals(mode))
|
||||
sql.append("LIKE '%").append(m_utils.encodeStringWildcards(term)).append("%'");
|
||||
else if (SearchMode.REGEXP.equals(mode))
|
||||
sql.append("REGEXP '").append(m_utils.encodeString(term)).append('\'');
|
||||
sql.append(" ORDER BY username LIMIT ").append(offset).append(", ").append(count+1).append(';');
|
||||
stmt = conn.createStatement();
|
||||
rs = stmt.executeQuery(sql.toString());
|
||||
|
||||
// We *know* the maximum number of indexes that can be returned, so allocate a temporary array big
|
||||
// enough to hold them all.
|
||||
int[] tmp = new int[count+1];
|
||||
int ct = 0;
|
||||
while (rs.next())
|
||||
tmp[ct++] = rs.getInt(1);
|
||||
|
||||
// Create the actual return array and fill it.
|
||||
int[] rc = new int[ct];
|
||||
System.arraycopy(tmp,0,rc,0,ct);
|
||||
return rc;
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
{ // translate to a general DatabaseException
|
||||
throw generalException(e);
|
||||
|
||||
} // end catch
|
||||
finally
|
||||
{ // shut everything down
|
||||
SQLUtils.shutdown(rs);
|
||||
SQLUtils.shutdown(stmt);
|
||||
SQLUtils.shutdown(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end searchName
|
||||
|
||||
int searchNameCount(SearchMode mode, String term) throws DatabaseException
|
||||
{
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{ // get a connection
|
||||
conn = getConnection();
|
||||
|
||||
// prepare and execute a query (note that we assemble it in SQL form)
|
||||
StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM users WHERE is_anon = 0 AND username ");
|
||||
if (SearchMode.PREFIX.equals(mode))
|
||||
sql.append("LIKE '").append(m_utils.encodeStringWildcards(term)).append("%'");
|
||||
else if (SearchMode.SUBSTRING.equals(mode))
|
||||
sql.append("LIKE '%").append(m_utils.encodeStringWildcards(term)).append("%'");
|
||||
else if (SearchMode.REGEXP.equals(mode))
|
||||
sql.append("REGEXP '").append(m_utils.encodeString(term)).append('\'');
|
||||
sql.append(';');
|
||||
stmt = conn.createStatement();
|
||||
rs = stmt.executeQuery(sql.toString());
|
||||
return SQLUtils.getReturnCountInt(rs,1);
|
||||
|
||||
} // end try
|
||||
catch (SQLException e)
|
||||
{ // translate to a general DatabaseException
|
||||
throw generalException(e);
|
||||
|
||||
} // end catch
|
||||
finally
|
||||
{ // shut everything down
|
||||
SQLUtils.shutdown(rs);
|
||||
SQLUtils.shutdown(stmt);
|
||||
SQLUtils.shutdown(conn);
|
||||
|
||||
} // end finally
|
||||
|
||||
} // end searchNameCount
|
||||
|
||||
} // end class AdvancedUserOps_mysql
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (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.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.app;
|
||||
|
||||
import java.util.List;
|
||||
import com.silverwrist.dynamo.db.UserManagement;
|
||||
import com.silverwrist.dynamo.except.DatabaseException;
|
||||
import com.silverwrist.dynamo.iface.DynamoUser;
|
||||
import com.silverwrist.venice.SearchMode;
|
||||
import com.silverwrist.venice.UserSearchField;
|
||||
|
||||
public interface AdvancedUserService extends UserManagement
|
||||
{
|
||||
public List searchForUsers(DynamoUser caller, UserSearchField field, SearchMode mode, String term,
|
||||
int offset, int count) throws DatabaseException;
|
||||
|
||||
public int getSearchUserCount(DynamoUser caller, UserSearchField field, SearchMode mode, String term)
|
||||
throws DatabaseException;
|
||||
|
||||
} // end interface AdvancedUserService
|
|
@ -60,7 +60,7 @@ public class CommunityManagerOps_mysql extends CommunityManagerOps
|
|||
else if (SearchMode.SUBSTRING.equals(mode))
|
||||
buf.append("LIKE '!%").append(m_utils.encodeStringWildcards(term)).append("%'");
|
||||
else if (SearchMode.REGEXP.equals(mode))
|
||||
{ // for regular expressions, if we're matching the start of the string, we have to inlcude the ! prefix
|
||||
{ // for regular expressions, if we're matching the start of the string, we have to include the ! prefix
|
||||
buf.append("REGEXP '");
|
||||
if (term.startsWith("^"))
|
||||
buf.append("^!").append(m_utils.encodeString(term.substring(1)));
|
||||
|
|
|
@ -21,6 +21,8 @@ public interface MenuRenderObject
|
|||
{
|
||||
public int getItemCount();
|
||||
|
||||
public int getItemContainingLinkText(String text);
|
||||
|
||||
public void setVariable(String name, String value);
|
||||
|
||||
public void setSelectedIndex(int index);
|
||||
|
|
|
@ -227,6 +227,12 @@ class InlineMenuRendering implements MenuRenderObject, SelfRenderable
|
|||
|
||||
} // end getItemCount
|
||||
|
||||
public int getItemContainingLinkText(String text)
|
||||
{
|
||||
return m_menudef.getItemContainingLinkText(text);
|
||||
|
||||
} // end getItemContainingLinkText
|
||||
|
||||
public void setVariable(String name, String value)
|
||||
{
|
||||
if (m_menudef.isVariable(name))
|
||||
|
|
|
@ -222,6 +222,12 @@ class LeftMenuRendering implements MenuRenderObject, SelfRenderable
|
|||
|
||||
} // end getItemCount
|
||||
|
||||
public int getItemContainingLinkText(String text)
|
||||
{
|
||||
return m_menudef.getItemContainingLinkText(text);
|
||||
|
||||
} // end getItemContainingLinkText
|
||||
|
||||
public void setVariable(String name, String value)
|
||||
{
|
||||
if (m_menudef.isVariable(name))
|
||||
|
|
|
@ -122,4 +122,18 @@ public class MenuDefinition
|
|||
|
||||
} // end getItem
|
||||
|
||||
public int getItemContainingLinkText(String text)
|
||||
{
|
||||
for (int i=0; i<m_items.size(); i++)
|
||||
{ // simple linear search through menu items
|
||||
MenuItemDefinition md = (MenuItemDefinition)(m_items.get(i));
|
||||
if (md.getLink().indexOf(text)>=0)
|
||||
return i;
|
||||
|
||||
} // end for
|
||||
|
||||
return -1;
|
||||
|
||||
} // end getItemContainingLinkText
|
||||
|
||||
} // end class MenuDefinition
|
||||
|
|
|
@ -215,6 +215,12 @@ class StandardMenuRendering implements MenuRenderObject, SelfRenderable, FramedC
|
|||
|
||||
} // end getItemCount
|
||||
|
||||
public int getItemContainingLinkText(String text)
|
||||
{
|
||||
return m_menudef.getItemContainingLinkText(text);
|
||||
|
||||
} // end getItemContainingLinkText
|
||||
|
||||
public void setVariable(String name, String value)
|
||||
{
|
||||
if (m_menudef.isVariable(name))
|
||||
|
|
|
@ -20,7 +20,9 @@ package com.silverwrist.venice.script;
|
|||
import com.silverwrist.dynamo.Namespaces;
|
||||
import com.silverwrist.dynamo.except.*;
|
||||
import com.silverwrist.dynamo.iface.*;
|
||||
import com.silverwrist.venice.app.AdvancedUserService;
|
||||
import com.silverwrist.venice.community.CategoryService;
|
||||
import com.silverwrist.venice.community.CommunityService;
|
||||
import com.silverwrist.venice.iface.*;
|
||||
|
||||
public class LibraryVeniceCast
|
||||
|
@ -81,6 +83,12 @@ public class LibraryVeniceCast
|
|||
|
||||
} // end getGlobalPropertiesStore
|
||||
|
||||
public final AdvancedUserService queryAdvancedUserService(Object obj)
|
||||
{
|
||||
return (AdvancedUserService)query(obj,AdvancedUserService.class);
|
||||
|
||||
} // end queryUserManagement
|
||||
|
||||
public final ButtonProvider queryButtonProvider(Object obj)
|
||||
{
|
||||
return (ButtonProvider)query(obj,ButtonProvider.class);
|
||||
|
@ -93,6 +101,12 @@ public class LibraryVeniceCast
|
|||
|
||||
} // end queryCategoryService
|
||||
|
||||
public final CommunityService queryCommunityService(Object obj)
|
||||
{
|
||||
return (CommunityService)query(obj,CommunityService.class);
|
||||
|
||||
} // end queryCategoryService
|
||||
|
||||
public final ContentBlockProvider queryContentBlockProvider(Object obj)
|
||||
{
|
||||
return (ContentBlockProvider)query(obj,ContentBlockProvider.class);
|
||||
|
|
|
@ -19,5 +19,7 @@ importPackage(Packages.com.silverwrist.dynamo.util);
|
|||
req = bsf.lookupBean("request"); // get request
|
||||
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||
|
||||
// TEMPORARY - redirect to the one find page we have implemented, Categories
|
||||
dynamo.scriptOutput(new Redirect("SERVLET","find_categories.js.vs"));
|
||||
// Retrieve the last Find page we visited from the session, and redirect to that page.
|
||||
session = rhelp.getSession();
|
||||
page = session.getObject("/find.js.vs","last.visited");
|
||||
dynamo.scriptOutput(new Redirect("SERVLET",page));
|
||||
|
|
|
@ -25,7 +25,11 @@ importPackage(Packages.com.silverwrist.venice.content);
|
|||
|
||||
req = bsf.lookupBean("request"); // get request
|
||||
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||
user = vlib.getUser(req); // get user
|
||||
session = rhelp.getSession(); // get the session
|
||||
user = vlib.getUser(session); // get user
|
||||
|
||||
// Tell the session we visited this page last.
|
||||
session.setObject("/find.js.vs","last.visited","find_categories.js.vs");
|
||||
|
||||
// Get the user's configured page size.
|
||||
pagesize = cast.toInteger(user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count"));
|
||||
|
@ -88,7 +92,8 @@ if (rc==null)
|
|||
// Load the profile menu.
|
||||
mprov = vcast.queryMenuProvider(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-menus"));
|
||||
menu = mprov.getInlineMenu(user,VeniceNamespaces.CONTENT_LAF_NAMESPACE,"find.menu",cast.newIntArray(0));
|
||||
menu.setSelectedIndex(0);
|
||||
ndx = menu.getItemContainingLinkText("find_categories.js.vs");
|
||||
menu.setSelectedIndex(ndx);
|
||||
rc.setParameter("menu",menu);
|
||||
|
||||
} // end if
|
||||
|
|
105
venice-data/scripts/find_users.js
Normal file
105
venice-data/scripts/find_users.js
Normal file
|
@ -0,0 +1,105 @@
|
|||
// The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
// (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.mozilla.org/MPL/>.
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
// language governing rights and limitations under the License.
|
||||
//
|
||||
// The Original Code is the Venice Web Communities System.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
importPackage(java.lang);
|
||||
importClass(Packages.com.silverwrist.dynamo.Namespaces);
|
||||
importPackage(Packages.com.silverwrist.dynamo.iface);
|
||||
importPackage(Packages.com.silverwrist.dynamo.util);
|
||||
importClass(Packages.com.silverwrist.venice.SearchMode);
|
||||
importClass(Packages.com.silverwrist.venice.UserSearchField);
|
||||
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
|
||||
importClass(Packages.com.silverwrist.venice.app.AdvancedUserService);
|
||||
importPackage(Packages.com.silverwrist.venice.content);
|
||||
|
||||
req = bsf.lookupBean("request"); // get request
|
||||
rhelp = bsf.lookupBean("request_help"); // get request helper
|
||||
session = rhelp.getSession(); // get the session
|
||||
user = vlib.getUser(session); // get user
|
||||
|
||||
// Tell the session we visited this page last.
|
||||
session.setObject("/find.js.vs","last.visited","find_users.js.vs");
|
||||
|
||||
// Get the user's configured page size.
|
||||
pagesize = cast.toInteger(user.getObject(VeniceNamespaces.USER_SETTINGS_NAMESPACE,"search.result.count"));
|
||||
|
||||
field = UserSearchField.USERNAME;
|
||||
mode = SearchMode.PREFIX;
|
||||
term = "";
|
||||
ofs = 0;
|
||||
fcount = -1;
|
||||
results = null;
|
||||
rc = null;
|
||||
|
||||
if (rhelp.isVerb("POST"))
|
||||
{ // Read the form parameters
|
||||
field = UserSearchField.getEnum(rhelp.getParameter("field"));
|
||||
mode = SearchMode.getEnum(rhelp.getParameter("mode"));
|
||||
term = rhelp.getParameter("term");
|
||||
ofs = rhelp.getParameterInt("ofs",0);
|
||||
fcount = rhelp.getParameterInt("fcount",-1);
|
||||
|
||||
// Adjust offset based on the button that was clicked.
|
||||
if (rhelp.isImageButtonClicked("search"))
|
||||
{ // beginning of a new search
|
||||
ofs = 0;
|
||||
fcount = -1;
|
||||
|
||||
} // end if
|
||||
else if (rhelp.isImageButtonClicked("previous"))
|
||||
ofs = Math.max(ofs - pagesize,0);
|
||||
else if (rhelp.isImageButtonClicked("next"))
|
||||
ofs += pagesize;
|
||||
|
||||
// Get the advanced user service object.
|
||||
usersvc = vcast.queryAdvancedUserService(rhelp.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"adv-users"));
|
||||
|
||||
try
|
||||
{ // search for users!
|
||||
if (fcount<0)
|
||||
fcount = usersvc.getSearchUserCount(user,field,mode,term);
|
||||
results = usersvc.searchForUsers(user,field,mode,term,ofs,pagesize);
|
||||
|
||||
} // end try
|
||||
catch (e)
|
||||
{ // exception thrown
|
||||
rc = new ErrorBox("Database Error",e,"SERVLET","find_users.js.vs");
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end else
|
||||
|
||||
if (rc==null)
|
||||
{ // create the VelocityView for the output
|
||||
rc = new VelocityView("Find Users","find_users.vm");
|
||||
rc.setParameter("field",field.getName());
|
||||
rc.setParameter("mode",mode.getName());
|
||||
rc.setParameter("term",term.toString());
|
||||
rc.setParameter("ofs",cast.toIntegerObject(ofs));
|
||||
rc.setParameter("fcount",cast.toIntegerObject(fcount));
|
||||
rc.setParameter("pagesize",cast.toIntegerObject(pagesize));
|
||||
if (results!=null)
|
||||
rc.setParameter("results",results);
|
||||
|
||||
// Load the profile menu.
|
||||
mprov = vcast.queryMenuProvider(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-menus"));
|
||||
menu = mprov.getInlineMenu(user,VeniceNamespaces.CONTENT_LAF_NAMESPACE,"find.menu",cast.newIntArray(0));
|
||||
ndx = menu.getItemContainingLinkText("find_users.js.vs");
|
||||
menu.setSelectedIndex(ndx);
|
||||
rc.setParameter("menu",menu);
|
||||
|
||||
} // end if
|
||||
|
||||
dynamo.scriptOutput(rc);
|
|
@ -46,8 +46,7 @@ view.setPageQID("user/" + user.getName());
|
|||
priv = cast.toOptionSet(user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"privacy"));
|
||||
|
||||
// get the user photo renderer
|
||||
uphoto = vcast.queryRenderImage(req_help.getRequestObject(VeniceNamespaces.DYNAMO_OBJECT_NAMESPACE,
|
||||
"venice-userphoto"));
|
||||
uphoto = vcast.queryRenderImage(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-userphoto"));
|
||||
|
||||
// set the view parameters
|
||||
view.setParameter("uid",cast.toIntegerObject(user.getUID()));
|
||||
|
@ -66,7 +65,8 @@ if (photo_url==null)
|
|||
view.setParameter("photo",uphoto.getRenderingObject(photo_url));
|
||||
view.setParameter("date_create",user.creationDate);
|
||||
view.setParameter("date_lastlogin",user.lastAccessDate);
|
||||
view.setParameter("date_lastupdate",user.getObject(VeniceNamespaces.USER_PROFILE_NAMESPACE,"last.update"));
|
||||
view.setParameter("date_lastupdate",PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,
|
||||
"last.update"));
|
||||
|
||||
buf = new StringBuffer();
|
||||
s = PropertyUtils.getPropertyNoErr(user,VeniceNamespaces.USER_PROFILE_NAMESPACE,"name.prefix");
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
// Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
|
||||
|
@ -62,6 +62,10 @@ if (rhelp.isRequestType("_SESSION") && rhelp.isVerb("PUT"))
|
|||
// Now set up the established user (either the one that just logged in or Anonymous_Honyak).
|
||||
dynamo.exec("/util/setup_user.js");
|
||||
|
||||
// Configure other session attributes.
|
||||
session = rhelp.getSession();
|
||||
session.setObject("/find.js.vs","last.visited","find_categories.js.vs");
|
||||
|
||||
} // end if (session is HTTP)
|
||||
|
||||
} // end if (session-PUT event)
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#macro( encodeURL $data )$std.encodeURL($data)#end
|
||||
|
||||
#macro( getProperty $obj $namespace $name )$std.getProperty($data,$namespace,$name)#end
|
||||
|
||||
#macro( render $obj )$std.renderObject($obj)#end
|
||||
|
||||
#macro( renderDialog $dlg )$std.renderDialog($dlg)#end
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*#
|
||||
#*
|
||||
Parameters:
|
||||
mode = Search mode
|
||||
mode = Search mode (string equivalent)
|
||||
term = Search term
|
||||
ofs = Offset within the search we're at right now
|
||||
fcount = Total number of items found in current search
|
||||
|
|
142
venice-data/velocity/find_users.vm
Normal file
142
venice-data/velocity/find_users.vm
Normal file
|
@ -0,0 +1,142 @@
|
|||
#*
|
||||
The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
(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.mozilla.org/MPL/>.
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
language governing rights and limitations under the License.
|
||||
|
||||
The Original Code is the Venice Web Communities System.
|
||||
|
||||
The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
*#
|
||||
#*
|
||||
Parameters:
|
||||
field = Search field (string equivalent)
|
||||
mode = Search mode (string equivalent)
|
||||
term = Search term
|
||||
ofs = Offset within the search we're at right now
|
||||
fcount = Total number of items found in current search
|
||||
pagesize = Number of items to display per page
|
||||
results = Results list from find, a List of DynamoUser objects (may be null)
|
||||
menu = Tab menu to render across the top
|
||||
*#
|
||||
#render( $menu )
|
||||
#header1( "Find Users" )
|
||||
<form method="POST" action="#formatURL( "SERVLET" "find_users.js.vs")">
|
||||
<input type="hidden" name="ofs" value="0">
|
||||
#comment( "Find Users form" )
|
||||
<div align="left"><p>
|
||||
Display all users whose
|
||||
<select name="field" size="1">
|
||||
<option value="USERNAME" #if( $field.equals("USERNAME") )selected="selected"#end >username</option>
|
||||
<option value="DESCRIPTION" #if( $field.equals("DESCRIPTION") )selected="selected"#end >description</option>
|
||||
<option value="FIRSTNAME" #if( $field.equals("FIRSTNAME") )selected="selected"#end >first name</option>
|
||||
<option value="LASTNAME" #if( $field.equals("LASTNAME") )selected="selected"#end >last name</option>
|
||||
</select>
|
||||
<select name="mode" size="1">
|
||||
<option value="PREFIX" #if( $mode.equals("PREFIX") )selected="selected"#end >starts with the string</option>
|
||||
<option value="SUBSTRING" #if( $mode.equals("SUBSTRING") )selected="selected"#end >contains the string</option>
|
||||
<option value="REGEXP" #if( $mode.equals("REGEXP") )selected="selected"#end >matches the regular
|
||||
expression</option>
|
||||
</select>
|
||||
<input type="text" name="term" size="32" maxlength="255" value="$!term" /></p>
|
||||
<p>#button( "INPUT" "search" )</p>
|
||||
</div>
|
||||
#comment( "end Find Users form" )
|
||||
</form>
|
||||
|
||||
#if( $results )
|
||||
## Do a tricky set of computations here to figure out what we need to display in terms of the search results
|
||||
## and the form to the right that lets us page through results.
|
||||
#set( $resultcount = $results.size() )
|
||||
#set( $is_next = 0 )
|
||||
#set( $is_prev = 0 )
|
||||
#if( $resultcount > $pagesize )
|
||||
#set( $resultcount = $pagesize )
|
||||
#set( $is_next = 1 )
|
||||
#end
|
||||
#if( $ofs > 0 )
|
||||
#set( $is_prev = 1 )
|
||||
#end
|
||||
#set( $is_form = $is_next + $is_prev )
|
||||
#set( $ndx_first = $ofs + 1 )
|
||||
#set( $ndx_last = $ofs + $pagesize )
|
||||
#if( $ndx_last > $fcount )
|
||||
#set( $ndx_last = $fcount )
|
||||
#end
|
||||
|
||||
#comment( "Results display" )
|
||||
<hr />
|
||||
<table width="100%" border="0" align="center"><tr valign="middle">
|
||||
<td width="50%" align="left">
|
||||
<b>Search Results</b>
|
||||
#if( $is_form >= 1 )
|
||||
(Displaying ${ndx_first}-${ndx_last} of ${fcount})
|
||||
#end
|
||||
</td>
|
||||
<td width="50%" align="right">
|
||||
#if( $is_form >= 1 )
|
||||
#comment( "Results navigation form" )
|
||||
<form method="POST" action="#formatURL( "SERVLET" "find_users.js.vs")">
|
||||
<input type="hidden" name="field" value="$field" />
|
||||
<input type="hidden" name="mode" value="$mode" />
|
||||
<input type="hidden" name="term" value="$term" />
|
||||
<input type="hidden" name="ofs" value="$ofs" />
|
||||
<input type="hidden" name="fcount" value="$fcount" />
|
||||
#if( $is_prev == 1 )
|
||||
#button( "INPUT" "previous" )
|
||||
#else
|
||||
#button( "IMAGE" "0transparent" )
|
||||
#end
|
||||
|
||||
#if( $is_next == 1 )
|
||||
#button( "INPUT" "next" )
|
||||
#else
|
||||
#button( "IMAGE" "0transparent" )
|
||||
#end
|
||||
</form>
|
||||
#else
|
||||
|
||||
#end
|
||||
</td>
|
||||
</tr></table>
|
||||
|
||||
#if( $fcount > 0 )
|
||||
#set( $i = $resultcount )
|
||||
#set( $prof_ns = "http://www.silverwrist.com/NS/venice/2002/12/31/user.profile" )
|
||||
<table border="0" align="left" cellpadding="0" cellspacing="4">
|
||||
#foreach( $usr in $results )
|
||||
#set( $i = $i - 1 )
|
||||
#if( $i >= 0 )
|
||||
#set( $first = $std.getProperty($usr,$prof_ns,"name.given") )
|
||||
#set( $last = $std.getProperty($usr,$prof_ns,"name.family") )
|
||||
#set( $city = $std.getProperty($usr,$prof_ns,"locality") )
|
||||
#set( $state = $std.getProperty($usr,$prof_ns,"region") )
|
||||
#set( $country = $std.getProperty($usr,$prof_ns,"country") )
|
||||
#set( $descr = $std.getProperty($usr,$prof_ns,"description") )
|
||||
<tr valign="top">
|
||||
<td align="center" width="14">#bullet()</td>
|
||||
<td align="left" class="content">
|
||||
<a href="#formatURL( "SERVLET" "user/${usr.Name}" )">#encodeHTML( $usr.Name )</a><br />
|
||||
#encodeHTML( $first ) #encodeHTML( $last ), from #encodeHTML( $city ), #encodeHTML( $state )
|
||||
#encodeHTML( $country.getCode() )
|
||||
#if( $descr )
|
||||
<br /><em>#encodeHTML( $descr )</em>
|
||||
#end
|
||||
</td>
|
||||
</tr>
|
||||
#end
|
||||
#end
|
||||
</table>
|
||||
#else
|
||||
<em>No users found.</em>
|
||||
#end
|
||||
|
||||
#comment( "End results display" )
|
||||
#end
|
Loading…
Reference in New Issue
Block a user