Index: openacs-4/packages/contacts/www/message.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message.adp,v diff -u -r1.24 -r1.25 --- openacs-4/packages/contacts/www/message.adp 18 May 2006 18:03:00 -0000 1.24 +++ openacs-4/packages/contacts/www/message.adp 28 Oct 2006 16:45:55 -0000 1.25 @@ -1,24 +1,11 @@ - @title@ @context@ - - - -@party_id@ - -

@error_message;noquote@

-
-
comment_add.comment - - #contacts.This_contact_doesnt# - - @@ -42,4 +29,3 @@ object_od=@object_id@ > - Index: openacs-4/packages/contacts/www/message.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message.tcl,v diff -u -r1.33 -r1.34 --- openacs-4/packages/contacts/www/message.tcl 12 Jun 2006 07:58:51 -0000 1.33 +++ openacs-4/packages/contacts/www/message.tcl 28 Oct 2006 16:45:55 -0000 1.34 @@ -65,18 +65,14 @@ set user_id [ad_conn user_id] set context [list $title] -set using_emp_email_p 0 - set recipients [list] foreach party_id $party_ids { set contact_name [contact::name -party_id $party_id] set contact_url [contact::url -party_id $party_id] set contact_link "${contact_name}" set sort_key [string toupper $contact_name] # Check if the party has a valid e-mail address we can send to - set email_p [contact::message::email_address_exists_p -party_id $party_id] - set letter_p [contact::message::mailing_address_exists_p -party_id $party_id] - lappend recipients [list $contact_name $party_id $contact_link $email_p $letter_p] + lappend recipients [list $contact_name $party_id $contact_link] } set sorted_recipients [ams::util::sort_list_of_lists -list $recipients] set recipients [list] @@ -87,33 +83,31 @@ foreach recipient $sorted_recipients { set party_id [lindex $recipient 1] set contact_link [lindex $recipient 2] - set email_p [lindex $recipient 3] - set letter_p [lindex $recipient 4] if { [lsearch [list "letter" "label" "envelope"] $message_type] >= 0 } { + + # Check if we can send a letter to this party + set letter_p [contact::message::mailing_address_exists_p -party_id $party_id] if { $letter_p } { lappend party_ids $party_id lappend recipients $contact_link } else { lappend invalid_party_ids $party_id lappend invalid_recipients $contact_link } + } elseif { $message_type == "email" } { - if { $email_p } { - lappend party_ids $party_id - lappend recipients $contact_link - } else { + + if { [party::email -party_id $party_id] eq "" } { # We are going to check if there is an employee relationship # if there is we are going to check if the employer has an # email adrres, if it does we are going to use that address - set employer_id [relation::get_object_two -object_id_one $party_id \ - -rel_type "contact_rels_employment"] + set employer_id [lindex [contact::util::get_employee_organization -employee_id $party_id] 0] if { ![empty_string_p $employer_id] } { set emp_addr [contact::email -party_id $employer_id] if { ![empty_string_p $emp_addr] } { - lappend party_ids $party_id + lappend party_ids $employer_id lappend recipients $contact_link - set using_emp_email_p 1 } else { lappend invalid_party_ids $party_id lappend invalid_recipients $contact_link @@ -122,24 +116,30 @@ lappend invalid_party_ids $party_id lappend invalid_recipients $contact_link } - } + } else { + lappend party_ids $party_id + lappend recipients $contact_link + } + } else { - if { $email_p || $letter_p } { + + # Check if we can send a letter to this party + set letter_p [contact::message::mailing_address_exists_p -party_id $party_id] + + if { $letter_p } { lappend party_ids $party_id lappend recipients $contact_link - } else { + } elseif { [party::email -party_id $party_id] eq "" } { # We are going to check if there is an employee relationship # if there is we are going to check if the employer has an # email adrres, if it does we are going to use that address - set employer_id [relation::get_object_two -object_id_one $party_id \ - -rel_type "contact_rels_employment"] + set employer_id [lindex [contact::util::get_employee_organization -employee_id $party_id] 0] if { ![empty_string_p $employer_id] } { set emp_addr [contact::email -party_id $employer_id] if { ![empty_string_p $emp_addr] } { - lappend party_ids $party_id + lappend party_ids $employer_id lappend recipients $contact_link - set using_emp_email_p 1 } else { lappend invalid_party_ids $party_id lappend invalid_recipients $contact_link @@ -148,7 +148,10 @@ lappend invalid_party_ids $party_id lappend invalid_recipients $contact_link } - } + } else { + lappend party_ids $party_id + lappend recipients $contact_link + } } }