Index: openacs-4/packages/acs-mail-lite/lib/email.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-mail-lite/lib/Attic/email.tcl,v diff -u -r1.24 -r1.25 --- openacs-4/packages/acs-mail-lite/lib/email.tcl 13 May 2006 11:23:02 -0000 1.24 +++ openacs-4/packages/acs-mail-lite/lib/email.tcl 21 May 2006 13:14:04 -0000 1.25 @@ -11,7 +11,7 @@ } } -foreach optional_param {return_url content export_vars file_ids object_id cc item_id} { +foreach optional_param {return_url content export_vars file_ids object_id cc item_id bcc} { if {![info exists $optional_param]} { set $optional_param {} } @@ -77,6 +77,11 @@ {html {size 56}} {help_text "[_ acs-mail-lite.cc_help]"} } + {bcc:text(text),optional + {label "[_ acs-mail-lite.BCC]:"} + {html {size 56}} + {help_text "[_ contacts.cc_help]"} + } } } else { set form_elements { @@ -235,15 +240,13 @@ set from [ad_conn user_id] set from_addr [cc_email_from_party $from] - # Remove all spaces in cc + # Remove all spaces in cc and bcc regsub -all " " $cc "" cc + regsub -all " " $bcc "" bcc - # Just in case someone is using "," instead of ";" - regsub -all ";" $cc "," cc - set cc_list [split $cc ","] + set cc_list [split $cc ";"] + set bcc_list [split $bcc ";"] - template::multirow create messages message_type to_addr to_party_id subject content_body - # Insert the uploaded file linked under the package_id set package_id [ad_conn package_id] @@ -271,26 +274,22 @@ # Send the mail to all parties. foreach party_id $to { - if { $contacts_p } { - set name [contact::name -party_id $party_id] - } else { - set name [acs-mail-lite::name -party_id $party_id] - } + set name [party::name -party_id $to] set first_names [lindex $name 0] set last_name [lindex $name 1] set date [lc_time_fmt [dt_sysdate] "%q"] set to $name - set to_addr [cc_email_from_party $party_id] - lappend recipients_addr $to_addr + set to_addr [party::email -party_id $party_id] + # This should not be happening in the first place and should be removed from here later.... if {[empty_string_p $to_addr]} { # We are going to check if this party_id has an employer and if this # employer has an email set employer_id [relation::get_object_two -object_id_one $party_id \ -rel_type "contact_rels_employment"] if { ![empty_string_p $employer_id] } { # Get the employer email adress - set to_addr [cc_email_from_party -party_id $employer_id] + set to_addr [party::email -party_id $employer_id] if {[empty_string_p $to_addr]} { ad_return_error [_ acs-kernel.common_Error] [_ acs-mail-lite.lt_there_was_an_error_processing] break @@ -305,276 +304,46 @@ lappend values [list "{$element}" [set $element]] } - # Append the CC for each to recipient - template::multirow append messages $message_type $to_addr $party_id [acs_mail_lite::message_interpolate -text $subject -values $values] [acs_mail_lite::message_interpolate -text $content_body -values $values] $cc - + set subject [contact::message::interpolate -text $subject -values $values] + set content_body [contact::message::interpolate -text $content_body -values $values] + acs_mail_lite::complex_send \ + -to_party_ids $party_id \ + -cc_addr $cc_list \ + -bcc_addr $bcc_list \ + -from_addr "$from_addr" \ + -subject "$subject" \ + -body "$content_body" \ + -package_id $package_id \ + -file_ids $file_ids \ + -mime_type $mime_type \ + -object_id $object_id \ + -no_callback_p $no_callback_p \ + -single_email + # Link the file to all parties if {[exists_and_not_null revision_id]} { application_data_link::new -this_object_id $revision_id -target_object_id $party_id } - } - - # Send the email to all CC in cc_list - foreach email_addr $cc_list { - - set name $email_addr - set first_names [split $email_addr "@"] - set last_name $first_names - set date [lc_time_fmt [dt_sysdate] "%q"] - set to $name - set to_addr $email_addr - lappend recipients_addr $to_addr - set values [list] - foreach element [list first_names last_name name date] { - lappend values [list "{$element}" [set $element]] - } - - if {$contacts_p} { - set party_revision_id [contact::live_revision -party_id $party_id] - set locale [lang::user::site_wide_locale -user_id $party_id] - set salutation [ams::value -attribute_name "salutation" -object_id $party_revision_id -locale $locale] - if {![empty_string_p $salutation]} { - lappend value [list "{salutation}" $salutation] - } - } - template::multirow append messages $message_type $to_addr $party_id [acs_mail_lite::message_interpolate -text $subject -values $values] [acs_mail_lite::message_interpolate -text $content_body -values $values] "" + lappend recipients "$to" + } - - set to_list [list] - template::multirow foreach messages { - - lappend to_list [list $to_addr] - - if {[exists_and_not_null file_ids]} { - # do not use fixed sender - if { $use_sender_p } { - - # If the no_callback_p is set to "t" then no callback will be executed - if { $no_callback_p } { - - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -file_ids $file_ids \ - -mime_type $mime_type \ - -object_id $object_id \ - -no_callback \ - -use_sender - - } else { - - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -file_ids $file_ids \ - -mime_type $mime_type \ - -object_id $object_id \ - -use_sender - - } - - } else { - - if { $no_callback_p } { - - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -file_ids $file_ids \ - -mime_type $mime_type \ - -object_id $object_id \ - -no_callback - - } else { - - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -file_ids $file_ids \ - -mime_type $mime_type \ - -object_id $object_id - - } - } - - } else { - - # acs_mail_lite does not know about sending the - # correct mime types.... - if {$mime_type == "text/html"} { - - # do not use fixed sender - if { $use_sender_p } { - - if { $no_callback_p } { - # If the no_callback_p is set to "t" then no callback will be executed - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -mime_type $mime_type \ - -object_id $object_id \ - -no_callback \ - -use_sender - - } else { - - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -mime_type $mime_type \ - -object_id $object_id \ - -use_sender - } - - } else { - - if { $no_callback_p } { - # If the no_callback_p is set to "t" then no callback will be executed - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -mime_type $mime_type \ - -object_id $object_id \ - -no_callback - - } else { - - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -mime_type $mime_type \ - -object_id $object_id - - } - } - - } else { - - if { [exists_and_not_null object_id] } { - - # do not use fixed sender - if { $use_sender_p } { - - # If the no_callback_p is set to "t" then no callback will be executed - if { $no_callback_p } { - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -mime_type "text/html" \ - -object_id $object_id \ - -no_callback \ - -use_sender - } else { - - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -mime_type "text/html" \ - -object_id $object_id \ - -use_sender - } - - } else { - - # If the no_callback_p is set to "t" then no callback will be executed - if { $no_callback_p } { - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -mime_type "text/html" \ - -object_id $object_id \ - -no_callback - } else { - - acs_mail_lite::complex_send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -mime_type "text/html" \ - -object_id $object_id - } - } - } else { - - if { $no_callback_p } { - # If the no_callback_p is set to "t" then no callback will be executed - acs_mail_lite::send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id \ - -no_callback - - } else { - acs_mail_lite::send \ - -to_addr $to_addr \ - -from_addr "$from_addr" \ - -subject "$subject" \ - -body "$content_body" \ - -package_id $package_id - } - } - } - } - - if { $contacts_p && ![empty_string_p $to_party_id] && ![empty_string_p $item_id]} { - - contact::message::log \ - -message_type "email" \ - -sender_id $from \ - -recipient_id $to_party_id \ - -title $title \ - -description $subject \ - -content $content_body \ - -content_format "text/plain" \ - -item_id "$item_id" - - lappend recipients "$to" - - } else { - lappend recipients "$to" - } + if {$to eq ""} { + acs_mail_lite::complex_send \ + -cc_addr $cc_list \ + -bcc_addr $bcc_list \ + -from_addr "$from_addr" \ + -subject "$subject" \ + -body "$content_body" \ + -package_id $package_id \ + -file_ids $file_ids \ + -mime_type $mime_type \ + -object_id $object_id \ + -no_callback_p $no_callback_p \ + -single_email } - set recipients [join $recipients_addr ", "] util_user_message -html -message "[_ acs-mail-lite.Your_message_was_sent_to]" } -after_submit {