Index: openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml,v diff -u -r1.80 -r1.81 --- openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 18 May 2006 18:02:59 -0000 1.80 +++ openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 19 May 2006 09:38:46 -0000 1.81 @@ -1,5 +1,5 @@ - + -- select a group -- -- add column -- @@ -164,8 +164,10 @@ Email Address Employee Employees + employees Employer Employers + Enter a query Envelopes Error even Index: openacs-4/packages/contacts/lib/contacts.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.tcl,v diff -u -r1.61 -r1.62 --- openacs-4/packages/contacts/lib/contacts.tcl 18 May 2006 21:16:44 -0000 1.61 +++ openacs-4/packages/contacts/lib/contacts.tcl 19 May 2006 09:38:46 -0000 1.62 @@ -64,9 +64,9 @@ # This is for showing the employee_id and employeer relationship -set type_list [db_list get_condition_type { }] +set condition_type_list [db_list get_condition_types {}] -if { ![string equal [lsearch -exact $type_list "employees"] "-1"] } { +if { ![string equal [lsearch -exact $condition_type_list "employees"] "-1"] } { set multirow_query_name "employees_select" } else { set multirow_query_name "contacts_select" @@ -129,58 +129,6 @@ set last_modified_clause "" set last_modified_rows "" -set first_names_url [export_vars -base $base_url -url {format search_id query page page_size extended_columns {orderby {first_names,asc}}}] -set last_name_url [export_vars -base $base_url -url {format search_id query page page_size extended_columns {orderby {last_name,asc}}}] -set organization_url [export_vars -base $base_url -url {format search_id query page page_size extended_columns {orderby {organization,asc}}}] -set last_modified_url [export_vars -base $base_url -url {format search_id query page page_size extended_columns {orderby {last_modified,desc}}}] -switch $orderby { - "first_names,asc" { - set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization] | [_ contacts.Last_Modified]" - set left_join "left join persons on (p.party_id = persons.person_id)" - set sort_item "lower(first_names), lower(last_name)" - } - "last_name,asc" { - set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization] | [_ contacts.Last_Modified]" - set left_join "left join persons on (p.party_id = persons.person_id)" - set sort_item "lower(last_name), lower(first_names)" - } - "organization,asc" { - set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization] | [_ contacts.Last_Modified]" - set left_join "left join organizations on (p.party_id = organizations.organization_id)" - set sort_item "lower(organizations.name)" - } - "last_modified,desc" { - set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization] | [_ contacts.Last_Modified]" - set left_join "" - set sort_item "cr.publish_date" - set last_modified_rows [list publish_date {}] - } -} - - - -append name_label "    [_ contacts.Show]: " - - -set valid_page_sizes [list 25 50 100 500] -if { ![exists_and_not_null page_size] || [lsearch $valid_page_sizes $page_size] < 0 } { - set page_size [parameter::get -parameter "DefaultPageSize" -default "50"] -} -foreach page_s $valid_page_sizes { - if { $page_size == $page_s } { - lappend page_size_list $page_s - } else { - lappend page_size_list "$page_s" - } -} -append name_label [join $page_size_list " | "] - -if { [string is true [parameter::get -parameter "DisableCSV" -default "0"]] } { - set format normal -} else { - append name_label "   [_ contacts.Get]: [_ contacts.CSV]" -} - template::multirow create bulk_acts pretty link detailed template::multirow append bulk_acts "[_ contacts.Add_to_Group]" "${base_url}group-parties-add" "[_ contacts.Add_to_group]" template::multirow append bulk_acts "[_ contacts.Remove_From_Group]" "${base_url}group-parties-remove" "[_ contacts.lt_Remove_from_this_Grou]" @@ -199,51 +147,133 @@ set return_url "[ad_conn url]?[ad_conn query]" -set group_in_list [contacts::default_groups] + # Delete file is not there, taking out the code to display the delete button # if { [permission::permission_p -object_id $package_id -privilege "delete"] } { # lappend bulk_actions "[_ contacts.Delete]" "${base_url}delete" "[_ contacts.lt_Delete_the_selected_C]" # } if { [exists_and_not_null search_id] } { set object_type [db_string get_object_type {} -default {party}] + set actual_object_type $object_type switch $object_type { person { - set page_query_name "person_pagination" - if {[string eq $orderby "organization,asc"]} { + set page_query_name "person_pagination" + if {[string eq $orderby "organization,asc"]} { set orderby "first_names,asc" - } -# set default_attr_extend [parameter::get -parameter "DefaultPersonAttributeExtension"] - set search_clause [contact::search_clause -and -search_id $search_id -query $query -party_id "persons.person_id" -revision_id "revision_id" -limit_type_p "0"] - set cr_where "and ci.item_id = persons.person_id and ci.latest_revision = cr.revision_id" + } + # set default_attr_extend [parameter::get -parameter "DefaultPersonAttributeExtension"] + set party_column "persons.person_id" } organization { set page_query_name "organization_pagination" if {[string eq $orderby "first_names,asc"] || [string eq $orderby "last_name,asc"]} { set orderby "organization,asc" } -# set default_attr_extend [parameter::get -parameter "DefaultOrganizationAttributeExtension"] - set search_clause [contact::search_clause -and -search_id $search_id -query $query -party_id "organizations.organization_id" -revision_id "revision_id" -limit_type_p "0"] - set cr_where "and ci.item_id = organizations.organization_id and ci.latest_revision = cr.revision_id" + # set default_attr_extend [parameter::get -parameter "DefaultOrganizationAttributeExtension"] + set party_column "organizations.organization_id" } party { set page_query_name "contacts_pagination" -# set default_attr_extend [parameter::get -parameter "DefaultPersonOrganAttributeExtension"] - set search_clause [contact::search_clause -and -search_id $search_id -query $query -party_id "p.party_id" -revision_id "revision_id" -limit_type_p "0"] - set cr_where "and ci.item_id = parties.party_id and ci.latest_revision = cr.revision_id" + # set default_attr_extend [parameter::get -parameter "DefaultPersonOrganAttributeExtension"] + set party_column "parties.party_id" } + employee { + set actual_object_type "person" + set party_column "persons.person_id" + set page_query_name "employee_pagination" + } } - set cr_from "cr_items ci, cr_revisions cr," + set search_clause [contact::search_clause -and -search_id $search_id -query $query -party_id $party_column -revision_id "cr_items.live_revision" -limit_type_p "0"] + if { $orderby eq "last_modified,desc" } { + # we need the cr_items and cr_revisions table since we need the + # cr_revisions.publish date + append cr_where " and $party_column = cr_items.item_id and cr_items.live_revision = cr_revisions.revision_id" + append cr_from " cr_items, cr_revisions," + } elseif { [string equal [lsearch -exact $condition_type_list "attribute"] "-1"] } { + # We don't need to search for attributes so we don't need to join + # on the cr_items table. This should speed things up. This assumes + # that packages other than contacts that add search condition + # types do not need the revision_id column, and only needs the + # party_id column. If this is not the case we may want to add a + # callback here to check if another package needs the revisions + # table. + # + # If this needs to change you should also update the + # contact::search::results_count_not_cached proc which behaves the + # same way. + set cr_where "" + set cr_from "" + } else { + set cr_where "and cr_items.item_id = $party_column" + set cr_from "cr_items," + } } else { set object_type "party" + set actual_object_type "party" set page_query_name "contacts_pagination" set search_clause "[contact::search_clause -and -query $query -search_id "" -party_id "p.party_id" -limit_type_p "0"]" - set cr_from "" - set cr_where "" + if { $orderby eq "last_modified,desc" } { + set cr_from "cr_items, cr_revisions," + set cr_where "and parties.party_id = cr_items.item_id and cr_items.live_revision = cr_revisions.revision_id" + } else { + set cr_from "" + set cr_where "" + } } +set first_names_url [export_vars -base $base_url -url {format search_id query page page_size extended_columns {orderby {first_names,asc}}}] +set last_name_url [export_vars -base $base_url -url {format search_id query page page_size extended_columns {orderby {last_name,asc}}}] +set organization_url [export_vars -base $base_url -url {format search_id query page page_size extended_columns {orderby {organization,asc}}}] +set last_modified_url [export_vars -base $base_url -url {format search_id query page page_size extended_columns {orderby {last_modified,desc}}}] +switch $orderby { + "first_names,asc" { + set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization] | [_ contacts.Last_Modified]" + set left_join "left join persons on (parties.party_id = persons.person_id)" + set sort_item "lower(persons.first_names), lower(persons.last_name)" + } + "last_name,asc" { + set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization] | [_ contacts.Last_Modified]" + set left_join "left join persons on (parties.party_id = persons.person_id)" + set sort_item "lower(persons.last_name), lower(persons.first_names)" + } + "organization,asc" { + set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization] | [_ contacts.Last_Modified]" + set left_join "left join organizations on (parties.party_id = organizations.organization_id)" + set sort_item "lower(organizations.name)" + } + "last_modified,desc" { + set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name] | [_ contacts.Organization] | [_ contacts.Last_Modified]" + set left_join "" + set sort_item "cr_revisions.publish_date" + set last_modified_rows [list publish_date {}] + } +} + +append name_label "    [_ contacts.Show]: " + +set valid_page_sizes [list 25 50 100 500] +if { ![exists_and_not_null page_size] || [lsearch $valid_page_sizes $page_size] < 0 } { + set page_size [parameter::get -parameter "DefaultPageSize" -default "50"] +} +foreach page_s $valid_page_sizes { + if { $page_size == $page_s } { + lappend page_size_list $page_s + } else { + lappend page_size_list "$page_s" + } +} +append name_label [join $page_size_list " | "] + +if { [string is true [parameter::get -parameter "DisableCSV" -default "0"]] } { + set format normal +} else { + append name_label "   [_ contacts.Get]: [_ contacts.CSV]" +} + + set elements [list] lappend elements contact [list \ label {$name_label} \ @@ -332,7 +362,7 @@ -user_id [ad_conn user_id] \ -multirow ext \ -package_id [ad_conn package_id] \ - -object_type $object_type + -object_type $actual_object_type set add_columns [list] @@ -396,13 +426,13 @@ } -orderby { first_names { label "[_ contacts.First_Name]" - orderby_asc "lower(first_names) asc, lower(last_name) asc" - orderby_desc "lower(first_names) desc, lower(last_name) desc" + orderby_asc "lower(persons.first_names) asc, lower(persons.last_name) asc" + orderby_desc "lower(persons.first_names) desc, lower(persons.last_name) desc" } last_name { label "[_ contacts.Last_Name]" - orderby_asc "lower(last_name) asc, lower(first_names) asc" - orderby_desc "lower(last_name) desc, lower(first_names) desc" + orderby_asc "lower(persons.last_name) asc, lower(persons.first_names) asc" + orderby_desc "lower(persons.last_name) desc, lower(persons.first_names) desc" } organization { label "[_ contacts.Organization]" @@ -411,8 +441,8 @@ } last_modified { label "[_ contacts.Last_Modified]" - orderby_asc "cr.publish_date" - orderby_desc "cr.publish_date" + orderby_asc "cr_revisions.publish_date asc" + orderby_desc "cr_revisions.publish_date desc" } default_value first_names,asc } -formats { Index: openacs-4/packages/contacts/lib/contacts.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.xql,v diff -u -r1.28 -r1.29 --- openacs-4/packages/contacts/lib/contacts.xql 18 May 2006 21:16:44 -0000 1.28 +++ openacs-4/packages/contacts/lib/contacts.xql 19 May 2006 09:38:46 -0000 1.29 @@ -3,68 +3,78 @@ - select - distinct p.party_id, $sort_item - from - parties p - $left_join, $cr_from - group_approved_member_map - where - p.party_id = group_approved_member_map.member_id - $cr_where - and group_approved_member_map.group_id in ([template::util::tcl_to_sql_list $group_in_list]) - $search_clause - [template::list::orderby_clause -orderby -name "contacts"] - + select distinct parties.party_id, $sort_item + from parties $left_join, $cr_from + group_approved_member_map + where parties.party_id = group_approved_member_map.member_id + $cr_where + and group_approved_member_map.group_id in ([template::util::tcl_to_sql_list [contacts::default_groups]]) + $search_clause + [template::list::orderby_clause -orderby -name "contacts"] + - select - organizations.organization_id as party_id - from organizations, $cr_from - group_approved_member_map - where - organizations.organization_id = group_approved_member_map.member_id - and group_approved_member_map.group_id in ([template::util::tcl_to_sql_list $group_in_list]) - $cr_where - $search_clause - [template::list::orderby_clause -orderby -name "contacts"] - + select distinct organizations.organization_id as party_id, $sort_item + from organizations, $cr_from + group_approved_member_map + where organizations.organization_id = group_approved_member_map.member_id + and group_approved_member_map.group_id in ([template::util::tcl_to_sql_list [contacts::default_groups]]) + $cr_where + $search_clause + [template::list::orderby_clause -orderby -name "contacts"] + - select - persons.person_id as party_id - from persons,$cr_from - group_approved_member_map - where - persons.person_id = group_approved_member_map.member_id - and group_approved_member_map.group_id in ([template::util::tcl_to_sql_list $group_in_list]) - $cr_where - $search_clause - [template::list::orderby_clause -orderby -name "contacts"] - + select distinct persons.person_id as party_id, $sort_item + from persons, $cr_from + group_approved_member_map + where persons.person_id = group_approved_member_map.member_id + and group_approved_member_map.group_id in ([template::util::tcl_to_sql_list [contacts::default_groups]]) + $cr_where + $search_clause + [template::list::orderby_clause -orderby -name "contacts"] + + + + select distinct persons.person_id as party_id, $sort_item + from persons, $cr_from + group_approved_member_map, + acs_rels + where persons.person_id = group_approved_member_map.member_id + and group_approved_member_map.group_id in ([template::util::tcl_to_sql_list [contacts::default_groups]]) + and persons.person_id = acs_rels.object_id_two + and acs_rels.rel_type = 'contact_rels_employment' + $cr_where + $search_clause + [template::list::orderby_clause -orderby -name "contacts"] + + + - -select $extend_query - organizations.name, - first_names, last_name, - parties.party_id, - parties.email, - parties.url, - to_char(cr.publish_date, :date_format) as publish_date - from parties - left join persons on (parties.party_id = persons.person_id) - left join organizations on (parties.party_id = organizations.organization_id), cr_items ci, cr_revisions cr - where ci.item_id = party_id and ci.latest_revision = cr.revision_id -[template::list::page_where_clause -and -name "contacts" -key "party_id"] -$group_by_group_id -[template::list::orderby_clause -orderby -name "contacts"] - + + select $extend_query + organizations.name, + persons.first_names, + persons.last_name, + parties.party_id, + parties.email, + parties.url, + to_char(cr_revisions.publish_date, :date_format) as publish_date + from parties + left join persons on (parties.party_id = persons.person_id) + left join organizations on (parties.party_id = organizations.organization_id), cr_items, cr_revisions + where cr_items.item_id = party_id + and cr_items.live_revision = cr_revisions.revision_id + [template::list::page_where_clause -and -name "contacts" -key "party_id"] + $group_by_group_id + [template::list::orderby_clause -orderby -name "contacts"] + @@ -83,78 +93,52 @@ - select - csem.extend_id - from - contact_search_extend_map csem, - contact_extend_options ceo - where - ceo.extend_id = csem.extend_id - and ceo.aggregated_p = 'f' - and csem.search_id = :search_id + select csem.extend_id + from contact_search_extend_map csem, + contact_extend_options ceo + where ceo.extend_id = csem.extend_id + and ceo.aggregated_p = 'f' + and csem.search_id = :search_id - select distinct - $extend_query - rel.object_id_one as party_id, - rel.object_id_two as employee_id - from - acs_rels rel, - parties p - where - rel.rel_type = 'contact_rels_employment' - and rel.object_id_one = p.party_id - [template::list::page_where_clause -and -name "contacts" -key "party_id"] + select distinct $extend_query + rel.object_id_one as party_id, + rel.object_id_two as employee_id + from acs_rels rel, + parties + where rel.rel_type = 'contact_rels_employment' + and rel.object_id_one = parties.party_id + [template::list::page_where_clause -and -name "contacts" -key "party_id"] - select - rel.object_id_one as party_id, - rel.object_id_two as employee_id - from - acs_rels rel, persons p - where - rel.rel_type = 'contact_rels_employment' - and person_id = object_id_one - order by last_name + select rel.object_id_one as party_id, + rel.object_id_two as employee_id + from acs_rels rel, persons p + where rel.rel_type = 'contact_rels_employment' + and person_id = object_id_one + order by last_name - - - select - object_type - from - contact_searches - where - search_id = :search_id - - - - select - object_type - from - contact_searches - where - search_id = :search_id + select object_type + from contact_searches + where search_id = :search_id - + - select - type - from - contact_search_conditions - where - search_id = :search_id + select type + from contact_search_conditions + where search_id = :search_id 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.28 -r1.29 --- openacs-4/packages/contacts/tcl/contact-search-procs.tcl 18 May 2006 21:16:44 -0000 1.28 +++ openacs-4/packages/contacts/tcl/contact-search-procs.tcl 19 May 2006 09:38:46 -0000 1.29 @@ -226,28 +226,44 @@ set object_type [db_string get_object_type {} -default "party"] switch $object_type { party { - set search_clause [contact::search_clause -and -search_id $search_id -query $query -party_id "cr_items.item_id" -revision_id "revision_id" -limit_type_p "0"] - set cr_where "and ci.item_id = parties.party_id and ci.latest_revision = cr.revision_id" - } + set party_column "parties.party_id" + } organization { - set search_clause [contact::search_clause -and -search_id $search_id -query $query -party_id "organizations.organization_id" -revision_id "revision_id" -limit_type_p "0"] - set cr_where "and ci.item_id = organizations.organization_id and ci.latest_revision = cr.revision_id" + set party_column "organizations.organization_id" } person { - set search_clause [contact::search_clause -and -search_id $search_id -query $query -party_id "persons.person_id" -revision_id "revision_id" -limit_type_p "0"] - set cr_where "and ci.item_id = persons.person_id and ci.latest_revision = cr.revision_id" + set party_column "persons.person_id" } + employee { + set party_column "persons.person_id" + } } - set cr_from "cr_items ci, cr_revisions cr," + set search_clause [contact::search_clause -and -search_id $search_id -query $query -party_id $party_column -revision_id "cr_items.live_revision" -limit_type_p "0"] + if { [lsearch -exact [db_list get_condition_types {}] "attribute"] > 0 } { + # We don't need to search for attributes so we don't need to join + # on the cr_items table. This should speed things up. This assumes + # that packages other than contacts that add search condition + # types do not need the revision_id column, and only needs the + # party_id column. If this is not the case we may want to add a + # callback here to check if another package needs the revisions + # table. + # + # If this needs to change you should also update the + # contacts/lib/contacts.tcl file which behave the same way. + set cr_where "and cr_items.item_id = $party_column" + set cr_from "cr_items," + } else { + set cr_where "" + set cr_from "" + } } else { set object_type "party" set page_query_name "contacts_pagination" - set search_clause "[contact::search_clause -and -query $query -search_id "" -party_id "parties.party_id" -limit_type_p "0"]" + set search_clause [contact::search_clause -and -query $query -search_id "" -party_id "parties.party_id" -limit_type_p "0"] set cr_from "" set cr_where "" } - return [db_string select_${object_type}_results_count {}] } @@ -348,6 +364,8 @@ set object_type [_ contacts.people] } elseif { $search_info(object_type) == "organization" } { set object_type [_ contacts.organizations] + } elseif { $search_info(object_type) == "employee" } { + set object_type [_ contacts.employees] } else { set object_type [_ contacts.people_or_organizations] } @@ -541,6 +559,8 @@ append result "$party_id = persons.person_id\n" } elseif { $object_type == "organization" } { append result "$party_id = organizations.organization_id\n" + } elseif { $object_type == "employee" } { + append result "$party_id in ( select acs_rels_employee_limitation.object_id_two from acs_rels acs_rels_employee_limitation where acs_rels_employee_limitation.rel_type = 'contact_rels_employment' )" } } # the reason we do not put this in the db_foreach statement is because we 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.16 -r1.17 --- openacs-4/packages/contacts/tcl/contact-search-procs.xql 18 May 2006 21:16:44 -0000 1.16 +++ openacs-4/packages/contacts/tcl/contact-search-procs.xql 19 May 2006 09:38:47 -0000 1.17 @@ -45,6 +45,14 @@ + + + select type + from contact_search_conditions + where search_id = :search_id + + + select count(distinct person_id) @@ -59,14 +67,29 @@ select count(distinct organization_id) - from organizations, $cr_from group_approved_member_map + from organizations, $cr_from + group_approved_member_map where organizations.organization_id = group_approved_member_map.member_id and group_approved_member_map.group_id in ([template::util::tcl_to_sql_list [contacts::default_groups -package_id $package_id]]) $cr_where $search_clause + + + select count(distinct person_id) + from persons, $cr_from + group_approved_member_map, + acs_rels + where persons.person_id = group_approved_member_map.member_id + and group_approved_member_map.group_id in ([template::util::tcl_to_sql_list [contacts::default_groups -package_id $package_id]]) + and persons.person_id = acs_rels.object_id_two + and acs_rels.rel_type = 'contact_rels_employment' + $cr_where + $search_clause + + Index: openacs-4/packages/contacts/www/search.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search.tcl,v diff -u -r1.31 -r1.32 --- openacs-4/packages/contacts/www/search.tcl 18 Apr 2006 10:19:44 -0000 1.31 +++ openacs-4/packages/contacts/www/search.tcl 19 May 2006 09:38:47 -0000 1.32 @@ -26,7 +26,7 @@ {remove_column ""} } -validate { valid_object_type -requires {object_type} { - if { [lsearch [list party person organization] $object_type] < 0 } { + if { [lsearch [list party person organization employee] $object_type] < 0 } { ad_complain "[_ contacts.You_have_specified_an_invalid_object_type]" } } @@ -48,6 +48,7 @@ } } + set package_url [ad_conn package_url] if { [exists_and_not_null aggregate] } { @@ -79,6 +80,11 @@ } } +if { $object_type eq "employee" } { + set actual_object_type "person" +} else { + set actual_object_type $object_type +} if { $search_exists_p } { @@ -87,12 +93,12 @@ # permissions for what attributes/extensions are visible to this # user are to be handled by this callback proc. The callback # MUST only return keys that are visible to this user - + callback contacts::extensions \ -user_id [ad_conn user_id] \ -multirow ext \ -package_id [ad_conn package_id] \ - -object_type $object_type + -object_type $actual_object_type set add_columns [list] set remove_columns [list] @@ -174,6 +180,7 @@ set object_type_pretty_name(party) [_ contacts.People_or_Organizations] set object_type_pretty_name(person) [_ contacts.People] set object_type_pretty_name(organization) [_ contacts.Organizations] +set object_type_pretty_name(employee) [_ contacts.Employees] if { ![exists_and_not_null owner_id] } { set owner_id [ad_conn user_id] @@ -197,6 +204,7 @@ set query_pretty "" } +set display_employers_p [parameter::get -boolean -parameter DisplayEmployersP -default "0"] # FORM HEADER set form_elements { {search_id:key} @@ -212,7 +220,11 @@ } } else { set object_type_options [list] - foreach object_type_temp [list party person organization] { + set object_types [list party person organization] + if { $display_employers_p } { + lappend object_types "employee" + } + foreach object_type_temp $object_types { lappend object_type_options [list $object_type_pretty_name($object_type_temp) $object_type_temp] } append form_elements { @@ -258,7 +270,7 @@ #get condition types widgets set form_elements [concat \ $form_elements \ - [contacts::search::condition_type -type $type -request ad_form_widgets -form_name advanced_search -object_type $object_type] \ + [contacts::search::condition_type -type $type -request ad_form_widgets -form_name advanced_search -object_type $actual_object_type] \ ] if { !$employee_p } { # Show the Ok button @@ -267,28 +279,41 @@ if { $search_exists_p } { - + set results_count [contact::search::results_count -search_id $search_id] append form_elements { {title:text(text),optional {label "

[_ contacts.save_this_search_]"} {html {size 40 maxlength 255}}} {save:text(submit) {label "[_ contacts.Save]"} {value "save"}} {search:text(submit) {label "[_ contacts.Search]"} {value "search"}} {clear:text(submit) {label "[_ contacts.Clear]"} {value "clear"}} - {delete:text(submit) {label "[_ contacts.Delete]"} {value "delete"} \ - {after_html "
[_ contacts.Aggregate_by]:
"} - } } - append form_elements [contacts::search::condition_type::attribute \ - -request ad_form_widgets \ - -prefix "aggregate_" \ - -without_arrow_p "t" \ - -only_multiple_p "t" \ - -package_id [ad_conn package_id]] + + if { $display_employers_p } { - append form_elements { - {aggregate:text(submit) {label "[_ contacts.Aggregate]"} {value "aggregate"} {after_html "  [_ contacts.Results] $results_count"}} + append form_elements { + {delete:text(submit) {label "[_ contacts.Delete]"} {value "delete"} \ + {after_html "
[_ contacts.Aggregate_by]:
"} + } + } + append form_elements [contacts::search::condition_type::attribute \ + -request ad_form_widgets \ + -prefix "aggregate_" \ + -without_arrow_p "t" \ + -only_multiple_p "t" \ + -package_id [ad_conn package_id]] + + append form_elements { + {aggregate:text(submit) {label "[_ contacts.Aggregate]"} {value "aggregate"} {after_html "  [_ contacts.Results] $results_count"}} + } + } else { + append form_elements { + {delete:text(submit) {label "[_ contacts.Delete]"} {value "delete"} \ + {after_html "  [_ contacts.Results] $results_count"} + } + aggregate:text(hidden),optional + } } }