Index: openacs-4/packages/contacts/lib/contacts-aggregated.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts-aggregated.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/contacts/lib/contacts-aggregated.tcl 29 Aug 2005 22:47:58 -0000 1.1 +++ openacs-4/packages/contacts/lib/contacts-aggregated.tcl 30 Aug 2005 21:31:04 -0000 1.2 @@ -23,9 +23,25 @@ # Get the search message set message [contact::search_pretty -search_id $search_id] -# Get the attribute name and the options for that attribute -set attr_name [attribute::pretty_name -attribute_id $attr_id] +# We check if the attr_id is -1, if it is we are going +# to search for the country in home_address or company_addres +set home_address_attr_id [db_string get_home_attr_id { } -default ""] +set company_address_attr_id [db_string get_company_attr_id { } -default ""] + +if { [string equal $attr_id "-1"] } { + set attr_name "[_ contacts.Country]" + set query_name get_countries_options + set result_query get_countries_results + set country_p 1 +} else { + # Get the attribute name and the options for that attribute + set attr_name [attribute::pretty_name -attribute_id $attr_id] + set query_name get_attribute_options + set result_query get_results + set country_p 0 +} + # Get the search_clasue used in the advanced search set search_clause [contact::search_clause -and \ -search_id $search_id \ @@ -50,13 +66,14 @@ } } -db_multirow -extend { result } contacts get_attribute_options { } { +db_multirow -extend { result } contacts $query_name { } { # We get the value_id here and not in the options query since # the value_id is only present when one attribute is associated # to one option, and we want to see every option. - - set value_id [db_string get_value_id { } -default 0] - set result [db_string get_results " " -default 0] + if { !$country_p } { + set value_id [db_string get_value_id { } -default 0] + } + set result [db_string $result_query " " -default 0] } Index: openacs-4/packages/contacts/lib/contacts-aggregated.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts-aggregated.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/contacts/lib/contacts-aggregated.xql 29 Aug 2005 22:47:58 -0000 1.1 +++ openacs-4/packages/contacts/lib/contacts-aggregated.xql 30 Aug 2005 21:31:04 -0000 1.2 @@ -13,6 +13,16 @@ + + + select + c.default_name as option, + c.iso + from + countries c + + + select @@ -58,4 +68,42 @@ + + + select + count(parties.party_id) + from + parties + where parties.party_id in ( + select + parties.party_id + from + parties + left join organizations on (parties.party_id = organizations.organization_id) + left join cr_items on (parties.party_id = cr_items.item_id) + left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ), + group_distinct_member_map + where parties.party_id = group_distinct_member_map.member_id + $search_clause + ) + and parties.party_id in ( + select + p.party_id + from + parties p, + ams_attribute_values a, + postal_addresses pa, + cr_items i, + cr_revisions r + where + i.item_id = p.party_id + and r.revision_id = i.latest_revision + and r.revision_id = a.object_id + and a.value_id = pa.address_id + and pa.country_code = :iso + ) + + + + Index: openacs-4/packages/contacts/tcl/attribute-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/attribute-procs.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/contacts/tcl/attribute-procs.tcl 29 Aug 2005 22:49:50 -0000 1.5 +++ openacs-4/packages/contacts/tcl/attribute-procs.tcl 30 Aug 2005 21:31:23 -0000 1.6 @@ -62,7 +62,9 @@ Returns a list of only the attributes that have multiple choices of the format {pretty_name attribute_id} } { - return [db_list_of_lists get_option_attributes { }] + set options [db_list_of_lists get_option_attributes { }] + lappend options [list "[_ contacts.Country]" "-1"] + return $options } }