Index: openacs-4/packages/contacts/tcl/contact-search-condition-type-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-search-condition-type-procs.tcl,v diff -u -r1.15 -r1.16 --- openacs-4/packages/contacts/tcl/contact-search-condition-type-procs.tcl 28 Feb 2006 23:39:16 -0000 1.15 +++ openacs-4/packages/contacts/tcl/contact-search-condition-type-procs.tcl 12 Mar 2006 17:54:18 -0000 1.16 @@ -737,16 +737,17 @@ } else { set group_pretty "" } + switch $operand { in { set output_pretty "[_ contacts.lt_The_contact_is_in_the]" -# set output_code "group_id = $group_id" - set output_code "party_id in ( select gdmm.member_id from group_distinct_member_map gdmm where group_id = $group_id )" +# set output_code "group_distinct_member_map.group_id = $group_id" + set output_code "${object_type}_id in ( select gdmm.member_id from group_distinct_member_map gdmm where group_id = $group_id )" } not_in { set output_pretty "[_ contacts.lt_The_contact_is_NOT_in]" -# set output_code "group_id != $group_id" - set output_code "party_id not in ( select gdmm.member_id from group_distinct_member_map gdmm where group_id = $group_id )" +# set output_code "group_distinct_member_map.group_id != $group_id" + set output_code "${object_type}_id not in ( select gdmm.member_id from group_distinct_member_map gdmm where group_id = $group_id )" } } if { $request == "pretty" } { Index: openacs-4/packages/contacts/tcl/contact-search-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-search-procs.tcl,v diff -u -r1.22 -r1.23 --- openacs-4/packages/contacts/tcl/contact-search-procs.tcl 12 Mar 2006 00:35:33 -0000 1.22 +++ openacs-4/packages/contacts/tcl/contact-search-procs.tcl 12 Mar 2006 17:54:18 -0000 1.23 @@ -167,18 +167,12 @@ } { Get the total number of results from a search } { - -# don't know why this is here - matthewg -# it causes an error though so i removed it -# -# set type_list [db_list get_object_type {}] +# Get the results depening on the object_type +set object_type [db_string get_object_type {} -default "party"] -# if { ![string equal [lsearch -exact $type_list "employees"] "-1"] } { - return [db_string select_results_count {}] -# } else { -# return [db_string select_employees_results_count {}] -# } +return [db_string select_${object_type}_results_count {}] + } ad_proc -private contact::party_id_in_sub_search_clause { @@ -269,7 +263,17 @@ } { Get the search in human readable format } { + + contact::search::get -search_id $search_id -array "search_info" + if { $search_info(object_type) == "person" } { + set object_type [_ contacts.people] + } elseif { $search_info(object_type) == "organization" } { + set object_type [_ contacts.organizations] + } else { + set object_type [_ contacts.people_or_organizations] + } + # the reason we do not put this in the db_foreach statement is because we # can run into problems with the number of database pools we have when a sub # query is a condition. We are limited to 3 levels of database access for most @@ -281,21 +285,13 @@ -type [lindex $condition 0] \ -request pretty \ -var_list [lindex $condition 1] \ + -object_type $object_type ] } if { [llength $conditions] > 0 } { - contact::search::get -search_id $search_id -array "search_info" - if { $search_info(object_type) == "person" } { - set object_type [_ contacts.people] - } elseif { $search_info(object_type) == "organization" } { - set object_type [_ contacts.organizations] - } else { - set object_type [_ contacts.people_or_organizations] - } - set results "[_ contacts.Search_for_all_object_type_where]\n" if { $search_info(all_or_any) == "all" } { @@ -459,9 +455,9 @@ if { [exists_and_not_null all_or_any] } { set result {} if { $object_type == "person" } { - append result "$party_id = persons.person_id\n" + # append result "$party_id = persons.person_id\n" } elseif { $object_type == "organization" } { - append result "$party_id = organizations.organization_id\n" + # append result "$party_id = organizations.organization_id\n" } # the reason we do not put this in the db_foreach statement is because we @@ -476,6 +472,7 @@ -var_list [lindex $condition 1] \ -revision_id $revision_id \ -party_id $party_id \ + -object_type $object_type ] } Index: openacs-4/packages/contacts/tcl/contact-search-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-search-procs.xql,v diff -u -r1.10 -r1.11 --- openacs-4/packages/contacts/tcl/contact-search-procs.xql 15 Feb 2006 10:06:36 -0000 1.10 +++ openacs-4/packages/contacts/tcl/contact-search-procs.xql 12 Mar 2006 17:54:18 -0000 1.11 @@ -34,7 +34,7 @@ - + select count(distinct 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 @@ -44,12 +44,37 @@ - + + select count(distinct person_id) + from persons, cr_items, cr_revisions, group_distinct_member_map + where persons.person_id = group_distinct_member_map.member_id + and group_distinct_member_map.group_id in ('[join [contacts::default_groups] "','"]') + and persons.person_id = cr_items.item_id + and cr_items.latest_revision = cr_revisions.revision_id + [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] + + + + + + select count(distinct organization_id) + from organizations, cr_items, cr_revisions, group_distinct_member_map + where organizations.organization_id = group_distinct_member_map.member_id + and group_distinct_member_map.group_id in ('[join [contacts::default_groups] "','"]') + and organizations.organization_id = cr_items.item_id + and cr_items.latest_revision = cr_revisions.revision_id + [contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"] + + + + + + select - distinct type + object_type from - contact_search_conditions + contact_searches where search_id = :search_id Index: openacs-4/packages/contacts/tcl/contacts-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-procs.tcl,v diff -u -r1.68 -r1.69 --- openacs-4/packages/contacts/tcl/contacts-procs.tcl 12 Mar 2006 14:43:03 -0000 1.68 +++ openacs-4/packages/contacts/tcl/contacts-procs.tcl 12 Mar 2006 17:54:18 -0000 1.69 @@ -14,8 +14,8 @@ namespace eval contact::revision:: {} namespace eval contact::rels:: {} namespace eval contact::employee {} +namespace eval contact::special_attributes {} - ad_proc -public contacts::default_group { {-package_id ""} } {