Index: openacs-4/packages/dotlrn/www/my-communities.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/my-communities.adp,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/dotlrn/www/my-communities.adp 20 Jan 2002 19:17:39 -0000 1.3
+++ openacs-4/packages/dotlrn/www/my-communities.adp 21 Jan 2002 06:58:45 -0000 1.4
@@ -6,7 +6,7 @@
@communities.pretty_name@
- @communities.role@
- - [ Email Members ]
+ - [ Email Members ]
- []
Index: openacs-4/packages/dotlrn/www/spam.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/spam.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/www/spam.adp 21 Jan 2002 06:58:18 -0000 1.1
@@ -0,0 +1,5 @@
+
+Spam Community
+@context_bar@
+
+
Index: openacs-4/packages/dotlrn/www/spam.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/spam.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/www/spam.tcl 21 Jan 2002 06:58:18 -0000 1.1
@@ -0,0 +1,198 @@
+# dotlrn/www/spam.tcl
+
+ad_page_contract {
+ @author yon (yon@milliped.com)
+ @creation-date Jan 19, 2002
+ @version $Id: spam.tcl,v 1.1 2002/01/21 06:58:18 yon Exp $
+} -query {
+ {community_id ""}
+ {rel_type "dotlrn_member_rel"}
+ {referer "preferences"}
+} -properties {
+ context_bar:onevalue
+}
+
+set context_bar {{$referer Admin} {Spam Community}}
+
+if {[empty_string_p $community_id]} {
+ set community_id [dotlrn_community::get_community_id]
+}
+
+dotlrn::require_user_admin_community $community_id
+
+form create spam_message
+
+element create spam_message community_id \
+ -label "Community ID" \
+ -datatype integer \
+ -widget hidden \
+ -value $community_id
+
+element create spam_message rel_type \
+ -label To \
+ -datatype text \
+ -widget select \
+ -options {{Members dotlrn_member_rel} {Administrators dotlrn_admin_rel}} \
+ -value $rel_type
+
+element create spam_message subject \
+ -label Subject \
+ -datatype text \
+ -widget text \
+ -html {size 50}
+
+element create spam_message message \
+ -label Message \
+ -datatype text \
+ -widget textarea \
+ -html {rows 10 cols 80 wrap soft}
+
+element create spam_message referer \
+ -label Referer \
+ -datatype text \
+ -widget hidden \
+ -value $referer
+
+if {[form is_valid spam_message]} {
+ form get_values spam_message community_id rel_type subject message referer
+
+ # YON: should redirect and close the connection here so that the user
+ # doesn't have to wait for the emails to get sent out.
+
+ set segment_id [db_string select_rel_segment_id {}]
+
+ # set the sql that selects the correct party_ids to spam
+# set sql "
+# select member_id as party_id
+# from party_approved_member_map
+# where party_id = $segment_id
+# and member_id <> $segment_id
+# "
+
+# spam_new_message \
+# -send_date [ns_fmttime [ns_time] "%Y-%m-%d %r"] \
+# -subject $subject \
+# -html $message \
+# -sql $sql \
+# -approved_p 't'
+
+ # YON: since spam is broken and also not flexible enough yet, then we will
+ # send all the emails ourselves.
+
+ # let's get some data we might need
+ set sender_id [ad_conn user_id]
+ db_1row select_sender_info {
+ select parties.email as sender_email,
+ persons.first_names as sender_first_names,
+ persons.last_name as sender_last_name
+ from parties,
+ persons
+ where parties.party_id = :sender_id
+ and persons.person_id = :sender_id
+ }
+
+ set community_name [dotlrn_community::get_community_name $community_id]
+ set community_url [dotlrn_community::get_community_url $community_id]
+
+ # replace some values in the subject and the message
+ regsub -all {} $subject $sender_email subject
+ regsub -all {} $message $sender_email message
+ regsub -all {} $subject $sender_first_names subject
+ regsub -all {} $message $sender_first_names message
+ regsub -all {} $subject $sender_last_name subject
+ regsub -all {} $message $sender_last_name message
+ regsub -all {} $subject $community_name subject
+ regsub -all {} $message $community_name message
+ regsub -all {} $subject $community_url subject
+ regsub -all {} $message $community_url message
+
+ # loop through all the recepeints and send them the spam
+ db_foreach select_recepient_info {
+ select parties.email,
+ decode(acs_objects.object_type,
+ 'user',
+ (select first_names
+ from persons
+ where person_id = parties.party_id),
+ 'group',
+ (select group_name
+ from groups
+ where group_id = parties.party_id),
+ 'rel_segment',
+ (select segment_name
+ from rel_segments
+ where segment_id = parties.party_id),
+ '') as first_names,
+ decode(acs_objects.object_type,
+ 'user',
+ (select last_name
+ from persons
+ where person_id = parties.party_id),
+ '') as last_name
+ from party_approved_member_map,
+ parties,
+ acs_objects
+ where party_approved_member_map.party_id = :segment_id
+ and party_approved_member_map.member_id <> :segment_id
+ and party_approved_member_map.member_id = parties.party_id
+ and parties.party_id = acs_objects.object_id
+ } {
+ # replace some values in the subject and the message
+ regsub -all {} $subject $email subject
+ regsub -all {} $message $email message
+ regsub -all {} $subject $first_names subject
+ regsub -all {} $message $first_names message
+ regsub -all {} $subject $last_name subject
+ regsub -all {} $message $last_name message
+
+ # send the email
+ set errors ""
+ if {[catch {ns_sendmail $email $sender_email $subject $message} errmsg]} {
+ append errors "
+
+ Failed to deliver to $email because:
+
+ [ad_quotehtml $errmsg]
+
+
+ "
+ }
+ }
+
+ # if there were any errors sending the emails, then send an email to the
+ # sender letting them know.
+ if {![empty_string_p $errors]} {
+ set error_subject "There were errors spamming community \"$community_name\""
+ set error_message "
+There were errors spamming community \"$community_name\". The attempted
+message was:
+
+
+
+
+
+ Subject |
+ $subject |
+
+
+ Message |
+ $message |
+
+
+
+
+
+The errors were: $errors
+ "
+
+ if {[catch {ns_sendmail $sender_email $sender_email $error_subject $error_message} errmsg]} {
+ ad_return_error $error_subject $error_message
+ ad_script_abort
+ }
+ }
+
+ ad_returnredirect $referer
+ ad_script_abort
+}
+
+ad_return_template
Index: openacs-4/packages/dotlrn/www/spam.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/spam.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn/www/spam.xql 21 Jan 2002 06:58:18 -0000 1.1
@@ -0,0 +1,12 @@
+
+
+
+
+
+ select rel_segments.segment_id
+ from rel_segments
+ where rel_segments.group_id = :community_id
+ and rel_segments.rel_type = :rel_type
+
+
+