(created by @jobs.user_name@, sent @jobs.mails_sent@ on @jobs.execution_date@, status: @jobs.state@)
(Link Tracking)
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/job-history-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/job-history-2.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/job-history-2.tcl 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/job-history-2.tcl 21 Jan 2004 19:22:15 -0000 1.2
@@ -42,7 +42,17 @@
}
}
-db_multirow jobs ml_mail_job_history {}
+db_multirow -extend {user_name} jobs ml_mail_job_history {} {
+ if {[string equal $user_first_names "first_names"]} {
+ set user_first_names ""
+ }
+ if {[string equal $user_last_name "last_name"]} {
+ set user_last_name ""
+ set user_name $user_first_names
+ } else {
+ set user_name "$user_first_names $user_last_name"
+ }
+}
set context_bar [list [list "." Administration] [list job-history "Mail Job History"] "Show"]
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/job-pending-oracle.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/job-pending-oracle.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/job-pending-oracle.xql 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/job-pending-oracle.xql 21 Jan 2004 19:22:15 -0000 1.2
@@ -8,9 +8,8 @@
select j.mail_job_id, j.mail_class_id, j.subject, j.state,
to_char(j.scheduled_date, 'YYYY-MM-DD HH24:MI') as execution_date
- from ml_mail_jobs j, acs_named_objects o
- where o.package_id = :package_id
- and o.object_id = j.mail_job_id
+ from ml_mail_jobs j
+ where j.package_id = :package_id
and j.state in ('suspended', 'active')
and acs_permission.permission_p(j.mail_job_id, :user_id, 'admin') = 't'
order by j.scheduled_date, lower(subject)
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/job-pending-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/job-pending-postgresql.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/job-pending-postgresql.xql 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/job-pending-postgresql.xql 21 Jan 2004 19:22:15 -0000 1.2
@@ -8,9 +8,8 @@
select j.mail_job_id, j.mail_class_id, j.subject, j.state,
to_char(j.scheduled_date, 'YYYY-MM-DD HH24:MI') as execution_date
- from ml_mail_jobs j, acs_named_objects o
- where o.package_id = :package_id
- and o.object_id = j.mail_job_id
+ from ml_mail_jobs j
+ where j.package_id = :package_id
and j.state in ('suspended', 'active')
and acs_permission__permission_p(j.mail_job_id, :user_id, 'admin') = 't'
order by j.scheduled_date, lower(subject)
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/job-preview.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/job-preview.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/job-preview.adp 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/job-preview.adp 21 Jan 2004 19:22:15 -0000 1.2
@@ -45,5 +45,5 @@
-
+
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/job-preview.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/job-preview.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/job-preview.tcl 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/job-preview.tcl 21 Jan 2004 19:22:15 -0000 1.2
@@ -105,7 +105,7 @@
# get list of all valid vars
if {[exists_and_not_null list_id]} {
# get all valid variables for mailing lists
- set valid_vars [list user_id user_first_names user_last_name user_email]
+ set valid_vars [list user_id user_first_names user_last_name user_email link view_mail_link]
} else {
# get sql-query
if {![db_0or1row get_mail_job_sql_query {}]} {
@@ -118,6 +118,7 @@
# get query columns - these are the variables names
# the user is allowed to use
set valid_vars [user_selection::get_field_names -query $sql_query]
+ lappend valid_vars link view_mail_link
}
# check text if all used variables are valid
@@ -139,11 +140,18 @@
# we have to use noquote-substitution for plaintext emails
while {[regsub -all [template::adp_variable_regexp] $mail_text_body {\1@\2;noquote@} mail_text_body]} {}
}
+ if {![empty_string_p $mail_html_body]} {
+ # we have to use noquote-substitution for mail view tracking in html mails
+ while {[regsub -all -nocase {@view_mail_link@} $mail_html_body {@view_mail_link;noquote@} mail_html_body]} {}
+ while {[regsub -all -nocase {?(html|body|head|title)[^>]*?>} $mail_html_body {} mail_html_body]} {}
+ }
set user_first_names "Joe"
set user_last_name "User"
set user_id 999
set user_email "joe.user@hotmail.com"
+ set link "[ad_url][ad_conn package_url]?user_id=$user_id&x=some_x_test"
+ set view_mail_link ""
variable ::template::parse_level
lappend ::template::parse_level [info level]
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/jobs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/jobs.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/jobs.tcl 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/jobs.tcl 21 Jan 2004 19:22:15 -0000 1.2
@@ -8,6 +8,8 @@
bind_var:array,optional
}
+ns_log notice "$list_id"
+
set user_id [ad_maybe_redirect_for_registration]
set package_id [ad_conn package_id]
permission::require_permission -object_id $package_id -privilege mailing_list_admin
@@ -77,7 +79,7 @@
{list_id:text(hidden)}
{list_name:text(inform) {label "Mailing List"}}
}
- set allowed_variables [list user_id user_first_names user_last_name user_email]
+ set allowed_variables [list user_id user_first_names user_last_name user_email link view_mail_link]
} else {
# spamming an user-selection
ad_form -extend -name mail_job_form -form {
@@ -106,6 +108,7 @@
set query_string [db_bind_var_substitution $query_string $subs_list]
}
set allowed_variables [user_selection::get_field_names -query $query_string]
+ lappend allowed_variables link view_mail_link
}
ad_form -extend -name mail_job_form -form {
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/list-subscribe.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/list-subscribe.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/list-subscribe.tcl 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/list-subscribe.tcl 21 Jan 2004 19:22:15 -0000 1.2
@@ -1,102 +1,116 @@
-ad_page_contract {
-}
-
-set user_id [ad_maybe_redirect_for_registration]
-set package_id [ad_conn package_id]
-permission::require_permission -object_id $package_id -privilege mailing_list_admin
-
-set context_bar [list [list "." Administration] "Mass Subscribe to Mailing List"]
-
-set lists [db_list_of_lists get_mailing_lists {}]
-
-
-ad_form -name list_mass_subscribe_form -action list-subscribe -form {
- {list_id:text(select) {label "Mailing List"} {options $lists}}
- {xx:text(inform) {label " "} {value "Enter emails and 2-character country code as a comma-seperated list (csv)"}}
- {emails_countries:text(textarea) {label "Emails and Countries"} {html {rows 30 cols 80}}}
- {confirmation_p:text(checkbox),optional {label "Send confirmation?"} {options {{"Yes" t}}}}
-} -validate {
- {emails_countries {
- [empty_string_p [set invalid_list [mailing_list::util::check_valid_country_codes -emails_and_countries $emails_countries]]]}
- "Invalid country code for emails: [join $invalid_list , ]"}
- {emails_countries {
- [empty_string_p [set invalid_list [mailing_list::util::check_valid_emails -emails_and_countries $emails_countries]]]}
- "Invalid emails: [join $invalid_list , ]"}
-} -on_submit {
- permission::require_permission -object_id $list_id -privilege read
-
- if {[exists_and_not_null confirmation_p]} {
- set confirmed_p f
- } else {
- set confirmed_p t
- }
- set default_first_names "Unknown"
- set default_last_name "User"
- set default_question "q"
- set default_answer "a"
-
- db_1row get_list_mail_data {}
-
- # get all mappings country_code -> country_id so that we can map users
- # to country_ids a lot easier
- db_foreach get_country_codes {} {
- set country_id($country_code) $category_id
- }
-
- # generate tmp-file for csv-processing
- set tmp_file [ns_tmpnam]
- set fd [open $tmp_file w]
- puts $fd $emails_countries
- close $fd
- set fd [open $tmp_file r]
-
- set unsubscribe_link "[ad_url][ad_conn package_url]"
-
- db_transaction {
- # process every line of the user/country list
- while {[ns_getcsv $fd line] > 0} {
-
- set user_id ""
- # grap the email and country of the current line
- util_unlist $line email country
-
- # check if user already exists
- set user_id [cc_email_user $email]
-
- if {[empty_string_p $user_id]} {
- # user doesn't exist, so create him
- set user_password [ad_generate_random_string]
- set user_id [ad_user_new $email $default_first_names $default_last_name $user_password $default_question $default_answer "" $confirmed_p]
- } else {
- set user_password ""
- }
-
- set confirmation_link "[ad_url][ad_conn package_url]confirm?[export_url_vars list_id user_id]"
-
- # try to map user to the given country - this might fail if user
- # is already mapped
- catch {[category::map_object -remove_old -object_id $user_id $country_id($country)]}
-
- # subscribe user. check if user already has a map entry
- if {[mailing_list::add_user -list_id $list_id -user_id $user_id -confirmed_p $confirmed_p]} {
- # user is newly added to this list
- # now send confirmation message to user if requested
- if {$confirmed_p == "f"} {
- mailing_list::util::send_mail -user_id $user_id -from_email $sender_email -subject $confirm_subject -body $confirm_body -mime_type $confirm_mime_type -charset $mime_charset -link $confirmation_link -new_password $user_password
- } else {
- # send welcome message if no confirmation needed
- mailing_list::util::send_mail -user_id $user_id -from_email $sender_email -subject $welcome_subject -body $welcome_body -mime_type $welcome_mime_type -charset $mime_charset -link "$unsubscribe_link?[export_url_vars user_id]" -new_password $user_password
- }
- }
- }
- }
-
- # remove tmp-file for csv processing
- close $fd
- ns_unlink $tmp_file
-} -after_submit {
- ad_returnredirect "."
- ad_script_abort
-}
-
-ad_return_template
+ad_page_contract {
+}
+
+set user_id [ad_maybe_redirect_for_registration]
+set package_id [ad_conn package_id]
+permission::require_permission -object_id $package_id -privilege mailing_list_admin
+
+set context_bar [list [list "." Administration] "Mass Subscribe to Mailing List"]
+
+set lists [db_list_of_lists get_mailing_lists {}]
+
+
+ad_form -name list_mass_subscribe_form -action list-subscribe -form {
+ {list_id:text(select) {label "Mailing List"} {options $lists}}
+ {xx:text(inform) {label " "} {value "Enter emails, first names and last names as a list (csv)"}}
+ {emails:text(textarea) {label "Emails"} {html {rows 30 cols 80}}}
+ {confirmation_p:text(checkbox),optional {label "Send confirmation?"} {options {{"Yes" t}}}}
+ {no_emails_p:text(checkbox),optional {label "Suppress all emails?"} {options {{"Yes" t}}}}
+} -validate {
+ {emails {
+ [empty_string_p [set invalid_list [mailing_list::util::check_valid_emails -emails $emails]]]}
+ "Invalid emails: [join $invalid_list , ]"}
+} -on_submit {
+ permission::require_permission -object_id $list_id -privilege read
+
+ if {[exists_and_not_null no_emails_p]} {
+ set no_emails_p t
+ set confirmed_p t
+ } else {
+ set no_emails_p f
+ if {[exists_and_not_null confirmation_p]} {
+ set confirmed_p f
+ } else {
+ set confirmed_p t
+ }
+ }
+
+ set default_first_names "first_names"
+ set default_last_name "last_name"
+
+ db_1row get_list_mail_data {}
+
+ # generate tmp-file for csv-processing
+ set tmp_file [ns_tmpnam]
+ set fd [open $tmp_file w]
+ puts $fd $emails
+ close $fd
+ set fd [open $tmp_file r]
+
+ set unsubscribe_link "[ad_url][ad_conn package_url]"
+
+ db_transaction {
+ # process every line of the email list
+ while {[ns_getcsv $fd line] > 0} {
+
+ set user_id ""
+ # grap the email of the current line
+ util_unlist $line email user_first_names user_last_name
+ if {[empty_string_p "$user_first_names$user_last_name"]} {
+ set user_first_names $default_first_names
+ set user_last_name $default_last_name
+ }
+
+ # check if user already exists
+ set user_id [db_string get_user_id {} -default ""]
+
+ if {[empty_string_p $user_id]} {
+ # user doesn't exist, so create him
+ set user_password [ad_generate_random_string]
+ set user_id [db_nextval acs_object_id_seq]
+
+ array set creation_info [auth::create_user \
+ -user_id $user_id \
+ -email $email \
+ -first_names $user_first_names \
+ -last_name $user_last_name \
+ -password $user_password \
+ -email_verified_p $confirmed_p]
+
+ if {$creation_info(creation_status) != "ok"} {
+ # something went wrong during user creation
+ ns_log notice "list-subscribe: could not create user $email: $creation_info(element_messages)"
+ }
+ array unset creation_info
+ } else {
+ set user_password ""
+ }
+
+ set confirmation_link "[ad_url][ad_conn package_url]confirm?[export_url_vars list_id user_id]"
+
+ # subscribe user. check if user already has a map entry
+ if {[mailing_list::add_user -list_id $list_id -user_id $user_id -confirmed_p $confirmed_p]} {
+ if {$no_emails_p == "f"} {
+ # user is newly added to this list
+ # now send confirmation message to user if requested
+ if {$confirmed_p == "f"} {
+ mailing_list::util::send_mail -user_id $user_id -from_email $sender_email -subject $confirm_subject -body $confirm_body -mime_type $confirm_mime_type -charset $mime_charset -link $confirmation_link -new_password $user_password
+ } else {
+ # send welcome message if no confirmation needed
+ mailing_list::util::send_mail -user_id $user_id -from_email $sender_email -subject $welcome_subject -body $welcome_body -mime_type $welcome_mime_type -charset $mime_charset -link "$unsubscribe_link?[export_url_vars user_id]" -new_password $user_password
+ }
+ }
+ }
+ }
+ }
+
+ # remove tmp-file for csv processing
+ close $fd
+ ns_unlink $tmp_file
+} -after_submit {
+ ad_returnredirect "."
+ ad_script_abort
+}
+
+ad_return_template
+
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/list-subscribe.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/list-subscribe.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/list-subscribe.xql 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/list-subscribe.xql 21 Jan 2004 19:22:15 -0000 1.2
@@ -14,12 +14,13 @@
-
+
- select country_code, category_id
- from ml_country_codes
-
+ select party_id
+ from parties
+ where email = lower(:email)
+
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/stats-all-region.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/stats-all-region.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/stats-all-region.tcl 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/stats-all-region.tcl 21 Jan 2004 19:22:15 -0000 1.2
@@ -1,60 +1,42 @@
ad_page_contract {
- Show all clicks on a link from a given mail job , brocken down by Region and Country within Region.
-
-
+ Show all clicks on a link from a given mail job, broken down by Region and Country within Region.
} {
-
-
-
link_id:notnull
mail_job_id:notnull
-
-
} -properties {
-
all_countries:multirow
regions:multirow
overall_clicks:onevalue
url:onevalue
}
-
set package_id [ad_conn package_id]
set context_bar [list [list "." Administration] [list job-history "Mail Job History"] [list link-track?mail_job_id=$mail_job_id "Link Tracking"] "Alphanumeric Statistics"]
set mailing_list_package_id [user_register::util::get_sw_package_id -package_key mailing-lists]
-
-if {![db_0or1row get_current_country_category_tree {select tree_id
- from ml_country_category_tree
- where package_id = :mailing_list_package_id}]} {
+if {![db_0or1row get_current_country_category_tree {}]} {
# no country tree mapped, so return to index page immediately
ad_returnredirect "."
return
}
-
-
-
template::multirow create all_countries region_id pretty_country clicks
set cur_parent_id 0
db_1row get_link_url {}
-
db_foreach get_all_clicks_for_link {} {
if {$cur_parent_id != $parent_id} {
set total_clicks($parent_id) 0
set cur_parent_id $parent_id
}
template::multirow append all_countries $parent_id [category::get_name $country_id] $number_clicks
- set total_clicks($parent_id) [expr $total_clicks($parent_id) + $number_clicks]
- }
+ set total_clicks($parent_id) [expr $total_clicks($parent_id) + $number_clicks]
+}
-
-
template::multirow create regions pretty_region clicks region_id
set overall_clicks 0
Index: openacs-4/contrib/packages/mailing-lists/www/madmin/stats-weekly.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/mailing-lists/www/madmin/stats-weekly.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/contrib/packages/mailing-lists/www/madmin/stats-weekly.adp 1 Oct 2003 05:01:55 -0000 1.1
+++ openacs-4/contrib/packages/mailing-lists/www/madmin/stats-weekly.adp 21 Jan 2004 19:22:15 -0000 1.2
@@ -1,27 +1,27 @@
-Administer Country Codes
+Weekly Mail Link Clicks@context_bar;noquote@