Index: openacs-4/packages/acs-authentication/lib/local-search.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/lib/local-search.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-authentication/lib/local-search.adp 8 Sep 2008 20:15:50 -0000 1.1
@@ -0,0 +1 @@
+
Index: openacs-4/packages/acs-authentication/lib/local-search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/lib/local-search.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-authentication/lib/local-search.tcl 8 Sep 2008 20:15:50 -0000 1.1
@@ -0,0 +1,74 @@
+# creation-date 2007-01-21
+# author Dave Bauer (dave@solutiongrove.com)
+# includable search form
+# results should be appended to multirow called users
+# ADP level
+# default local authority search
+
+ad_form -name user-search -method GET -export {authority_id object_id} -form {
+ {search_text:text(text),optional
+ {label "Search"}
+ }
+} -on_request {
+ element set_value user-search search_text $search_text
+} -on_submit {
+
+}
+if {![info exists orderby]} {
+ set orderby ""
+}
+set search_text [string tolower $search_text]
+set search_terms [list]
+foreach term [split $search_text] {
+ lappend search_terms $term
+}
+
+set name_search "'()'"
+if {[llength $search_terms]} {
+ set name_search "([join $search_terms |])"
+}
+
+set system_name [ad_system_name]
+ db_foreach get_users "
+select
+first_names,
+last_name,
+email,
+username,
+user_id,
+authority_id
+from cc_users
+where
+(
+ lower(first_names) ~ :name_search
+ or lower(last_name) ~ :name_search
+)
+or lower(username) like '%' || :search_text || '%'
+or lower(email) like '%' || :search_text || '%'
+" {
+
+set status [list]
+if {[info exists object_id]} {
+ set group_member_p [permission::permission_p -object_id $object_id -party_id $user_id -privilege $privilege]
+ set status ""
+
+} else {
+ set group_member_p [group::member_p -group_id $group_id -user_id $user_id -cascade]
+ set group_name [group::get_element -element group_name -group_id $group_id]
+ if {$group_member_p} {
+ lappend status "[_ acs-authentication.Member_of_group_name]"
+ } else {
+ lappend status "[_ acs-authentication.Not_a_member_of_group_name]"
+ }
+ set status [join $status "
"]
+}
+ template::multirow -ulevel 2 -local append users $first_names $last_name $username $email $status $group_member_p "" "" "" $user_id $authority_id
+}
+
+set orderby_list [split $orderby ,]
+set orderby_column [lindex $orderby_list 0]
+set direction [lindex $orderby_list 1]
+set direction [string map {asc -increasing desc -decreasing} $direction]
+if {$orderby_column ne ""} {
+ eval "template::multirow -ulevel 2 -local sort users $direction $orderby_column"
+}
\ No newline at end of file
Index: openacs-4/packages/acs-authentication/lib/search.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/lib/search.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-authentication/lib/search.adp 8 Sep 2008 20:15:50 -0000 1.1
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+@authorities.pretty_name@
+
+
+
+
+
+
+
+
+
+
+
+
+#acs-authentication.lt_Not_getting_the_results_you_expected#
+
+
+@authorities.pretty_name@
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/acs-authentication/lib/search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-authentication/lib/search.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/acs-authentication/lib/search.tcl 8 Sep 2008 20:15:50 -0000 1.1
@@ -0,0 +1,130 @@
+ad_page_contract {
+ Includable page to search users in any authority
+
+ To grant permission on an object
+ Including page can pass in
+ add_permisison (list of Label, URL)
+ object_id
+ privilege
+
+ OR
+ To add a member of a group
+ add_to_subsite (list of label url)
+ add_to_main_site (optional) (list of label url)
+ group_id (optional default to subsite applicaiton group)
+ rel_type (default to membership_rel)
+
+} {
+ {search_text ""}
+ {authority_id ""}
+ orderby:optional
+}
+
+set authority_options [auth::authority::get_authority_options]
+set default_authority_id [lindex [lindex $authority_options 0] 1]
+if {$authority_id eq ""} {
+ set authority_id $default_authority_id
+}
+
+if {![info exists rel_type] || $rel_type eq ""} {
+ set rel_type membership_rel
+}
+if {![info exists package_id] || $package_id eq ""} {
+ set package_id [ad_conn subsite_id]
+}
+
+if {![info exists return_url] || $return_url eq ""} {
+ set return_url [ad_return_url]
+}
+set selected_authority_id $authority_id
+
+set bulk_actions [list]
+# we need a base url for adding a user to the site (main subsite or dotlrn, etc...)
+if {[info exists add_to_main_site]} {
+ foreach elm $add_to_main_site {
+ lappend bulk_actions $elm
+ }
+}
+
+# we need a base url for adding a user to a specific community (subsite or dotlrn class instance etc...) (optional)
+if {[info exists add_to_subsite]} {
+ foreach elm $add_to_subsite {
+ lappend bulk_actions $elm
+ }
+}
+if {[info exists add_to_subsite] && [llength $add_to_subsite]} {
+ set add_user_url [lindex $add_to_subsite 1]
+ set add_user_label [lindex $add_to_subsite 0]
+} elseif {[info exists add_to_main_site]} {
+ set add_user_url [lindex $add_to_main_site 1]
+ set add_user_label "[_ acs-authentication.Add_to_system_name [list system_name [ad_system_name]]]"
+}
+if {[info exists add_permission] && [llength $add_permission]} {
+ set add_user_url [lindex $add_permission 1]
+ set add_user_label [lindex $add_permission 0]
+ lappend bulk_actions $add_user_label $add_user_url $add_user_label
+}
+if {![regexp {\?} $add_user_url]} {
+ set add_user_url "${add_user_url}?"
+}
+if {![info exists group_id] || $group_id eq ""} {
+ set group_id [application_group::group_id_from_package_id -package_id $package_id]
+}
+# generate authority links
+
+ template::multirow create users first last username email auth_status group_member_p create_account_url actions extra_attributes user_id authority_id
+ns_log debug "MEMBER SEARCH TCL level='[template::adp_level]' [uplevel \#[template::adp_level] "info vars"]"
+ template::list::create \
+ -no_data "Search returned no results" \
+ -name users \
+ -multirow users \
+ -key userkey \
+ -has_checkboxes \
+ -bulk_action_export_vars { authority_id return_url object_id } \
+ -filters {search_text {} authority_id {} object_id {}} \
+ -elements [list \
+ checkbox {
+ display_template {}} \
+ first [list label "First Name" link_url_eval "\[export_vars -base \"$member_url\" {user_id} \]"] \
+ last [list label "Last Name" link_url_eval "\[export_vars -base \"$member_url\" {user_id} \]"] \
+ username [list label "Username" link_url_eval "\[export_vars -base \"$member_url\" {user_id} \]"] \
+ email {label "Email"} \
+ auth_status {
+ label "Status"
+ } \
+ actions [list label "Actions" display_template "$add_user_label"] \
+ extra_attributes {label "Extra Attributes"} \
+ user_id [list hide_p [expr {!$admin_p}] label "" display_template "User Admin Page"] \
+ ] -bulk_actions $bulk_actions \
+ -orderby {first {orderby first_names} last {orderby last_name} username {orderby username} email {orderby email} auth_status {orderby auth_status}}
+
+template::multirow create authorities authority_id pretty_name local_authority_p search_url form_include
+
+foreach option_list [auth::authority::get_authority_options] {
+ set this_authority_id [lindex $option_list 1]
+ set local_authority_p [string match $this_authority_id [auth::authority::local]]
+ if {$local_authority_p} {
+ set local_authority_id $this_authority_id
+ set form_include /packages/acs-authentication/lib/local-search
+ } else {
+ set form_include [acs_sc::invoke -impl_id [auth::authority::get_element -authority_id $this_authority_id -element search_impl_id] -operation FormInclude]
+ }
+ if {$this_authority_id eq $selected_authority_id} {
+ set selected_form_include $form_include
+ }
+ template::multirow append authorities $this_authority_id [lindex $option_list 0] $local_authority_p [export_vars -base [ad_conn url] -no_empty {{authority_id $this_authority_id} search_text object_id}] $form_include
+}
+
+#template::multirow sort authorities -decreasing authority_id
+
+if {$selected_authority_id eq ""} {
+ set selected_authority_id $default_authority_id
+}
+set authority_id $selected_authority_id
+
+#set search_form_html [template::adp_include $selected_form_include [list authority_id $selected_authority_id search_text $search_text return_url $return_url orderby $orderby]]
+
+#
+if {![info exists orderby]} {
+ set orderby ""
+}
\ No newline at end of file