Index: openacs-4/packages/contacts/lib/contacts.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/contacts/lib/contacts.tcl 9 Aug 2005 12:44:19 -0000 1.20 +++ openacs-4/packages/contacts/lib/contacts.tcl 12 Aug 2005 07:45:17 -0000 1.21 @@ -35,7 +35,7 @@ } else { if {[llength $group_id] > 1} { set where_group_id " IN ('[join $group_id "','"]')" - set group_by_group_id "group by parties.party_id , cr_revisions.revision_id, parties.email" + set group_by_group_id "group by parties.party_id , parties.email" } else { set where_group_id " = :group_id" } @@ -45,12 +45,16 @@ set package_id [apm_package_id_from_key contacts] -if { $orderby == "first_names,asc" } { - set name_order 0 - set name_label "[_ contacts.Sort_by]: [_ contacts.First_Names] | [_ contacts.Last_Name]" -} else { - set name_order 1 - set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name]" +switch $orderby { + "first_names,asc" { + set name_label "[_ contacts.Sort_by]: [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization]" + } + "last_name,asc" { + set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization]" + } + "organization,asc" { + set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization]" + } } append name_label "    [_ contacts.Show]: " @@ -147,14 +151,20 @@ } -orderby { first_names { label "[_ contacts.First_Name]" - orderby_asc "lower(contact__name(party_id,'f')) asc" - orderby_desc "lower(contact__name(party_id,'f')) asc" + orderby_asc "lower(first_names) asc" + orderby_desc "lower(first_names) asc" } last_name { label "[_ contacts.Last_Name]" - orderby_asc "lower(contact__name(party_id,'t')) asc" - orderby_desc "lower(contact__name(party_id,'t')) asc" + orderby_asc "lower(last_name) asc" + orderby_desc "lower(last_name) asc" } + organization { + label "[_ contacts.Last_Name]" + orderby_asc "lower(organizations.name) asc" + orderby_desc "lower(organizations.name) asc" + } + default_value first_names,asc } -formats { normal { @@ -179,8 +189,9 @@ } } -db_multirow -extend {contact_url} -unclobber contacts contacts_select {} { +db_multirow -extend {contact_url name} -unclobber contacts contacts_select {} { set contact_url [contact::url -party_id $party_id] + set name [contact::name -party_id $party_id] } if { [exists_and_not_null query] && [template::multirow size contacts] == 1 } { Index: openacs-4/packages/contacts/lib/contacts.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/contacts/lib/contacts.xql 9 Aug 2005 12:44:19 -0000 1.5 +++ openacs-4/packages/contacts/lib/contacts.xql 12 Aug 2005 07:45:17 -0000 1.6 @@ -3,9 +3,14 @@ -select parties.party_id - from parties 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 +select parties.party_id, organizations.name, + first_names, last_name + from parties + left join persons on (parties.party_id = persons.person_id) + left join organizations on (parties.party_id = organizations.organization_id), group_distinct_member_map, cr_items, cr_revisions where parties.party_id = group_distinct_member_map.member_id + and parties.party_id = cr_items.item_id + and cr_items.latest_revision = cr_revisions.revision_id and group_distinct_member_map.group_id $where_group_id [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] [template::list::orderby_clause -orderby -name "contacts"] @@ -14,16 +19,14 @@ -select contact__name(parties.party_id), +select organizations.name, + first_names, last_name, parties.party_id, - cr_revisions.revision_id, - contact__name(parties.party_id,:name_order) as name, parties.email, - parties.url, - ( select first_names from persons where person_id = party_id ) as first_names, - ( select last_name from persons where person_id = party_id ) as last_name, - ( select name from organizations where organization_id = party_id ) as organization - from parties 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 + parties.url + from parties + left join persons on (parties.party_id = persons.person_id) + left join organizations on (parties.party_id = organizations.organization_id), group_distinct_member_map where parties.party_id = group_distinct_member_map.member_id and group_distinct_member_map.group_id $where_group_id [template::list::page_where_clause -and -name "contacts" -key "party_id"]