Index: openacs-4/packages/mail-tracking/mail-tracking.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/mail-tracking.info,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/mail-tracking/mail-tracking.info 3 Jun 2006 19:57:47 -0000 1.7
+++ openacs-4/packages/mail-tracking/mail-tracking.info 14 Nov 2006 07:17:55 -0000 1.8
@@ -8,7 +8,7 @@
t
tracking
-
+
Nima Mazloumi
Mail tracking package. Records all messages send out by acs-mail-lite.
2005-10-24
@@ -18,9 +18,8 @@
0
-
-
-
+
+
Index: openacs-4/packages/mail-tracking/catalog/mail-tracking.en_US.ISO-8859-1.xml
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/catalog/mail-tracking.en_US.ISO-8859-1.xml,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/mail-tracking/catalog/mail-tracking.en_US.ISO-8859-1.xml 3 Jun 2006 19:57:47 -0000 1.8
+++ openacs-4/packages/mail-tracking/catalog/mail-tracking.en_US.ISO-8859-1.xml 14 Nov 2006 07:17:55 -0000 1.9
@@ -1,5 +1,5 @@
-
+
Attachments
BCC
Index: openacs-4/packages/mail-tracking/sql/postgresql/mail-tracking-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/sql/postgresql/mail-tracking-create.sql,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/mail-tracking/sql/postgresql/mail-tracking-create.sql 14 May 2006 16:11:19 -0000 1.7
+++ openacs-4/packages/mail-tracking/sql/postgresql/mail-tracking-create.sql 14 Nov 2006 07:17:55 -0000 1.8
@@ -54,6 +54,20 @@
create index acs_mail_log_recipient_map_recipient_idx on acs_mail_log_recipient_map(recipient_id);
create index acs_mail_log_um_log_rec_idx on acs_mail_log_recipient_map(log_id,recipient_id,type);
+-- file_mapping_table
+create table acs_mail_log_attachment_map (
+ log_id integer
+ constraint acs_mail_log_log_id2_fk
+ references acs_mail_log(log_id),
+ file_id integer
+ constraint acs_mail_log_file_id_fk
+ references cr_items(item_id)
+);
+
+create index acs_mail_log_att_map_file_idx on acs_mail_log_attachment_map(file_id);
+create index acs_mail_log_att_map_log_idx on acs_mail_log_attachment_map(log_id);
+
+
-- create the content type
select acs_object_type__create_type (
'mail_log', -- content_type
Index: openacs-4/packages/mail-tracking/sql/postgresql/upgrade/upgrade-0.6.2-0.6.3.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/sql/postgresql/upgrade/upgrade-0.6.2-0.6.3.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/mail-tracking/sql/postgresql/upgrade/upgrade-0.6.2-0.6.3.sql 14 Nov 2006 07:17:55 -0000 1.1
@@ -0,0 +1,43 @@
+-- file_mapping_table
+create table acs_mail_log_attachment_map (
+ log_id integer
+ constraint acs_mail_log_log_id2_fk
+ references acs_mail_log(log_id),
+ file_id integer
+ constraint acs_mail_log_file_id_fk
+ references cr_items(item_id)
+);
+
+create index acs_mail_log_att_map_file_idx on acs_mail_log_attachment_map(file_id);
+create index acs_mail_log_att_map_log_idx on acs_mail_log_attachment_map(log_id);
+
+-- Get the file_ids and insert them into the tracking table
+
+insert into acs_mail_log_attachment_map (log_id, file_id) select r.object_id_one as log_id, o.object_id as file_id
+ from acs_data_links r, acs_objects o, acs_mail_log m
+ where r.object_id_two = o.object_id
+ and o.object_type in ('content_item')
+ and r.object_id_one = m.log_id;
+
+
+insert into acs_mail_log_attachment_map (log_id, file_id) select r.object_id_one as log_id, cr.item_id as file_id
+ from acs_data_links r, acs_objects o, acs_mail_log m, cr_revisions cr
+ where r.object_id_two = o.object_id
+ and o.object_id = cr.revision_id
+ and o.object_type in ('content_revision')
+ and r.object_id_one = m.log_id;
+
+insert into acs_mail_log_attachment_map (log_id, file_id) select r.object_id_one as log_id, cr.item_id as file_id
+ from acs_data_links r, acs_objects o, acs_mail_log m, cr_revisions cr
+ where r.object_id_two = o.object_id
+ and o.object_id = cr.revision_id
+ and o.object_type in ('file_storage_object')
+ and r.object_id_one = m.log_id;
+
+insert into acs_mail_log_attachment_map (log_id, file_id) select r.object_id_one as log_id, cr.item_id as file_id
+ from acs_data_links r, acs_objects o, acs_mail_log m, cr_revisions cr
+ where r.object_id_two = o.object_id
+ and o.object_id = cr.revision_id
+ and o.object_type in ('image')
+ and r.object_id_one = m.log_id;
+
Index: openacs-4/packages/mail-tracking/tcl/mail-tracking-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/tcl/mail-tracking-callback-procs.tcl,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/mail-tracking/tcl/mail-tracking-callback-procs.tcl 28 May 2006 07:17:27 -0000 1.6
+++ openacs-4/packages/mail-tracking/tcl/mail-tracking-callback-procs.tcl 14 Nov 2006 07:17:56 -0000 1.7
@@ -73,3 +73,18 @@
-subject $subject]
}
+
+ad_proc -public -callback fs::file_delete -impl mail-tracking {
+ {-package_id:required}
+ {-file_id:required}
+} {
+ Create a copy of the file and attach it to the mail-tracking entry, if the file is referenced
+} {
+
+ if {[db_string file_attached_p "select 1 from acs_mail_log_attachment_map where file_id = :file_id" -default 0]} {
+ set package_id [apm_package_id_from_key mail-tracking]
+ set new_file_id [fs::file_copy -file_id $file_id -target_folder_id $package_id]
+ db_dml update_file "update acs_mail_log_attachment_map set file_id = :new_file_id where file_id = :file_id"
+ }
+}
+
\ No newline at end of file
Index: openacs-4/packages/mail-tracking/tcl/mail-tracking-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/tcl/mail-tracking-procs.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/mail-tracking/tcl/mail-tracking-procs.tcl 28 May 2006 07:17:27 -0000 1.5
+++ openacs-4/packages/mail-tracking/tcl/mail-tracking-procs.tcl 14 Nov 2006 07:17:56 -0000 1.6
@@ -63,25 +63,20 @@
# First create the message entry
- set log_id [db_exec_plsql insert_log_entry {select acs_mail_log__new (
- :log_id,
- :message_id,
- :sender_id,
- :package_id,
- :subject,
- :body,
- :sender_id,
- :creation_ip,
- :context_id,
- :object_id,
- :cc_addr,
- :bcc_addr,
- :to_addr
- )}]
+ db_dml insert_mail_log {
+ insert into acs_mail_log
+ (log_id, message_id, sender_id, package_id, subject, body, sent_date, object_id, cc, bcc, to_addr)
+ values
+ (:log_id, :message_id, :sender_id, :package_id, :subject, :body, now(), :object_id, :cc_addr, :bcc_addr, :to_addr)
+ }
- ns_log Debug "Mail Traking OBJECT $object_id CONTEXT $context_id FILES $file_ids LOGS $log_id"
foreach file_id $file_ids {
- application_data_link::new -this_object_id $log_id -target_object_id $file_id
+ set item_id [content::revision::item_id -revision_id $file_id]
+ if {$item_id eq ""} {
+ set item_id $file_id
+ }
+ db_dml insert_file_map "insert into acs_mail_log_attachment_map (log_id,file_id) values (:log_id,:file_id)"
+ permission::grant -party_id $sender_id -object_id $file_id -privilege "read"
}
# Now add the recipients to the log_id
Index: openacs-4/packages/mail-tracking/www/one-message.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/www/one-message.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/mail-tracking/www/one-message.tcl 14 May 2006 16:11:19 -0000 1.8
+++ openacs-4/packages/mail-tracking/www/one-message.tcl 14 Nov 2006 07:17:56 -0000 1.9
@@ -83,29 +83,12 @@
set bcc_string [join $reciever_list ","]
# We get the related files
-set files [list]
-
-set content_types [list content_revision content_item file_storage_object image]
-foreach content_type $content_types {
-
- foreach file [application_data_link::get_linked -from_object_id $log_id -to_object_type "$content_type"] {
- if { [string equal $content_type "content_revision"] } {
- lappend files [item::get_item_from_revision $file]
- } else {
- lappend files $file
- }
- }
-}
-
+set tracking_url [apm_package_url_from_key "mail-tracking"]
set download_files [list]
-
-foreach file $files {
- set title [content::item::get_title -item_id $file]
- if { [empty_string_p $title]} {
- set title [acs_object_name $file]
- }
- # Creating the link to dowload the files
- lappend download_files "$title"
+set files [db_list files {}]
+foreach file_id $files {
+ set title [content::item::get_title -item_id $file_id]
+ lappend download_files "$title
"
}
set download_files [join $download_files ", "]
Index: openacs-4/packages/mail-tracking/www/one-message.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/mail-tracking/www/one-message.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/mail-tracking/www/one-message.xql 30 Sep 2005 17:37:33 -0000 1.1
+++ openacs-4/packages/mail-tracking/www/one-message.xql 14 Nov 2006 07:17:56 -0000 1.2
@@ -24,4 +24,11 @@
+
+
+ select file_id from acs_mail_log_attachment_map
+ where log_id = :log_id
+
+
+
\ No newline at end of file