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.64 -r1.65 --- openacs-4/packages/contacts/tcl/contacts-procs.tcl 27 Feb 2006 03:46:17 -0000 1.64 +++ openacs-4/packages/contacts/tcl/contacts-procs.tcl 5 Mar 2006 08:34:12 -0000 1.65 @@ -127,11 +127,24 @@ } } - ad_proc -public contact::util::get_employees { +ad_proc -public contact::util::get_employees { {-organization_id:required} + {-package_id ""} } { get employees of an organization } { + if { $package_id eq "" } { + set package_id [ad_conn package_id] + } + return [util_memoize [list ::contact::util::get_employees_not_cached -organization_id $organization_id -package_id $package_id]] +} + +ad_proc -public contact::util::get_employees_not_cached { + {-organization_id:required} + {-package_id:required} +} { + get employees of an organization +} { set contact_list {} db_foreach select_employee_ids { select CASE WHEN object_id_one = :organization_id @@ -142,16 +155,32 @@ and ( object_id_one = :organization_id or object_id_two = :organization_id ) and acs_rels.rel_type = 'contact_rels_employment' } { - lappend contact_list $other_party_id + if { [contact::visible_p -party_id $other_party_id -package_id $package_id_id] } { + lappend contact_list $other_party_id + } } return $contact_list } ad_proc -public contact::util::get_employees_list_of_lists { {-organization_id:required} + {-package_id ""} } { get employees of an organization in a list of list suitable for inclusion in options + the list is made up of employee_name and employee_id. Cached +} { + if { $package_id eq "" } { + set package_id [ad_conn package_id] + } + return [util_memoize [list ::contact::util::get_employees_list_of_lists_not_cached -organization_id $organization_id -package_id $package_id]] +} + +ad_proc -private contact::util::get_employees_list_of_lists_not_cached { + {-organization_id:required} + {-package_id:required} +} { + get employees of an organization in a list of list suitable for inclusion in options the list is made up of employee_name and employee_id } { set contact_list [list] @@ -164,24 +193,31 @@ and ( object_id_one = :organization_id or object_id_two = :organization_id ) and acs_rels.rel_type = 'contact_rels_employment' } { - lappend contact_list [list [person::name -person_id $other_party_id] $other_party_id] + if { [contact::visible_p -party_id $other_party_id -package_id $package_id_id] } { + lappend contact_list [list [person::name -person_id $other_party_id] $other_party_id] + } } return $contact_list } ad_proc -public contact::util::get_employers { {-employee_id:required} + {-package_id ""} } { Get employers of an employee @return List of lists, each containing the ID and name of an employer, or an empty list if no employers exist. } { - return [util_memoize [list ::contact::util::get_employers_not_cached -employee_id $employee_id]] + if { $package_id eq "" } { + set package_id [ad_conn package_id] + } + return [util_memoize [list ::contact::util::get_employers_not_cached -employee_id $employee_id -package_id $package_id]] } ad_proc -private contact::util::get_employers_not_cached { {-employee_id:required} + {-package_id:required} } { Get employers of an employee @@ -200,14 +236,15 @@ and ( object_id_one = :employee_id or object_id_two = :employee_id ) and acs_rels.rel_type = 'contact_rels_employment' } { - set organization_name [contact::name -party_id $other_party_id] - lappend contact_list [list $other_party_id $organization_name] + if { [contact::visible_p -party_id $other_party_id -package_id $package_id] } { + set organization_name [contact::name -party_id $other_party_id] + lappend contact_list [list $other_party_id $organization_name] + } } return $contact_list } - ad_proc -public contact::salutation { {-party_id:required} {-type salutation} @@ -268,6 +305,7 @@ {-employee_id:required} {-array:required} {-organization_id ""} + {-package_id ""} } { Get full employee information. If employee does not have a phone number, fax number, or an e-mail address, the employee will be assigned the corresponding employer value, if an employer exists. Cached. @@ -301,7 +339,10 @@ } { upvar $array local_array - set values [util_memoize [list ::contact::employee::get_not_cached -employee_id $employee_id -organization_id $organization_id]] + if { $package_id eq "" } { + set package_id [ad_conn package_id] + } + set values [util_memoize [list ::contact::employee::get_not_cached -employee_id $employee_id -organization_id $organization_id -package_id $package_id]] if {![empty_string_p $values]} { array set local_array $values @@ -314,6 +355,7 @@ ad_proc -private contact::employee::get_not_cached { {-employee_id:required} {-organization_id} + {-package_id:required} } { @author Malte Sussdorff (malte.sussdorff@cognovis.de) Get full employee information. If employee does not have a phone number, fax number, or an e-mail address, the employee will be assigned the corresponding employer value, if an employer exists. Uncached. @@ -361,7 +403,7 @@ # Get employers, if any set employers [list] - set employers [contact::util::get_employers -employee_id $employee_id] + set employers [contact::util::get_employers -employee_id $employee_id -package_id $package_id] # If employer(s) exist if {[llength $employers] > 0} { @@ -437,6 +479,13 @@ } } + # message variables. if the employee does not have + # a viable mailing address for this package it will + # look for a viable mailing address for its employers + set local_array(mailing_address) [contact::message::mailing_address -party_id $employee_id -package_id $package_id] + set local_array(email_address) [contact::message::email_address -party_id $employee_id -package_id $package_id] + + # Get the locale set local_array(locale) [lang::user::site_wide_locale -user_id $employee_id] @@ -445,9 +494,22 @@ ad_proc -public contact::util::get_employee_organization { {-employee_id:required} + {-package_id ""} } { get organization of an employee } { + if { $package_id eq "" } { + set package_id [ad_conn package_id] + } + return [util_memoize [list ::contact::util::get_employee_organization_not_cached -employee_id $employee_id -package_id $package_id]] +} + +ad_proc -public contact::util::get_employee_organization_not_cached { + {-employee_id:required} + {-package_id:required} +} { + get organization of an employee +} { set contact_list {} db_foreach select_employee_ids { select CASE WHEN object_id_one = :employee_id @@ -458,7 +520,9 @@ and ( object_id_one = :employee_id or object_id_two = :employee_id ) and acs_rels.rel_type = 'contact_rels_employment' } { - lappend contact_list $other_party_id + if { [contact::visible_p -party_id $other_party_id -package_id $package_id] } { + lappend contact_list $other_party_id + } } return $contact_list