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 -N -r1.64 -r1.65 --- openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 28 Feb 2006 23:35:25 -0000 1.64 +++ openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 5 Mar 2006 08:34:12 -0000 1.65 @@ -319,7 +319,7 @@ Person - Registered Users Person or Organization %pretty_plural_list_name% found in search, please try again or add a new contact - remember that you can use mail merge substitutions. The most common wildcards are {name} {first_names}, {last_name}, {salutation}, {home_address} and {date} + remember that you can use mail merge substitutions. The most common wildcards are {name} {first_names}, {last_name}, {salutation}, {mailing_address}, {directphone} and {date} Remove from Selected Group(s) Remove from this Group %role% exists Index: openacs-4/packages/contacts/lib/email.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/email.tcl,v diff -u -N -r1.20 -r1.21 --- openacs-4/packages/contacts/lib/email.tcl 20 Feb 2006 09:13:58 -0000 1.20 +++ openacs-4/packages/contacts/lib/email.tcl 5 Mar 2006 08:34:12 -0000 1.21 @@ -208,14 +208,17 @@ contact::employee::get -employee_id $party_id -array employee set first_names $employee(first_names) set last_name $employee(last_name) - set name "$employee(person_title) $first_names $last_name" + set name [string trim "$employee(person_title) $first_names $last_name"] set salutation $employee(salutation) + set directphone $employee(directphoneno) + set mailing_address $employee(mailing_address) set locale $employee(locale) } else { set name [contact::name -party_id $party_id] set salutation "Dear ladies and gentlemen" set locale [lang::user::site_wide_locale -user_id $party_id] } + set to_addr [contact::message::email_address -party_id $party_id] set date [lc_time_fmt [dt_sysdate] "%q"] set to $name @@ -228,7 +231,7 @@ lappend recipients_addr $to_addr set values [list] - foreach element [list first_names last_name name date salutation] { + foreach element [list first_names last_name name date salutation mailing_address directphone] { lappend values [list "{$element}" [set $element]] } Index: openacs-4/packages/contacts/lib/letter.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/letter.tcl,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/contacts/lib/letter.tcl 22 Feb 2006 01:40:39 -0000 1.10 +++ openacs-4/packages/contacts/lib/letter.tcl 5 Mar 2006 08:34:12 -0000 1.11 @@ -144,13 +144,23 @@ set total_count [llength $party_ids] foreach party_id $party_ids { - set name [contact::name -party_id $party_id] - set first_names [lindex $name 0] - set last_name [lindex $name 1] - set locale [lang::user::site_wide_locale -user_id $party_id] - set revision_id [contact::live_revision -party_id $party_id] - set salutation [ams::value -attribute_name "salutation" -object_id $revision_id -locale $locale] + # Differentiate between person and organization + if {[person::person_p -party_id $party_id]} { + contact::employee::get -employee_id $party_id -array employee + set first_names $employee(first_names) + set last_name $employee(last_name) + set name [string trim "$employee(person_title) $first_names $last_name"] + set salutation $employee(salutation) + set directphone $employee(directphoneno) + set mailing_address $employee(mailing_address) + set locale $employee(locale) + } else { + set name [contact::name -party_id $party_id] + set salutation "Dear ladies and gentlemen" + set locale [lang::user::site_wide_locale -user_id $party_id] + } + set letter "" if { [exists_and_not_null date] } { # do not pull the date variable out here and reformat @@ -160,12 +170,13 @@ append letter "\n
[lc_time_fmt $date %q $locale]
" } if { $include_address eq "1" } { - set mailing_address [contact::message::mailing_address -party_id $party_id -format "text/html"] - append letter "\n
$name
$mailing_address
" + # this work differnt from the contact::employee::get mailing address because that is + # in text format, but we need it as html + append letter "\n
$name
[contact::message::mailing_address -party_id $party_id -format "text/html"]
" } append letter "\n
${content_html}
" set values [list] - foreach element [list first_names last_name name mailing_address date salutation] { + foreach element [list first_names last_name name date salutation mailing_address directphone] { lappend values [list "{$element}" [set $element]] } set letter [contact::message::interpolate -text $letter -values $values] Index: openacs-4/packages/contacts/lib/oo_mailing.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/oo_mailing.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/contacts/lib/oo_mailing.tcl 20 Feb 2006 22:01:02 -0000 1.9 +++ openacs-4/packages/contacts/lib/oo_mailing.tcl 5 Mar 2006 08:34:12 -0000 1.10 @@ -184,8 +184,10 @@ contact::employee::get -employee_id $party_id -array employee set first_names $employee(first_names) set last_name $employee(last_name) - set name "$first_names $last_name" + set name [string trim "$employee(person_title) $first_names $last_name"] set salutation $employee(salutation) + set directphone $employee(directphoneno) + set mailing_address $employee(mailing_address) set locale $employee(locale) set to_addr $employee(email) } else { @@ -196,7 +198,7 @@ } set values [list] - foreach element [list first_names last_name name date salutation] { + foreach element [list first_names last_name name date salutation mailing_address directphone] { lappend values [list "{$element}" [set $element]] } Index: openacs-4/packages/contacts/tcl/contact-message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-message-procs.tcl,v diff -u -N -r1.26 -r1.27 --- openacs-4/packages/contacts/tcl/contact-message-procs.tcl 27 Feb 2006 02:25:23 -0000 1.26 +++ openacs-4/packages/contacts/tcl/contact-message-procs.tcl 5 Mar 2006 08:34:12 -0000 1.27 @@ -157,22 +157,31 @@ ad_proc -private contact::message::email_address_exists_p { {-party_id:required} + {-package_id ""} } { Does a message email address exist for this party or his/her employer. Cached via contact::message::email_address. } { - return [string is false [empty_string_p [contact::message::email_address -party_id $party_id]]] + if { $package_id eq "" } { + set package_id [ad_conn package_id] + } + return [string is false [empty_string_p [contact::message::email_address -party_id $party_id -package_id [ad_conn package_id]]]] } ad_proc -private contact::message::email_address { {-party_id:required} + {-package_id ""} } { Does a message email address exist for this party } { - return [util_memoize [list ::contact::message::email_address_not_cached -party_id $party_id]] + if { $package_id eq "" } { + set package_id [ad_conn package_id] + } + return [util_memoize [list ::contact::message::email_address_not_cached -party_id $party_id -package_id $package_id]] } ad_proc -private contact::message::email_address_not_cached { {-party_id:required} + {-package_id:required} } { Does a message email address exist for this party } { @@ -181,7 +190,7 @@ # if this person is the employee of # an organization we can attempt to use # that organizations email address - foreach employer [contact::util::get_employers -employee_id $party_id] { + foreach employer [contact::util::get_employers -employee_id $party_id -package_id $package_id] { set email [contact::email -party_id [lindex $employer 0]] if { $email ne "" } { break @@ -193,16 +202,20 @@ ad_proc -private contact::message::mailing_address_exists_p { {-party_id:required} + {-package_id ""} } { Does a mailing address exist for this party. Cached via contact::message::mailing_address. } { + if { $package_id eq "" } { + set package_id [ad_conn package_id] + } # since this check is almost always called by a page which # will later ask for the mailing address we take on the # overhead of calling for the address, which is cached. # this simplifies the code and thus "pre" caches the address # for the user, which overall is faster - return [string is false [empty_string_p [contact::message::mailing_address -party_id $party_id -format "text"]]] + return [string is false [empty_string_p [contact::message::mailing_address -party_id $party_id -format "text" -package_id $package_id]]] } ad_proc -private contact::message::mailing_address { @@ -245,7 +258,7 @@ # if this person is the employee of # an organization we can attempt to use # that organizations email address - foreach employer [contact::util::get_employers -employee_id $party_id] { + foreach employer [contact::util::get_employers -employee_id $party_id -package_id $package_id] { set mailing_address [contact::message::mailing_address -party_id [lindex $employer 0] -package_id $package_id] if { $mailing_address ne "" } { break 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 -N -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