Index: openacs-4/packages/dotlrn/www/spam-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/Attic/spam-oracle.xql,v diff -u -r1.2.6.1 -r1.2.6.2 --- openacs-4/packages/dotlrn/www/spam-oracle.xql 21 Jun 2004 19:55:37 -0000 1.2.6.1 +++ openacs-4/packages/dotlrn/www/spam-oracle.xql 22 Jul 2004 05:58:37 -0000 1.2.6.2 @@ -31,22 +31,22 @@ '') as last_name, '$safe_community_name' as community_name, '$community_url' as community_url - from party_approved_member_map, + from acs_rels, 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 + where (acs_rels.object_id_one = $community_id + and acs_rels.object_id_two = parties.party_id + and (acs_rels.rel_type in ('$rel_types_str') + or acs_rels.object_id_two in ($recipients_str)) + and parties.party_id = acs_objects.object_id and parties.party_id in (select acs_rels.object_id_two from acs_rels, membership_rels where acs_rels.object_id_one = acs.magic_object_id('registered_users') and acs_rels.rel_id = membership_rels.rel_id and membership_rels.member_state - = 'approved') - $extra_where_clause + = 'approved')) Index: openacs-4/packages/dotlrn/www/spam-recipients.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/spam-recipients.adp,v diff -u -r1.1.2.2 -r1.1.2.3 --- openacs-4/packages/dotlrn/www/spam-recipients.adp 22 Jun 2004 00:41:36 -0000 1.1.2.2 +++ openacs-4/packages/dotlrn/www/spam-recipients.adp 22 Jul 2004 05:58:37 -0000 1.1.2.3 @@ -27,8 +27,15 @@

+ +Send to the following roles:

+ +@rel_types_html;noquote@ #dotlrn.Send_to_all#

+ +In addition, send to the following people:

+ Index: openacs-4/packages/dotlrn/www/spam-recipients.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/spam-recipients.tcl,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/dotlrn/www/spam-recipients.tcl 21 Jun 2004 19:55:38 -0000 1.1.2.1 +++ openacs-4/packages/dotlrn/www/spam-recipients.tcl 22 Jul 2004 05:58:37 -0000 1.1.2.2 @@ -29,7 +29,27 @@ set read_private_data_p 1 } + set community_id [dotlrn_community::get_community_id] + +#element create spam_message rel_type \ +# -label [_ dotlrn.To] \ +# -datatype text \ + # -widget select \ + # -options [list [list [_ dotlrn.Members] dotlrn_member_rel] [list [_ dotlrn.Administrators] dotlrn_admin_rel]] \ + # -value $rel_type + + +# SET THE PROPERTIES RIGHT + +set roles [dotlrn_community::get_roles -community_id $community_id] +set rel_types_html "" + +foreach {rel_type role pretty_name pretty_plural} [eval concat $roles] { + append rel_types_html " [lang::util::localize $pretty_plural]
" + +} + db_multirow current_members select_current_members {} set exported_vars [export_vars -form { referer }] Index: openacs-4/packages/dotlrn/www/spam.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/spam.tcl,v diff -u -r1.21.6.3 -r1.21.6.4 --- openacs-4/packages/dotlrn/www/spam.tcl 22 Jun 2004 00:41:36 -0000 1.21.6.3 +++ openacs-4/packages/dotlrn/www/spam.tcl 22 Jul 2004 05:58:37 -0000 1.21.6.4 @@ -22,7 +22,8 @@ {recipients:integer,multiple ""} {recipients_str ""} {community_id ""} - {rel_type "dotlrn_member_rel"} + {rel_types:multiple "" } + {rel_types_str ""} {referer "control-panel"} {spam_all 0} } -validate { @@ -36,6 +37,11 @@ set recipients [split $recipients_str] } } + rel_types_split { + if { [info exists rel_types_str] && ![info exists rel_types] } { + set rel_types [split $rel_types_str] + } + } } -properties { context_bar:onevalue portal_id:onevalue @@ -61,7 +67,6 @@ set sender_first_names [db_quote $sender_first_names] set sender_last_name [db_quote $sender_last_name] - form create spam_message element create spam_message community_id \ @@ -77,13 +82,6 @@ -html {size 60} \ -value $sender_email -element create spam_message rel_type \ - -label [_ dotlrn.To] \ - -datatype text \ - -widget select \ - -options [list [list [_ dotlrn.Members] dotlrn_member_rel] [list [_ dotlrn.Administrators] dotlrn_admin_rel]] \ - -value $rel_type - element create spam_message subject \ -label [_ dotlrn.Subject] \ -datatype text \ @@ -122,6 +120,12 @@ -widget hidden \ -value $recipients +element create spam_message rel_types_str \ + -label rel_types \ + -datatype text \ + -widget hidden \ + -value $rel_types + element create spam_message spam_all \ -label spam \ -datatype text \ @@ -130,23 +134,42 @@ if {[ns_queryexists "form:confirm"]} { form get_values spam_message \ - community_id from rel_type subject message message_type send_date referer recipients_str spam_all + community_id from rel_types_str subject message message_type send_date referer recipients_str spam_all - set segment_id [db_string select_rel_segment_id {}] set community_name [dotlrn_community::get_community_name $community_id] set community_url "[ad_parameter -package_id [ad_acs_kernel_id] SystemURL][dotlrn_community::get_community_url $community_id]" + set recipients_str [join [split $recipients_str] ,] + set rel_types_str [join [split $rel_types_str] ','] + + +# POSTGRES - change to plural +# TODO - what if no rel_types + set safe_community_name [db_quote $community_name] + set extra_where_clause "" + if { $spam_all } { - set extra_where_clause "" - } else { - set extra_where_clause "and parties.party_id in ($recipients_str)" + # if there is a spam_all, choose all the rel_types! + + set rel_types_str [join [db_list select_rel_segments " + select rel_segments.rel_type + from rel_segments + where rel_segments.group_id = :community_id"] ','] + } + + if {[empty_string_p $recipients_str]} { + set recipients_str '' } + + set query [db_map sender_info] -ns_log notice "query: $query" + # TO DO CHANGE THE ORACLE QUERY + + ns_log notice "query: $query" bulk_mail::new \ -package_id [site_node_apm_integration::get_child_package_id -package_key [bulk_mail::package_key]] \ Index: openacs-4/packages/dotlrn/www/spam.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/spam.xql,v diff -u -r1.7 -r1.7.10.1 --- openacs-4/packages/dotlrn/www/spam.xql 15 May 2002 22:13:57 -0000 1.7 +++ openacs-4/packages/dotlrn/www/spam.xql 22 Jul 2004 05:58:37 -0000 1.7.10.1 @@ -14,12 +14,12 @@ - + select rel_segments.segment_id from rel_segments where rel_segments.group_id = :community_id - and rel_segments.rel_type = :rel_type + and rel_segments.rel_type in (:rel_types_str)