Index: openacs-4/packages/wp-slim/www/presentation-acl-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/presentation-acl-add.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/presentation-acl-add.adp 20 Apr 2001 20:51:24 -0000 1.1 +++ openacs-4/packages/wp-slim/www/presentation-acl-add.adp 18 Jun 2002 15:13:23 -0000 1.2 @@ -1,7 +1,7 @@ Add User -
+

Add User

@nav_bar@
Index: openacs-4/packages/wp-slim/www/presentation-acl-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/presentation-acl-add.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/wp-slim/www/presentation-acl-add.tcl 20 Apr 2001 20:51:24 -0000 1.1 +++ openacs-4/packages/wp-slim/www/presentation-acl-add.tcl 18 Jun 2002 15:13:23 -0000 1.2 @@ -24,7 +24,7 @@ set encoded_title [ns_urlencode $title] -set target "/wp/presentation-acl-add-2" +set target "[ad_conn package_url]/presentation-acl-add-2" set passthrough [list pres_item_id role title] set params [export_form_vars pres_item_id role title target passthrough] Index: openacs-4/packages/wp-slim/www/search.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/search.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/wp-slim/www/search.adp 18 Jun 2002 15:13:23 -0000 1.1 @@ -0,0 +1,47 @@ + +User Search in @group_name@ + +

User Search in @group_name@

+ + + for name or email matching "@keyword@" + + + for email "@email@" + + for last name "@last_name@" + + +
+ + + Index: openacs-4/packages/wp-slim/www/search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/search.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/wp-slim/www/search.tcl 18 Jun 2002 15:13:23 -0000 1.1 @@ -0,0 +1,148 @@ +ad_page_contract { + + Reusable page for searching for a user by email or last_name. + Returns to "target" with user_id_from_search, first_names_from_search, + ast_name_from_search, and email_from_search, and passing along all + form variables listed in "passthrough". + + @cvs-id $Id: search.tcl,v 1.1 2002/06/18 15:13:23 lars Exp $ + + @param email search string + @param last_name search string + @param keyword For looking through both email and last_name (optional) + @param target URL to return to + @param passthrough Form variables to pass along from caller + @param limit_to_users_in_group_id Limits search to users in the specified group id. This can be a comma separated list to allow searches within multiple groups. (optional) + + @author Jin Choi (jsc@arsdigita.com) +} { + {email ""} + {last_name ""} + keyword:optional + target + {passthrough ""} + {limit_users_in_group_id ""} +} -properties { + group_name:onevalue + search_type:onevalue + keyword:onevalue + email:onevalue + last_name:onevalue + export_authorize:onevalue + passthrough_parameters:onevalue +} + +# Check input. +set exception_count 0 +set exception_text "" + +if [info exists keyword] { + # this is an administrator + if { [empty_string_p $keyword] } { + incr exception_count + append exception_text "
  • You forgot to type a search string!\n" + } +} else { + # from one of the user pages + if { (![info exists email] || [empty_string_p $email]) && \ + (![info exists last_name] || [empty_string_p $last_name]) } { + incr exception_count + append exception_text "
  • You must specify either an email address or last name to search for.\n" + } + + if { [info exists email] && [info exists last_name] && \ + ![empty_string_p $email] && ![empty_string_p $last_name] } { + incr exception_count + append exception_text "
  • You can only specify either email or last name, not both.\n" + } + + if { ![info exists target] || [empty_string_p $target] } { + incr exception_count + append exception_text "
  • Target was not specified. This shouldn't have happened, +please contact the administrator +and let them know what happened.\n" + } +} + +if { $exception_count != 00 } { + ad_return_complaint $exception_count $exception_text + return +} + +#### +# Input okay. Now start building the SQL + +set where_clause [list] +if { [info exists keyword] } { + set search_type "keyword" + set sql_keyword "%[string tolower $keyword]%" + lappend where_clause "(email like :sql_keyword or lower(first_names || ' ' || last_name) like :sql_keyword)" +} elseif { [info exists email] && ![empty_string_p $email] } { + set search_type "email" + set sql_email "%[string tolower $email]%" + lappend where_clause "email like :sql_email" +} else { + set search_type "last" + set sql_last_name "%[string tolower $last_name]%" + lappend where_clause "lower(last_name) like :sql_last_name" +} + +lappend where_clause {member_state = 'approved'} + +if { ![info exists passthrough] } { + set passthrough_parameters "" +} else { + set passthrough_parameters "[export_entire_form_as_url_vars $passthrough]" +} + +if { [exists_and_not_null limit_to_users_in_group_id] } { +set query "select distinct first_names, last_name, email, member_state, email_verified_p, cu.user_id +from cc_users cu, group_member_map gm, membership_rels mr +where cu.user_id = gm.member_id + and gm.rel_id = mr.rel_id + and gm.group_id = :limit_to_users_in_group_id + and [join $where_clause "\nand "]" + +} else { +set query "select user_id, email_verified_p, first_names, last_name, email, member_state +from cc_users +where [join $where_clause "\nand "]" +} + + + +set i 0 + +set user_items "" + +set rowcount 0 + +db_foreach user_search_admin $query { + incr rowcount + + set user_id_from_search $user_id + set first_names_from_search $first_names + set last_name_from_search $last_name + set email_from_search $email + + set user_search:[set rowcount](user_id) $user_id + set user_search:[set rowcount](first_names) $first_names + set user_search:[set rowcount](last_name) $last_name + set user_search:[set rowcount](email) $email + set user_search:[set rowcount](export_vars) [export_url_vars user_id_from_search first_names_from_search last_name_from_search email_from_search] + set user_search:[set rowcount](member_state) $member_state +} + +set user_search:rowcount $rowcount + +# We are limiting the search to one group - display that group's name +if { [exists_and_not_null limit_to_users_in_group_id] && ![regexp {[^0-9]} $limit_to_users_in_group_id] } { + set group_name [db_string user_group_name_from_id "select group_name from user_groups where group_id = :limit_to_users_in_group_id"] +} else { + set group_name "" +} + +set export_authorize [export_ns_set_vars {url} {only_authorized_p}] + + +ad_return_template Index: openacs-4/packages/wp-slim/www/search.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/wp-slim/www/search.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/wp-slim/www/search.xql 18 Jun 2002 15:13:23 -0000 1.1 @@ -0,0 +1,11 @@ + + + + + + select group_name from user_groups where group_id = :limit_to_users_in_group_id + + + + +