Index: openacs-4/packages/contacts/lib/contacts.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.tcl,v
diff -u -N -r1.72 -r1.73
--- openacs-4/packages/contacts/lib/contacts.tcl 8 Jan 2007 12:53:34 -0000 1.72
+++ openacs-4/packages/contacts/lib/contacts.tcl 25 Jun 2007 16:25:39 -0000 1.73
@@ -428,7 +428,7 @@
-actions $actions \
-bulk_actions $bulk_actions \
-bulk_action_method post \
- -bulk_action_export_vars { search_id return_url } \
+ -bulk_action_export_vars { return_url } \
-elements $elements \
-filters {
search_id {}
Index: openacs-4/packages/contacts/lib/email-search.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/email-search.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/lib/email-search.adp 25 Jun 2007 16:25:39 -0000 1.1
@@ -0,0 +1,10 @@
+
+
Index: openacs-4/packages/contacts/lib/email-search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/email-search.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/lib/email-search.tcl 25 Jun 2007 16:25:39 -0000 1.1
@@ -0,0 +1,396 @@
+# packages/contacts/lib/email.tcl
+# Template for email inclusion
+# @author Malte Sussdorff (sussdorff@sussdorff.de)
+# @creation-date 2005-06-14
+# @arch-tag: 48fe00a8-a527-4848-b5de-0f76dfb60291
+# @cvs-id $Id: email-search.tcl,v 1.1 2007/06/25 16:25:39 maltes Exp $
+
+foreach required_param {search_id} {
+ if {![info exists $required_param]} {
+ return -code error "$required_param is a required parameter."
+ }
+}
+
+foreach optional_param {return_url content export_vars file_ids cc bcc item_id context_id} {
+ if {![info exists $optional_param]} {
+ set $optional_param {}
+ }
+}
+
+if {![info exists cancel_url]} {
+ set cancel_url $return_url
+}
+
+if {![info exists no_callback_p]} {
+ set no_callback_p f
+}
+
+# The element check_uncheck only calls a javascript function
+# to check or uncheck all recipients
+set form_elements {
+ message_id:key
+ return_url:text(hidden)
+ no_callback_p:text(hidden)
+ title:text(hidden),optional
+ search_id:text(hidden)
+ {message_type:text(hidden) {value "email"}}
+ {-section "sec1" {legendtext "[_ contacts.Recipients]"}}
+ {recipients:text(inform)
+ {label "[_ contacts.Recipients]"}
+ {value "$recipients"}
+ }
+ {cc:text(text),optional
+ {label "[_ contacts.CC]:"}
+ {html {size 60}}
+ {help_text "[_ contacts.cc_help]"}
+ }
+ {bcc:text(text),optional
+ {label "[_ acs-mail-lite.BCC]:"}
+ {html {size 60}}
+ {help_text "[_ contacts.cc_help]"}
+ }
+}
+
+# Set single_email_p in the form
+set single_email_p 0
+
+# Get the list of files from the file storage folder
+set file_folder_id [parameter::get_from_package_key -package_key "acs-mail-lite" -parameter "FolderID"]
+if {![string eq "" $file_folder_id]} {
+ # get the list of files in an option
+ set file_options [db_list_of_lists files {
+ select r.title, i.item_id
+ from cr_items i, cr_revisions r
+ where i.parent_id = :file_folder_id
+ and i.content_type = 'file_storage_object'
+ and r.revision_id = i.latest_revision
+ }]
+ if {![string eq "" $file_options]} {
+ append form_elements {
+ {files_extend:text(checkbox),optional
+ {label "[_ acs-mail-lite.Additional_files]"}
+ {options $file_options}
+ }
+ }
+ }
+}
+
+# See if the contacts and mail-tracking packages are installed.
+set contacts_p [apm_package_installed_p "contacts"]
+set tracking_p [apm_package_installed_p "mail-tracking"]
+
+if { [exists_and_not_null file_ids] } {
+ set files [list]
+ foreach file $file_ids {
+ set file_item_id [content::revision::item_id -revision_id $file]
+ if {$file_item_id eq ""} {
+ set file_item_id $file
+ }
+ set file_title [lang::util::localize [content::item::get_title -item_id $file_item_id]]
+ if {[empty_string_p $file_title]} {
+ set file_title "empty"
+ }
+ if { $tracking_p } {
+ lappend files "$file_title "
+ } else {
+ lappend files "$file_title "
+ }
+ }
+ set files [join $files ", "]
+
+ append form_elements {
+ {file_ids:text(hidden) {value $file_ids}}
+ {context_id:text(hidden) {value $context_id}}
+ {files:text(inform),optional {label "[_ acs-mail-lite.Associated_files]"} {value $files}}
+ }
+}
+
+foreach var $export_vars {
+ upvar $var var_value
+
+ # We need to split to construct the element with two lappends
+ # becasue if we put something like this {value $value} the value
+ # of the variable is not interpreted
+
+ set element [list]
+ lappend element "${var}:text(hidden)"
+ lappend element "value $var_value"
+
+ # Adding the element to the form
+ lappend form_elements $element
+}
+
+if {![exists_and_not_null mime_type]} {
+ set mime_type text/plain
+}
+
+set content_list [list $content $mime_type]
+
+append form_elements {
+ {-section "sec2" {legendtext "[_ contacts.Message]"}}
+ {subject:text(text),optional
+ {label "[_ contacts.Subject]"}
+ {html {size 60}}
+ }
+ {content_body:richtext(richtext),optional
+ {label "[_ contacts.Message]"}
+ {html {cols 80 rows 18}}
+ {help_text "[_ contacts.lt_remember_that_you_can]"}
+ {value $content_list}
+ }
+ {upload_file:file(file),optional
+ {label "[_ contacts.Upload_file]"}
+ }
+ {mail_through_p:text(hidden)
+ {label "[_ contacts.Mail_through_p]"}
+ {options {{"Yes" "1"} {"No" "0"}}}
+ {value "0"}
+ {help_text "[_ contacts.lt_Mail_through_p_help]"}
+ }
+}
+
+if { [exists_and_not_null item_id] } {
+ append form_elements {
+ {item_id:text(hidden),optional
+ {value $item_id}
+ }
+ }
+}
+
+if { ![exists_and_not_null action] } {
+ set action [ad_conn url]
+}
+
+set edit_buttons [list [list [_ contacts.Send] send]]
+
+ad_form -action $action \
+ -html {enctype multipart/form-data} \
+ -name email \
+ -cancel_label "[_ acs-kernel.common_Cancel]" \
+ -cancel_url $cancel_url \
+ -edit_buttons $edit_buttons \
+ -form $form_elements \
+ -on_request {
+ } -new_request {
+ if {![exists_and_not_null mime_type]} {
+ set mime_type "text/html"
+ }
+
+ if {[exists_and_not_null folder_id] } {
+ callback contacts::email_subject -folder_id $folder_id
+ }
+ if {[exists_and_not_null item_id] } {
+ contact::message::get -item_id $item_id -array message_info
+ set subject $message_info(description)
+ set content_body [list $message_info(content) $message_info(content_format)]
+ set title $message_info(title)
+ }
+ if {[exists_and_not_null signature_id] } {
+ set signature [contact::signature::get -signature_id $signature_id]
+ if { [exists_and_not_null signature] } {
+ append content_body "{
$signature } text/html"
+ }
+ }
+ } -edit_request {
+ if {![exists_and_not_null mime_type]} {
+ set mime_type "text/html"
+ }
+
+ } -on_submit {
+
+ set package_id [ad_conn package_id]
+
+ # Make sure we get the correct users and can send an e-mail to them
+ if {[contact::group::mapped_p -group_id $search_id]} {
+
+ # Make sure the user has write permission on the group
+ permission::require_permission -object_id $search_id -privilege "write"
+
+ # Get the party_ids from the group members
+ if { [contact::group::mapped_p -group_id $search_id] } {
+ set valid_party_ids [group::get_members -group_id $search_id]
+ }
+ } else {
+ set valid_party_ids [contact::search::results -search_id $search_id -package_id $package_id]
+ }
+
+ foreach party_id $valid_party_ids {
+ 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 [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 $employer_id
+ } else {
+ lappend invalid_party_ids $party_id
+ }
+ } else {
+ lappend invalid_party_ids $party_id
+ }
+ } else {
+ lappend party_ids $party_id
+ }
+ }
+
+ # Deal with the invalid recipients
+ foreach party_id $invalid_party_ids {
+ set contact_name [contact::name -party_id $party_id]
+ set contact_url [contact::url -party_id $party_id]
+ lappend invalid_recipients "${contact_name}"
+ }
+
+ set invalid_recipients [join $invalid_recipients ", "]
+ if { [llength $invalid_recipients] > 0 } {
+ switch $message_type {
+ letter {
+ set error_message [_ contacts.lt_You_cannot_send_a_letter_to_invalid_recipients]
+ }
+ email {
+ set error_message [_ contacts.lt_You_cannot_send_an_email_to_invalid_recipients]
+ }
+ default {
+ set error_message [_ contacts.lt_You_cannot_send_a_message_to_invalid_recipients]
+ }
+ }
+ if { $party_ids != "" } {
+ util_user_message -html -message $error_message
+ }
+ }
+
+ # We get the attribute_id of the salutation attribute
+ set attribute_id [attribute::id -object_type "person" -attribute_name "salutation"]
+
+ # List to store know wich emails recieved the message
+ set recipients_addr [list]
+
+ set from [ad_conn user_id]
+ set from_addr [contact::email -party_id $from]
+
+ # Remove all spaces in cc and bcc
+ regsub -all " " $cc "" cc
+ regsub -all " " $bcc "" bcc
+
+ set cc_list [split $cc ";"]
+ set bcc_list [split $bcc ";"]
+
+ set mime_type [template::util::richtext::get_property format $content_body]
+ set content_body [template::util::richtext::get_property contents $content_body]
+
+
+ # Insert the uploaded file linked under the package_id
+ if {![empty_string_p $upload_file] } {
+ set revision_id [content::item::upload_file \
+ -package_id $package_id \
+ -upload_file $upload_file \
+ -parent_id $search_id]
+
+ lappend file_ids $revision_id
+ }
+
+ # Append the additional files
+ if {[exists_and_not_null files_extend]} {
+ foreach file_id $files_extend {
+ lappend file_ids $file_id
+ }
+ }
+
+
+ # Send the mail to all parties.
+ set member_size [llength $party_ids]
+ set counter 1
+ foreach party_id $party_ids {
+
+ # Differentiate between person and organization
+ if {[person::person_p -party_id $party_id]} {
+ set salutation [contact::salutation -party_id $party_id]
+ db_1row names "select first_names, last_name from persons where person_id = :party_id"
+ set name "$first_names $last_name"
+ } else {
+ set name [contact::name -party_id $party_id]
+ set salutation "Dear ladies and gentlemen"
+ # the following is a hot fix (nfl 2006/10/20)
+ set first_names ""
+ set last_name ""
+ }
+
+
+ set date [lc_time_fmt [dt_sysdate] "%q"]
+
+ set values [list]
+ foreach element [list first_names last_name salutation name date] {
+ lappend values [list "{$element}" [set $element]]
+ }
+
+ set interpol_subject [contact::message::interpolate -text $subject -values $values]
+
+ set interpol_content_body [contact::message::interpolate -text $content_body -values $values]
+
+ # If we are doing mail through for tracking purposes
+ # Set the reply_to_addr accordingly
+ if {$mail_through_p} {
+ regsub -all {@} $from_addr {#} reply_to
+ set reply_to_addr "${reply_to}@[acs_mail_lite::address_domain]"
+ } else {
+ set reply_to_addr $from_addr
+ }
+
+ ns_log Notice "Recipient: $name $party_id ( $counter / $member_size )"
+ incr counter
+
+ acs_mail_lite::complex_send \
+ -to_party_ids $party_id \
+ -cc_addr $cc_list \
+ -bcc_addr $bcc_list \
+ -from_addr "$from_addr" \
+ -reply_to "$reply_to_addr" \
+ -subject "$interpol_subject" \
+ -body "$interpol_content_body" \
+ -package_id $package_id \
+ -file_ids $file_ids \
+ -mime_type $mime_type \
+ -object_id $context_id \
+ -no_callback_p $no_callback_p \
+ -single_email
+
+ # Link the files to all parties
+ if {[exists_and_not_null revision_id]} {
+ application_data_link::new -this_object_id $revision_id -target_object_id $party_id
+ }
+
+ # Log the sending of the mail in contacts history
+ if { ![empty_string_p $item_id]} {
+
+ contact::message::log \
+ -message_type "email" \
+ -sender_id $from \
+ -recipient_id $party_id \
+ -title $title \
+ -description $subject \
+ -content $content_body \
+ -content_format "text/plain" \
+ -item_id "$item_id"
+
+ }
+ }
+
+ ad_returnredirect $return_url
+
+ # Prepare the user message
+ foreach cc_addr [concat $cc_list $bcc_list] {
+ set cc_id [party::get_by_email -email $cc_addr]
+ if {$cc_id eq ""} {
+ lappend recipients $cc_addr
+ } else {
+ lappend recipients "[contact::name -party_id $cc_id]"
+ }
+ }
+ util_user_message -html -message "[_ contacts.Your_message_was_sent_to_-recipients-]"
+
+ } -after_submit {
+ ad_script_abort
+ }
+
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.34 -r1.35
--- openacs-4/packages/contacts/lib/email.tcl 22 Jun 2007 05:31:44 -0000 1.34
+++ openacs-4/packages/contacts/lib/email.tcl 25 Jun 2007 16:25:39 -0000 1.35
@@ -304,9 +304,9 @@
lappend values [list "{$element}" [set $element]]
}
- set subject [contact::message::interpolate -text $subject -values $values]
+ set interpol_subject [contact::message::interpolate -text $subject -values $values]
- set content_body [contact::message::interpolate -text $content_body -values $values]
+ set interpol_content_body [contact::message::interpolate -text $content_body -values $values]
# If we are doing mail through for tracking purposes
# Set the reply_to_addr accordingly
@@ -325,8 +325,8 @@
-bcc_addr $bcc_list \
-from_addr "$from_addr" \
-reply_to "$reply_to_addr" \
- -subject "$subject" \
- -body "$content_body" \
+ -subject "$interpol_subject" \
+ -body "$interpol_content_body" \
-package_id $package_id \
-file_ids $file_ids \
-mime_type $mime_type \
Index: openacs-4/packages/contacts/lib/email_group.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/Attic/email_group.adp,v
diff -u -N
--- openacs-4/packages/contacts/lib/email_group.adp 23 Jun 2007 10:18:17 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,10 +0,0 @@
-
-
Index: openacs-4/packages/contacts/lib/email_group.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/Attic/email_group.tcl,v
diff -u -N
--- openacs-4/packages/contacts/lib/email_group.tcl 23 Jun 2007 10:18:17 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,333 +0,0 @@
-# packages/contacts/lib/email.tcl
-# Template for email inclusion
-# @author Malte Sussdorff (sussdorff@sussdorff.de)
-# @creation-date 2005-06-14
-# @arch-tag: 48fe00a8-a527-4848-b5de-0f76dfb60291
-# @cvs-id $Id: email_group.tcl,v 1.1 2007/06/23 10:18:17 maltes Exp $
-
-foreach required_param {group_id} {
- if {![info exists $required_param]} {
- return -code error "$required_param is a required parameter."
- }
-}
-
-foreach optional_param {return_url content export_vars file_ids cc bcc item_id context_id} {
- if {![info exists $optional_param]} {
- set $optional_param {}
- }
-}
-
-if {![info exists cancel_url]} {
- set cancel_url $return_url
-}
-
-if {![info exists no_callback_p]} {
- set no_callback_p f
-}
-
-# The element check_uncheck only calls a javascript function
-# to check or uncheck all recipients
-set form_elements {
- message_id:key
- return_url:text(hidden)
- no_callback_p:text(hidden)
- title:text(hidden),optional
- group_id:text(hidden)
- {message_type:text(hidden) {value "email"}}
- {-section "sec1" {legendtext "[_ contacts.Recipients]"}}
- {recipients:text(inform)
- {label "[_ contacts.Recipients]"}
- {value "$recipients"}
- }
- {cc:text(text),optional
- {label "[_ contacts.CC]:"}
- {html {size 60}}
- {help_text "[_ contacts.cc_help]"}
- }
- {bcc:text(text),optional
- {label "[_ acs-mail-lite.BCC]:"}
- {html {size 60}}
- {help_text "[_ contacts.cc_help]"}
- }
-}
-
-# Set single_email_p in the form
-set single_email_p 0
-
-# Get the list of files from the file storage folder
-set file_folder_id [parameter::get_from_package_key -package_key "acs-mail-lite" -parameter "FolderID"]
-if {![string eq "" $file_folder_id]} {
- # get the list of files in an option
- set file_options [db_list_of_lists files {
- select r.title, i.item_id
- from cr_items i, cr_revisions r
- where i.parent_id = :file_folder_id
- and i.content_type = 'file_storage_object'
- and r.revision_id = i.latest_revision
- }]
- if {![string eq "" $file_options]} {
- append form_elements {
- {files_extend:text(checkbox),optional
- {label "[_ acs-mail-lite.Additional_files]"}
- {options $file_options}
- }
- }
- }
-}
-
-# See if the contacts and mail-tracking packages are installed.
-set contacts_p [apm_package_installed_p "contacts"]
-set tracking_p [apm_package_installed_p "mail-tracking"]
-
-if { [exists_and_not_null file_ids] } {
- set files [list]
- foreach file $file_ids {
- set file_item_id [content::revision::item_id -revision_id $file]
- if {$file_item_id eq ""} {
- set file_item_id $file
- }
- set file_title [lang::util::localize [content::item::get_title -item_id $file_item_id]]
- if {[empty_string_p $file_title]} {
- set file_title "empty"
- }
- if { $tracking_p } {
- lappend files "$file_title "
- } else {
- lappend files "$file_title "
- }
- }
- set files [join $files ", "]
-
- append form_elements {
- {file_ids:text(hidden) {value $file_ids}}
- {context_id:text(hidden) {value $context_id}}
- {files:text(inform),optional {label "[_ acs-mail-lite.Associated_files]"} {value $files}}
- }
-}
-
-foreach var $export_vars {
- upvar $var var_value
-
- # We need to split to construct the element with two lappends
- # becasue if we put something like this {value $value} the value
- # of the variable is not interpreted
-
- set element [list]
- lappend element "${var}:text(hidden)"
- lappend element "value $var_value"
-
- # Adding the element to the form
- lappend form_elements $element
-}
-
-if {![exists_and_not_null mime_type]} {
- set mime_type text/plain
-}
-
-set content_list [list $content $mime_type]
-
-append form_elements {
- {-section "sec2" {legendtext "[_ contacts.Message]"}}
- {subject:text(text),optional
- {label "[_ contacts.Subject]"}
- {html {size 60}}
- }
- {content_body:richtext(richtext),optional
- {label "[_ contacts.Message]"}
- {html {cols 80 rows 18}}
- {help_text "[_ contacts.lt_remember_that_you_can]"}
- {value $content_list}
- }
- {upload_file:file(file),optional
- {label "[_ contacts.Upload_file]"}
- }
- {mail_through_p:integer(radio)
- {label "[_ contacts.Mail_through_p]"}
- {options {{"Yes" "1"} {"No" "0"}}}
- {value "1"}
- {help_text "[_ contacts.lt_Mail_through_p_help]"}
- }
-}
-
-if { [exists_and_not_null item_id] } {
- append form_elements {
- {item_id:text(hidden),optional
- {value $item_id}
- }
- }
-}
-
-if { ![exists_and_not_null action] } {
- set action [ad_conn url]
-}
-
-set edit_buttons [list [list [_ contacts.Send] send]]
-
-ad_form -action $action \
- -html {enctype multipart/form-data} \
- -name email \
- -cancel_label "[_ acs-kernel.common_Cancel]" \
- -cancel_url $cancel_url \
- -edit_buttons $edit_buttons \
- -form $form_elements \
- -on_request {
- } -new_request {
- if {![exists_and_not_null mime_type]} {
- set mime_type "text/html"
- }
-
- if {[exists_and_not_null folder_id] } {
- callback contacts::email_subject -folder_id $folder_id
- }
- if {[exists_and_not_null item_id] } {
- contact::message::get -item_id $item_id -array message_info
- set subject $message_info(description)
- set content_body [list $message_info(content) $message_info(content_format)]
- set title $message_info(title)
- }
- if {[exists_and_not_null signature_id] } {
- set signature [contact::signature::get -signature_id $signature_id]
- if { [exists_and_not_null signature] } {
- append content_body "{
$signature } text/html"
- }
- }
- } -edit_request {
- if {![exists_and_not_null mime_type]} {
- set mime_type "text/html"
- }
-
- } -on_submit {
-
- # We get the attribute_id of the salutation attribute
- set attribute_id [attribute::id -object_type "person" -attribute_name "salutation"]
-
- # List to store know wich emails recieved the message
- set recipients_addr [list]
-
- set from [ad_conn user_id]
- set from_addr [contact::email -party_id $from]
-
- # Remove all spaces in cc and bcc
- regsub -all " " $cc "" cc
- regsub -all " " $bcc "" bcc
-
- set cc_list [split $cc ";"]
- set bcc_list [split $bcc ";"]
-
- set mime_type [template::util::richtext::get_property format $content_body]
- set content_body [template::util::richtext::get_property contents $content_body]
-
-
- # Insert the uploaded file linked under the package_id
- set package_id [ad_conn package_id]
-
- if {![empty_string_p $upload_file] } {
- set revision_id [content::item::upload_file \
- -package_id $package_id \
- -upload_file $upload_file \
- -parent_id $party_id]
-
- lappend file_ids $revision_id
- }
-
- # Append the additional files
- if {[exists_and_not_null files_extend]} {
- foreach file_id $files_extend {
- lappend file_ids $file_id
- }
- }
-
-
- # Send the mail to all parties.
- ns_log Notice "Recipients: $group_id"
- foreach party_id [group::get_members -group_id $group_id] {
-
- # Differentiate between person and organization
- if {[person::person_p -party_id $party_id]} {
- set salutation [contact::salutation -party_id $party_id]
- db_1row names "select first_names, last_name from persons where person_id = :party_id"
- set name "$first_names $last_name"
- } else {
- set name [contact::name -party_id $party_id]
- set salutation "Dear ladies and gentlemen"
- # the following is a hot fix (nfl 2006/10/20)
- set first_names ""
- set last_name ""
- }
-
-
- set date [lc_time_fmt [dt_sysdate] "%q"]
-
- set values [list]
- foreach element [list first_names last_name salutation name date] {
- lappend values [list "{$element}" [set $element]]
- }
-
- set subject [contact::message::interpolate -text $subject -values $values]
-
- set content_body [contact::message::interpolate -text $content_body -values $values]
-
- # If we are doing mail through for tracking purposes
- # Set the reply_to_addr accordingly
- if {$mail_through_p} {
- regsub -all {@} $from_addr {#} reply_to
- set reply_to_addr "${reply_to}@[acs_mail_lite::address_domain]"
- } else {
- set reply_to_addr $from_addr
- }
-
- ns_log Notice "Recipients: $party_id"
-
- acs_mail_lite::complex_send \
- -to_party_ids $party_id \
- -cc_addr $cc_list \
- -bcc_addr $bcc_list \
- -from_addr "$from_addr" \
- -reply_to "$reply_to_addr" \
- -subject "$subject" \
- -body "$content_body" \
- -package_id $package_id \
- -file_ids $file_ids \
- -mime_type $mime_type \
- -object_id $context_id \
- -no_callback_p $no_callback_p \
- -single_email
-
- # Link the files to all parties
- if {[exists_and_not_null revision_id]} {
- application_data_link::new -this_object_id $revision_id -target_object_id $party_id
- }
-
- # Log the sending of the mail in contacts history
- if { ![empty_string_p $item_id]} {
-
- contact::message::log \
- -message_type "email" \
- -sender_id $from \
- -recipient_id $party_id \
- -title $title \
- -description $subject \
- -content $content_body \
- -content_format "text/plain" \
- -item_id "$item_id"
-
- }
- }
-
- ad_returnredirect $return_url
-
- # Prepare the user message
- foreach cc_addr [concat $cc_list $bcc_list] {
- set cc_id [party::get_by_email -email $cc_addr]
- if {$cc_id eq ""} {
- lappend recipients $cc_addr
- } else {
- lappend recipients "[contact::name -party_id $cc_id]"
- }
- }
- util_user_message -html -message "[_ contacts.Your_message_was_sent_to_-recipients-]"
-
- } -after_submit {
- ad_script_abort
- }
-
Index: openacs-4/packages/contacts/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/index.tcl,v
diff -u -N -r1.28 -r1.29
--- openacs-4/packages/contacts/www/index.tcl 21 Jun 2007 21:11:27 -0000 1.28
+++ openacs-4/packages/contacts/www/index.tcl 25 Jun 2007 16:25:39 -0000 1.29
@@ -83,14 +83,6 @@
lappend search_options [list "${my_lists_title}" ${my_lists_list_id} [_ contacts.Lists]]
}
-# Include for an Ajax dropdown smart search widget that filters search results as you type.
-# Requires ajaxhelper
-
-set js_update_user_select [ah::ajaxupdate \
- -container "results_box" \
- -url "lookup" \
- -pars "Form.serialize('search')"]
-
if { [exists_and_not_null search_id] } {
set search_in_list_p 0
foreach search_option $search_options {
@@ -110,7 +102,7 @@
set form_elements {
{search_id:integer(select_with_optgroup),optional {label ""} {options $search_options} {html {onChange "javascript:acs_FormRefresh('search')"}}}
- {query:text(text),optional {label ""} {html {size 20 maxlength 255 onKeyUp "$js_update_user_select document.getElementById('results_box').style.visibility='visible';" autocomplete "off" value ""}}}
+ {query:text(text),optional {label ""}}
{save:text(submit) {label {[_ contacts.Search]}} {value "go"}}
{results_count:integer(inform),optional {label " [_ contacts.Results] $contacts_total_count "}}
}
@@ -124,8 +116,7 @@
}
}
-if { [contact::group::mapped_p -group_id $search_id] && $contacts_total_count > 0 } {
- set group [contact::group::name -group_id $search_id]
+if { $search_id ne "" && $contacts_total_count > 0 } {
set label [_ contacts.Mail_group]
append form_elements {
{mail_merge_group:text(submit) {label $label} {value "1"}}
@@ -138,7 +129,7 @@
} -on_refresh {
} -on_submit {
if { [exists_and_not_null mail_merge_group] } {
- ad_returnredirect [export_vars -base "message" -url {{group_id $search_id}}]
+ ad_returnredirect [export_vars -base "message" -url {{search_id $search_id}}]
ad_script_abort
}
} -after_submit {
Index: openacs-4/packages/contacts/www/message.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message.adp,v
diff -u -N -r1.27 -r1.28
--- openacs-4/packages/contacts/www/message.adp 23 Jun 2007 10:18:17 -0000 1.27
+++ openacs-4/packages/contacts/www/message.adp 25 Jun 2007 16:25:39 -0000 1.28
@@ -22,7 +22,7 @@
footer_id=@footer_id@
header_id=@header_id@
folder_id=@folder_id@
- group_id=@group_id@
+ search_id=@search_id@
title=@title@
cc=@cc@
bcc=@bcc@
Index: openacs-4/packages/contacts/www/message.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message.tcl,v
diff -u -N -r1.38 -r1.39
--- openacs-4/packages/contacts/www/message.tcl 23 Jun 2007 10:18:17 -0000 1.38
+++ openacs-4/packages/contacts/www/message.tcl 25 Jun 2007 16:25:39 -0000 1.39
@@ -8,7 +8,7 @@
{object_id:integer,multiple,optional}
{party_id:multiple,optional}
{party_ids ""}
- {group_id:integer ""}
+ {search_id:integer ""}
{message_type ""}
{message:optional}
{header_id:integer ""}
@@ -45,16 +45,23 @@
set invalid_party_ids [list]
-if { $group_id ne "" } {
+set package_id [ad_conn package_id]
+set recipients [list]
- # Make sure the user has write permission on the group
- permission::require_permission -object_id $group_id -privilege "write"
+if { $search_id ne "" } {
- # Get the party_ids from the group members
- if { [contact::group::mapped_p -group_id $group_id] } {
- set valid_party_ids [group::get_members -group_id $group_id]
+ set return_url [export_vars -base [apm_package_url_from_id $package_id] -url {search_id}]
+ if {[contact::group::mapped_p -group_id $search_id]} {
+
+ # Make sure the user has write permission on the group
+ permission::require_permission -object_id $search_id -privilege "write"
+ lappend recipients "[group::title -group_id $search_id]"
+ } else {
+ lappend recipients "[contact::search::title -search_id $search_id]"
}
+ # We do the check in the search template
+ set valid_party_ids "0"
} else {
if { [exists_and_not_null party_id] } {
@@ -74,7 +81,7 @@
# Make sure the parties are visible to the user
foreach id $party_ids {
- if {[contact::visible_p -party_id $id -package_id [ad_conn package_id]]} {
+ if {[contact::visible_p -party_id $id -package_id $package_id]} {
lappend valid_party_ids $id
}
}
@@ -85,14 +92,11 @@
set user_id [ad_conn user_id]
set context [list $title]
-set recipients [list]
-
if {![exists_and_not_null valid_party_ids]} {
ad_return_error "[_ contacts.No_valid_parties]" "[_ contacts.No_valid_parties_lt]"
ad_script_abort
}
-set recipients [list]
set invalid_recipients [list]
set party_ids [list]
@@ -137,17 +141,17 @@
}
# If we are passing in a group, do not show the individual users
-if { [empty_string_p $group_id] } {
+if { [empty_string_p $search_id] } {
# Prepare the recipients
foreach party_id $party_ids {
set contact_name [contact::name -party_id $party_id]
set contact_url [contact::url -party_id $party_id]
lappend recipients "${contact_name}"
}
-
+ set form_elements "party_ids:text(hidden)"
} else {
- lappend recipients "[group::title -group_id $group_id]"
+ set form_elements ""
}
# Deal with the invalid recipients
@@ -179,11 +183,11 @@
if {[exists_and_not_null object_id]} {
foreach object $object_id {
if {[fs::folder_p -object_id $object]} {
- db_foreach files "select r.revision_id
- from cr_revisions r, cr_items i
- where r.item_id = i.item_id and i.parent_id = :object" {
- lappend file_list $revision_id
- }
+ db_foreach files {select r.revision_id
+ from cr_revisions r, cr_items i
+ where r.item_id = i.item_id and i.parent_id = :object} {
+ lappend file_list $revision_id
+ }
} else {
set revision_id [content::item::get_best_revision -item_id $object]
if {[empty_string_p $revision_id]} {
@@ -205,18 +209,16 @@
set file_ids [join $file_list " "]
}
-set form_elements {
+append form_elements {
file_ids:text(hidden)
- party_ids:text(hidden)
- group_id:text(hidden)
+ search_id:text(hidden)
return_url:text(hidden)
folder_id:text(hidden)
object_id:text(hidden)
context_id:text(hidden)
{to_name:text(inform),optional {label "[_ contacts.Recipients]"} {value $recipients}}
}
-
if { ![exists_and_not_null message_type] } {
set message_type_options [ams::util::localize_and_sort_list_of_lists \
@@ -283,9 +285,9 @@
} else {
set title [_ contacts.create_$message_type]
- if {$group_id ne ""} {
- # Get the group template
- set message_src "/packages/contacts/lib/${message_type}_group"
+ if {$search_id ne ""} {
+ # Get the search template
+ set message_src "/packages/contacts/lib/${message_type}-search"
} else {
set message_src "/packages/contacts/lib/${message_type}"
}
Index: openacs-4/packages/contacts/www/admin/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/index.tcl,v
diff -u -N -r1.15 -r1.16
--- openacs-4/packages/contacts/www/admin/index.tcl 21 Jun 2007 20:06:42 -0000 1.15
+++ openacs-4/packages/contacts/www/admin/index.tcl 25 Jun 2007 16:25:39 -0000 1.16
@@ -32,7 +32,9 @@
}
member_count {
label {[_ contacts.Contacts]}
- display_col member_count
+ display_template {
+ @groups.member_count@
+ }
}
mapped {
label {Mapped}
@@ -171,4 +173,4 @@
set populate_url [export_vars -base "populate" -url {{populate_type "crm"}}]
} else {
set populate_url ""
-}
\ No newline at end of file
+}