Index: openacs-4/packages/contacts/lib/contacts.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.tcl,v
diff -u -r1.24 -r1.25
--- openacs-4/packages/contacts/lib/contacts.tcl 9 Sep 2005 22:19:22 -0000 1.24
+++ openacs-4/packages/contacts/lib/contacts.tcl 18 Oct 2005 23:04:21 -0000 1.25
@@ -1,6 +1,6 @@
set required_param_list [list]
-set optional_param_list [list base_url extend_p extend_values]
-set default_param_list [list orderby format query page page_size package_id search_id group_id ]
+set optional_param_list [list base_url extend_p extend_values attribute_values]
+set default_param_list [list orderby format query page page_size package_id search_id group_id]
set optional_unset_list [list]
# default values for default params
@@ -10,6 +10,8 @@
set _tasks_interval "7"
set admin_p 0
+set package_id [apm_package_id_from_key contacts]
+
foreach required_param $required_param_list {
set $required_param [ns_queryget $default_param]
if { ![exists_and_not_null required_param] } {
@@ -36,18 +38,24 @@
set group_where_clause ""
# Also we can extend this search.
# Is to allow extend the list by any extend_options defined in contact_extend_options
- set available_options [contact::extend::get_options -ignore_extends $extend_values -search_id $search_id]
+ set available_options [concat \
+ [list [list "- - - - - - - -" ""]] \
+ [contact::extend::get_options -ignore_extends $extend_values -search_id $search_id]]
+
ad_form -name extend -form {
{extend_option:text(select),optional
{label "[_ contacts.Available_Options]" }
- {options {{" - - - - - - -" ""} $available_options}}
+ {options {$available_options}}
}
{search_id:text(hidden)
{value "$search_id"}
}
{extend_values:text(hidden)
{value "$extend_values"}
}
+ {attribute_values:text(hidden)
+ {value $attribute_values}
+ }
} -on_submit {
# We clear the list when no value is submited, otherwise
# we acumulate the extend values.
@@ -56,8 +64,45 @@
} else {
lappend extend_values [list $extend_option]
}
- ad_returnredirect [export_vars -base "?" {search_id extend_values}]
+ ad_returnredirect [export_vars -base "?" {search_id extend_values attribute_values}]
}
+
+ # Now we are going to do the same for ams_attributes
+ set attribute_values_query ""
+ if { [exists_and_not_null attribute_values] } {
+ set attribute_values_query "and lam.attribute_id not in ([template::util::tcl_to_sql_list $attribute_values])"
+ }
+ set attribute_options [db_list_of_lists get_ams_options " "]
+ set ams_options [list [list "- - - - - - - - - -" ""]]
+ foreach attribute $attribute_options {
+ lappend ams_options [list [lang::util::localize [db_string get_ams_pretty_name { }]] $attribute]
+ }
+
+ ad_form -name ams_attributes -form {
+ {attribute_id:text(select),optional
+ {label "[_ contacts.Available_Attributes]:"}
+ {options { $ams_options }}
+ }
+ {search_id:text(hidden)
+ {value "$search_id"}
+ }
+ {attribute_values:text(hidden)
+ {value "$attribute_values"}
+ }
+ {extend_values:text(hidden)
+ {value $extend_values}
+ }
+ } -on_submit {
+ # We clear the list when no value is submited, otherwise
+ # we acumulate the attribute values.
+ if { [empty_string_p $attribute_id] } {
+ set attribute_values [list]
+ } else {
+ lappend attribute_values [list $attribute_id]
+ }
+ ad_returnredirect [export_vars -base "?" {search_id extend_values attribute_values}]
+ }
+
} else {
set group_where_clause "and group_distinct_member_map.group_id = [contacts::default_group]"
}
@@ -75,9 +120,6 @@
}
-set package_id [apm_package_id_from_key contacts]
-
-
switch $orderby {
"first_names,asc" {
set name_label "[_ contacts.Sort_by]: [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization]"
@@ -182,6 +224,19 @@
lappend row_list $name [list]
append extend_query "( $sub_query ) as $name,"
}
+
+# This is for the attributes
+set attr_extend [list]
+foreach attribute $attribute_values {
+ db_1row get_ams_info { }
+ set pretty_name [lang::util::localize $pretty_name]
+ lappend elements ${attribute}_$name [list label "$pretty_name" display_col ${attribute}_$name]
+ lappend row_list ${attribute}_$name [list]
+ lappend attr_extend "${attribute}_$name"
+}
+set attr_extend [join $attr_extend " "]
+
+
set actions [list]
if { $admin_p && [exists_and_not_null search_id] } {
set actions [list "[_ contacts.Set_default_extend]" "admin/ext-search-options?search_id=$search_id" "[_ contacts.Set_default_extend]" ]
@@ -205,6 +260,8 @@
-filters {
search_id {}
page_size {}
+ extend_values {}
+ attribute_values {}
tasks_interval {}
query {}
} -orderby {
@@ -247,9 +304,17 @@
}
}
-db_multirow -extend {contact_url name} -unclobber contacts contacts_select " " {
+set extend "$attr_extend contact_url name"
+
+db_multirow -extend $extend -unclobber contacts contacts_select " " {
set contact_url [contact::url -party_id $party_id]
set name [contact::name -party_id $party_id]
+ foreach attr $attr_extend {
+ set attribute_id [lindex [split $attr "_"] 0]
+ set attribute_name [string range $attr [expr [string length $attribute_id] + 1] [string length $attr]]
+ set attr_object_id [db_string get_attr_object_id { } -default ""]
+ set $attr [ams::value -object_id $attr_object_id -attribute_id $attribute_id -attribute_name $attribute_name]
+ }
}
if { [exists_and_not_null query] && [template::multirow size contacts] == 1 } {