Index: openacs-4/packages/contacts/contacts.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/contacts.info,v diff -u -r1.59 -r1.60 --- openacs-4/packages/contacts/contacts.info 31 Dec 2005 07:39:37 -0000 1.59 +++ openacs-4/packages/contacts/contacts.info 3 Jan 2006 22:14:54 -0000 1.60 @@ -7,14 +7,14 @@ f t - + Matthew Geddert This application lets you collaboratively view, edit and categorize contacts. 2005-11-23 Contacts is an application for managing all those people and or organization you need to keep track of. It has a complete UI for storing and categorizing contacts. Each contact can have an arbitrary number of custom attributes associated with it, including other contacts (i.e. a certain contact "belongs" to a certain organization). It also functions as a service contract provider for attributes related to users in your system 0 - + @@ -66,6 +66,7 @@ + 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 -r1.58 -r1.59 --- openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 31 Dec 2005 07:39:39 -0000 1.58 +++ openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 3 Jan 2006 22:14:54 -0000 1.59 @@ -484,8 +484,8 @@ signatures Sort By Sort by - Spoiler? - Path to the file containing the image used as a spoiler + Banner? + Path to the file containing the image used as a banner state/province is -> Status Stored Extended Options Index: openacs-4/packages/contacts/lib/email.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/email.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/contacts/lib/email.tcl 24 Oct 2005 18:18:03 -0000 1.14 +++ openacs-4/packages/contacts/lib/email.tcl 3 Jan 2006 22:14:55 -0000 1.15 @@ -201,44 +201,37 @@ # Send the mail to all parties. foreach party_id $to { - set name [contact::name -party_id $party_id] - 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] - set party_revision_id [contact::live_revision -party_id $party_id] - if { ![exists_and_not_null locale]} { + + # Differentiate between person and organization + if {[person::person_p -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 "$employee(title) $first_names $last_name" + set salutation $employee(salutation) + set locale $employee(locale) + set to_addr $employee(email) + } else { + set name [contact::name -party_id $party_id] + set to_addr [cc_email_from_party $party_id] + set salutation "Dear ladies and gentlemen" set locale [lang::user::site_wide_locale -user_id $party_id] } - set salutation [ams::value \ - -attribute_id $attribute_id \ - -attribute_name "salutation" \ - -object_id $party_revision_id \ - -locale $locale] - lappend recipients_addr $to_addr + set date [lc_time_fmt [dt_sysdate] "%q"] + set to $name 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] - if {[empty_string_p $to_addr]} { - ad_return_error [_ contacts.Error] [_ contacts.lt_there_was_an_error_processing] - break - } - } else { - ad_return_error [_ contacts.Error] [_ contacts.lt_there_was_an_error_processing] - break - } - } + ad_return_error [_ contacts.Error] [_ contacts.lt_there_was_an_error_processing] + break + } + + lappend recipients_addr $to_addr + set values [list] foreach element [list first_names last_name name date salutation] { lappend values [list "{$element}" [set $element]] } + template::multirow append messages $message_type $to_addr $party_id [contact::message::interpolate -text $subject -values $values] [contact::message::interpolate -text $content_body -values $values] # Link the files to all parties 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 -r1.4 -r1.5 --- openacs-4/packages/contacts/lib/oo_mailing.tcl 28 Dec 2005 12:38:11 -0000 1.4 +++ openacs-4/packages/contacts/lib/oo_mailing.tcl 3 Jan 2006 22:14:55 -0000 1.5 @@ -39,8 +39,9 @@ set footer "" } -set spoiler_options [util::find_all_files -extension jpg -path "/web/wieners/packages/wieners/templates/spoiler"] - +set template_path "[acs_root_dir][parameter::get_from_package_key -package_key contacts -parameter OOMailingPath]" +set banner_options [util::find_all_files -extension jpg -path "${template_path}/banner"] + set date [split [dt_sysdate] "-"] append form_elements { message_id:key @@ -54,28 +55,39 @@ {date:date(date) {label "[_ contacts.Date]"} } - {spoiler:text(select),optional - {label "[_ contacts.Spoiler]"} - {help_text "[_ contacts.Spoiler_help_text]"} - {options $spoiler_options} + {banner:text(select),optional + {label "[_ contacts.Banner]"} + {help_text "[_ contacts.Banner_help_text]"} + {options $banner_options} + {section "[_ contacts.oo_message]"} } {content:richtext(richtext) - {label "[_ contacts.Message]"} + {label "[_ contacts.oo_message]"} {html {cols 70 rows 24}} - {help_text {[_ contacts.lt_remember_that_you_can]}} + {help_text {[_ contacts.oo_content_help]}} } {ps:text(text),optional {label "[_ contacts.PS]"} {help_text "[_ contacts.PS_help_text]"} {html {size 45 maxlength 1000}} } + {subject:text(text),optional + {label "[_ contacts.Subject]"} + {html {size 55}} + {section "[_ contacts.oo_email_content]"} + {help_text {[_ contacts.oo_email_subject_help]}} + } + {email_content:text(textarea),optional + {label "[_ contacts.oo_email_content]"} + {html {cols 65 rows 12}} + {help_text {[_ contacts.oo_email_help]}} + } } ad_form -action message \ -name letter \ -cancel_label "[_ contacts.Cancel]" \ -cancel_url $return_url \ - -edit_buttons [list [list [_ contacts.Print] print]] \ -form $form_elements \ -on_request { } -new_request { @@ -90,7 +102,7 @@ set content [list $content $message_info(content_format)] set title $message_info(title) set ps $message_info(ps) - set spoiler $message_info(spoiler) + set banner $message_info(banner) } else { if { [exists_and_not_null signature] } { set content [list $signature "text/html"] @@ -99,6 +111,7 @@ set paper_type "letterhead" } -edit_request { } -on_submit { + # Make sure the content actually exists set content_raw [string trim \ [ad_html_text_convert \ @@ -110,17 +123,21 @@ if {$content_raw == "" } { template::element set_error message content "[_ contacts.Message_is_required]" } - + # Now parse the content for openoffice set content_format [template::util::richtext::get_property format $content] set content [contact::oo::convert -content [string trim [template::util::richtext::get_property content $content]]] - + # Retrieve information about the user so it can be used in the template set user_id [ad_conn user_id] if {![contact::employee::get -employee_id $user_id -array user_info]} { ad_return_error $user_id "User is not an employee" } + template::multirow create messages revision_id to_addr to_party_id subject content_body + + set file_revisions [list] + foreach party_id $party_ids { # get the user information if {[contact::employee::get -employee_id $party_id -array employee]} { @@ -130,42 +147,98 @@ ad_return_error [_ contacts.Error] [_ contacts.lt_there_was_an_error_processing_this_request] break } - - set file [open "/web/wieners/vorlage.xml"] + + set file [open "${template_path}/content.xml"] fconfigure $file -translation binary set template_content [read $file] close $file + set file [open "${template_path}/styles.xml"] + fconfigure $file -translation binary + set style_content [read $file] + close $file + eval [template::adp_compile -string $template_content] - set letter $__adp_output + set content $__adp_output - set odt_filename [contact::oo::change_content -document_filename "vorlage.odt" -path "/web" -contents [list "content.xml" "$letter"]] - set revision_id [contact::oo::import_oo_pdf -oo_file $odt_filename -parent_id $party_id] + eval [template::adp_compile -string $style_content] + set style $__adp_output + set odt_filename [contact::oo::change_content -path "${template_path}" -document_filename "document.odt" -contents [list "content.xml" $content "styles.xml" $style]] + + set item_id [contact::oo::import_oo_pdf -oo_file $odt_filename -parent_id $party_id -title "${title}.pdf"] + set revision_id [content::item::get_best_revision -item_id $item_id] + lappend file_revisions $revision_id + + # Now we need to find a way to join all these files. Probably using a new procedure to join all the revision ids + + # Subject is set => we send an email. + if {$subject ne ""} { + + # 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 "$first_names $last_name" + set salutation $employee(salutation) + set locale $employee(locale) + set to_addr $employee(email) + } else { + set name [contact::name -party_id $party_id] + set to_addr [cc_email_from_party $party_id] + set salutation "Dear ladies and gentlemen" + set locale [lang::user::site_wide_locale -user_id $party_id] + } + set date [lc_time_fmt [dt_sysdate] "%q"] + + set values [list] + foreach element [list first_names last_name name date salutation] { + lappend values [list "{$element}" [set $element]] + } + + # We are going to create a multirow which knows about the file (revision_id) and contains + # the parsed e-mail. + template::multirow append messages $revision_id $to_addr "" [contact::message::interpolate -text $subject -values $values] [contact::message::interpolate -text $email_content -values $values] + } + + # Log that we have been sending this oo-mailing contact::message::log \ -message_type "oo_mailing" \ -sender_id $user_id \ -recipient_id $party_id \ -title $title \ -description "" \ - -content $letter \ + -content $content \ -content_format "text/html" + } - } - + if {$subject ne ""} { + set from [ad_conn user_id] + set from_addr [cc_email_from_party $from] + set package_id [ad_conn package_id] - # onLoad=\"window.print()\" - ns_return 200 text/html " - - -[_ contacts.Print_Letter] - - -$letter - - - -" - ad_script_abort + template::multirow foreach messages { + + ad_return_error "toaddr" "$to_addr" + # Send the e-mail to each of the users + acs_mail_lite::complex_send \ + -to_addr $to_addr \ + -from_addr "$from_addr" \ + -subject "$subject" \ + -body "$content_body" \ + -package_id $package_id \ + -file_ids $revision_id \ + -mime_type "text/plain" \ + -object_id $item_id + } + } else { + + # We are not sending the e-mail but write the file back to the user + if {[llength $file_revisions]==1} { + cr_write_content -revision_id [lindex $file_revisions 0] + } + } + ad_returnredirect "/contacts/$party_id" } Index: openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql,v diff -u -r1.6 -r1.7 --- openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql 26 Dec 2005 17:21:54 -0000 1.6 +++ openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql 3 Jan 2006 22:14:55 -0000 1.7 @@ -31,8 +31,8 @@ constraint contact_message_items_message_type_nn not null, locale varchar(30) constraint contact_message_items_locale_fk references ad_locales(locale), - -- Spoiler contains the path to an image which can be inserted into the open office mailing document - spoiler varchar(500), + -- Banner contains the path to an image which can be inserted into the open office mailing document + banner varchar(500), -- PS is the post scriptum, which is commonly used in mailings. ps varchar(500), ); @@ -42,7 +42,7 @@ cmi.owner_id, cmi.message_type, cmi.locale, - cmi.spoiler, + cmi.banner, cmi.ps cr.title, cr.description, Index: openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.1d11-1.1d12.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.1d11-1.1d12.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.1d11-1.1d12.sql 3 Jan 2006 22:14:55 -0000 1.1 @@ -0,0 +1,19 @@ +alter table contact_message_items add column banner varchar(500); +update contact_message_items set banner = spoiler; +alter table contact_message_items drop column spoiler cascade; +create view contact_messages as + select cmi.item_id, + cmi.owner_id, + cmi.message_type, + cmi.locale, + cmi.banner, + cmi.ps, + cr.title, + cr.description, + cr.content, + cr.mime_type as content_format + from contact_message_items cmi, cr_items ci, cr_revisions cr + where cmi.item_id = cr.item_id + and ci.publish_status not in ( 'expired' ) + and ci.live_revision = cr.revision_id +; 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 -r1.15 -r1.16 --- openacs-4/packages/contacts/tcl/contact-message-procs.tcl 31 Dec 2005 07:39:39 -0000 1.15 +++ openacs-4/packages/contacts/tcl/contact-message-procs.tcl 3 Jan 2006 22:14:55 -0000 1.16 @@ -46,7 +46,7 @@ {-content:required} {-content_format "text/plain"} {-locale ""} - {-spoiler ""} + {-banner ""} {-ps ""} } { save a contact message @@ -67,13 +67,13 @@ db_dml insert_into_message_items { insert into contact_message_items - ( item_id, owner_id, message_type, locale, spoiler, ps ) + ( item_id, owner_id, message_type, locale, banner, ps ) values - ( :item_id, :owner_id, :message_type, :locale, :spoiler, :ps ) + ( :item_id, :owner_id, :message_type, :locale, :banner, :ps ) } } else { db_dml update_message_item { - update contact_message_items set owner_id = :owner_id, message_type = :message_type, locale = :locale, spoiler = :spoiler, ps = :ps where item_id = :item_id + update contact_message_items set owner_id = :owner_id, message_type = :message_type, locale = :locale, banner = :banner, ps = :ps where item_id = :item_id } } @@ -280,7 +280,7 @@ @param title Title which will be used for the resulting content item and file name if none was given in the item @param item_id The item_id of the content item to which the content should be associated. @param parent_id Needed to set the parent of this object - @return revision_id of the revision that contains the file + @return item_id of the revision that contains the file } { # This exec command is missing all the good things about openacs # Add the parameter to whatever package you put this procedure in. @@ -355,6 +355,12 @@ } set pdf_filesize [file size $pdf_filename] set mime_type "application/pdf" + + set file_name [file tail $pdf_filename] + if {$title eq ""} { + set title $file_name + } + if {[exists_and_not_null $item_id]} { set parent_id [get_parent -item_id $item_id] @@ -365,15 +371,15 @@ $pdf_filename \ $pdf_filesize \ $mime_type \ - $pdf_filename ] + $file_name ] } else { set revision_id [cr_import_content \ -title $title \ $parent_id \ $pdf_filename \ $pdf_filesize \ $mime_type \ - $pdf_filename ] + $file_name ] } content::item::set_live_revision -revision_id $revision_id Index: openacs-4/packages/contacts/www/message-ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-ae.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/contacts/www/message-ae.tcl 26 Dec 2005 16:46:00 -0000 1.4 +++ openacs-4/packages/contacts/www/message-ae.tcl 3 Jan 2006 22:14:55 -0000 1.5 @@ -70,12 +70,13 @@ } } oo_mailing { + set banner_options [util::find_all_files -extension jpg -path "[acs_root_dir][parameter::get_from_package_key -package_key contacts -parameter OOMailingPath]/banner"] append form_elements { - {spoiler:text(text),optional - {label "[_ contacts.Spoiler]"} - {help_text "[_ contacts.Spoiler_help_text]"} - {html {size 45 maxlength 1000}} - } + {banner:text(select),optional + {label "[_ contacts.Banner]"} + {help_text "[_ contacts.Banner_help_text]"} + {options $banner_options} + } {content:richtext(richtext) {label "[_ contacts.Message]"} {html {cols 70 rows 24}}} {ps:text(text),optional {label "[_ contacts.PS]"} @@ -131,7 +132,7 @@ -content $content \ -content_format $content_format \ -locale $locale \ - -spoiler $spoiler \ + -banner $banner \ -ps $ps } -after_submit { Index: openacs-4/packages/contacts/www/message.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message.tcl,v diff -u -r1.23 -r1.24 --- openacs-4/packages/contacts/www/message.tcl 27 Dec 2005 08:39:15 -0000 1.23 +++ openacs-4/packages/contacts/www/message.tcl 3 Jan 2006 22:14:55 -0000 1.24 @@ -41,7 +41,7 @@ lappend party_ids $party_id } } - + if { [exists_and_not_null to] } { set party_ids [list] foreach party_id $to {