diff --git a/conf-sso/sp/dynamo.xml b/conf-sso/sp/dynamo.xml index 90b04c6..ecce4cf 100644 --- a/conf-sso/sp/dynamo.xml +++ b/conf-sso/sp/dynamo.xml @@ -169,6 +169,12 @@ + + + + + + diff --git a/conf/dynamo-venice.xml b/conf/dynamo-venice.xml index 57c7d3a..c3aa33a 100644 --- a/conf/dynamo-venice.xml +++ b/conf/dynamo-venice.xml @@ -168,6 +168,12 @@ + + + + + + diff --git a/conf/std_render_macro_library.vm b/conf/std_render_macro_library.vm index da62ded..90f78ff 100644 --- a/conf/std_render_macro_library.vm +++ b/conf/std_render_macro_library.vm @@ -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 diff --git a/conf/venice-db-init-mysql.sql b/conf/venice-db-init-mysql.sql index ab64df7..51be039 100644 --- a/conf/venice-db-init-mysql.sql +++ b/conf/venice-db-init-mysql.sql @@ -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'); diff --git a/src/dynamo-framework/com/silverwrist/dynamo/velocity/StdObject.java b/src/dynamo-framework/com/silverwrist/dynamo/velocity/StdObject.java index ebc5923..2f920ed 100644 --- a/src/dynamo-framework/com/silverwrist/dynamo/velocity/StdObject.java +++ b/src/dynamo-framework/com/silverwrist/dynamo/velocity/StdObject.java @@ -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); diff --git a/src/venice-base/com/silverwrist/venice/UserSearchField.java b/src/venice-base/com/silverwrist/venice/UserSearchField.java new file mode 100644 index 0000000..8f1c50a --- /dev/null +++ b/src/venice-base/com/silverwrist/venice/UserSearchField.java @@ -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 . + * + * 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 , + * 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 diff --git a/src/venice-base/com/silverwrist/venice/app/AdvancedUserManager.java b/src/venice-base/com/silverwrist/venice/app/AdvancedUserManager.java new file mode 100644 index 0000000..62cf625 --- /dev/null +++ b/src/venice-base/com/silverwrist/venice/app/AdvancedUserManager.java @@ -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 . + * + * 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 , + * 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. + * + * 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 , + * 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 diff --git a/src/venice-base/com/silverwrist/venice/app/AdvancedUserOps_mysql.java b/src/venice-base/com/silverwrist/venice/app/AdvancedUserOps_mysql.java new file mode 100644 index 0000000..1e57805 --- /dev/null +++ b/src/venice-base/com/silverwrist/venice/app/AdvancedUserOps_mysql.java @@ -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 . + * + * 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 , + * 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 diff --git a/src/venice-base/com/silverwrist/venice/app/AdvancedUserService.java b/src/venice-base/com/silverwrist/venice/app/AdvancedUserService.java new file mode 100644 index 0000000..e8772f9 --- /dev/null +++ b/src/venice-base/com/silverwrist/venice/app/AdvancedUserService.java @@ -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 . + * + * 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 , + * 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 diff --git a/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps_mysql.java b/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps_mysql.java index 609c2b9..5a5879b 100644 --- a/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps_mysql.java +++ b/src/venice-base/com/silverwrist/venice/community/CommunityManagerOps_mysql.java @@ -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))); diff --git a/src/venice-base/com/silverwrist/venice/iface/MenuRenderObject.java b/src/venice-base/com/silverwrist/venice/iface/MenuRenderObject.java index 876dc10..52d4b5e 100644 --- a/src/venice-base/com/silverwrist/venice/iface/MenuRenderObject.java +++ b/src/venice-base/com/silverwrist/venice/iface/MenuRenderObject.java @@ -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); diff --git a/src/venice-base/com/silverwrist/venice/menu/InlineMenuRendering.java b/src/venice-base/com/silverwrist/venice/menu/InlineMenuRendering.java index 1b21065..37281d8 100644 --- a/src/venice-base/com/silverwrist/venice/menu/InlineMenuRendering.java +++ b/src/venice-base/com/silverwrist/venice/menu/InlineMenuRendering.java @@ -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)) diff --git a/src/venice-base/com/silverwrist/venice/menu/LeftMenuRendering.java b/src/venice-base/com/silverwrist/venice/menu/LeftMenuRendering.java index b3505ef..201efaa 100644 --- a/src/venice-base/com/silverwrist/venice/menu/LeftMenuRendering.java +++ b/src/venice-base/com/silverwrist/venice/menu/LeftMenuRendering.java @@ -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)) diff --git a/src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java b/src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java index 73faee8..2be4c88 100644 --- a/src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java +++ b/src/venice-base/com/silverwrist/venice/menu/MenuDefinition.java @@ -122,4 +122,18 @@ public class MenuDefinition } // end getItem + public int getItemContainingLinkText(String text) + { + for (int i=0; i=0) + return i; + + } // end for + + return -1; + + } // end getItemContainingLinkText + } // end class MenuDefinition diff --git a/src/venice-base/com/silverwrist/venice/menu/StandardMenuRendering.java b/src/venice-base/com/silverwrist/venice/menu/StandardMenuRendering.java index 2059aa6..8c6a250 100644 --- a/src/venice-base/com/silverwrist/venice/menu/StandardMenuRendering.java +++ b/src/venice-base/com/silverwrist/venice/menu/StandardMenuRendering.java @@ -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)) diff --git a/src/venice-base/com/silverwrist/venice/script/LibraryVeniceCast.java b/src/venice-base/com/silverwrist/venice/script/LibraryVeniceCast.java index c1c2292..d702a1b 100644 --- a/src/venice-base/com/silverwrist/venice/script/LibraryVeniceCast.java +++ b/src/venice-base/com/silverwrist/venice/script/LibraryVeniceCast.java @@ -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); diff --git a/venice-data/scripts/find.js b/venice-data/scripts/find.js index dac2c31..fc88b3a 100644 --- a/venice-data/scripts/find.js +++ b/venice-data/scripts/find.js @@ -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)); diff --git a/venice-data/scripts/find_categories.js b/venice-data/scripts/find_categories.js index fff69b8..aa50563 100644 --- a/venice-data/scripts/find_categories.js +++ b/venice-data/scripts/find_categories.js @@ -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 diff --git a/venice-data/scripts/find_users.js b/venice-data/scripts/find_users.js new file mode 100644 index 0000000..df420be --- /dev/null +++ b/venice-data/scripts/find_users.js @@ -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 . +// +// 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 , +// 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); diff --git a/venice-data/util/create_profile.js b/venice-data/util/create_profile.js index 2fbd6fb..cc97d35 100644 --- a/venice-data/util/create_profile.js +++ b/venice-data/util/create_profile.js @@ -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"); diff --git a/venice-data/util/session_init.js b/venice-data/util/session_init.js index 2342e7a..9220a3d 100644 --- a/venice-data/util/session_init.js +++ b/venice-data/util/session_init.js @@ -10,7 +10,7 @@ // // The Initial Developer of the Original Code is Eric J. Bowersox , // 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) diff --git a/venice-data/velocity/VM_global_library.vm b/venice-data/velocity/VM_global_library.vm index 6c234bf..a01d7c2 100644 --- a/venice-data/velocity/VM_global_library.vm +++ b/venice-data/velocity/VM_global_library.vm @@ -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 diff --git a/venice-data/velocity/find_categories.vm b/venice-data/velocity/find_categories.vm index c54eb4b..662aaaf 100644 --- a/venice-data/velocity/find_categories.vm +++ b/venice-data/velocity/find_categories.vm @@ -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 diff --git a/venice-data/velocity/find_users.vm b/venice-data/velocity/find_users.vm new file mode 100644 index 0000000..f15c3c9 --- /dev/null +++ b/venice-data/velocity/find_users.vm @@ -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 . + + 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 , + 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" ) +
+ + #comment( "Find Users form" ) +

+ Display all users whose  +   +    +

+

#button( "INPUT" "search" )

+
+ #comment( "end Find Users 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" ) +
+ + + +
+ Search Results + #if( $is_form >= 1 ) + (Displaying ${ndx_first}-${ndx_last} of ${fcount}) + #end + + #if( $is_form >= 1 ) + #comment( "Results navigation form" ) +
+ + + + + + #if( $is_prev == 1 ) + #button( "INPUT" "previous" ) + #else + #button( "IMAGE" "0transparent" ) + #end +    + #if( $is_next == 1 ) + #button( "INPUT" "next" ) + #else + #button( "IMAGE" "0transparent" ) + #end +
+ #else +   + #end +
+ + #if( $fcount > 0 ) + #set( $i = $resultcount ) + #set( $prof_ns = "http://www.silverwrist.com/NS/venice/2002/12/31/user.profile" ) + + #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") ) + + + + + #end + #end +
#bullet() + #encodeHTML( $usr.Name )
+ #encodeHTML( $first ) #encodeHTML( $last ), from #encodeHTML( $city ), #encodeHTML( $state ) +  #encodeHTML( $country.getCode() ) + #if( $descr ) +
#encodeHTML( $descr ) + #end +
+ #else + No users found. + #end + + #comment( "End results display" ) +#end