Index: openacs-4/packages/dotlrn/lib/member-email-confirm.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/lib/member-email-confirm.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/lib/member-email-confirm.adp 21 Dec 2006 15:57:53 -0000 1.1 @@ -0,0 +1 @@ + \ No newline at end of file Index: openacs-4/packages/dotlrn/lib/member-email-confirm.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/lib/member-email-confirm.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/lib/member-email-confirm.tcl 21 Dec 2006 15:57:53 -0000 1.1 @@ -0,0 +1,77 @@ +ad_page_contract { + Ask admin to confirm email and if so + let the admin edit the email before sending +} { + user_id:integer,multiple + {type "on join"} + {return_url ""} +} + +permission::require_permission \ + -party_id [ad_conn user_id] \ + -object_id $community_id \ + -privilege admin + +# FIXME list/unlist user_id since hidden vars can't be multiple + +ad_form -name member-email-confirm \ + -export { user_id community_id return_url type } \ + -has_submit 1 \ + -form { + {from_addr:text } + {subject:text } + {email:richtext } + {btn_ok:text(submit) {label "[_ dotlrn.OK_Send_Email]"}} + {btn_cancel:text(submit) {label "[_ dotlrn.Cancel_Dont_Send_email]"}} + } -on_request { + set community_name [dotlrn_community::get_community_name $community_id] + + if {![db_0or1row member_email {}]} { + set default_email [lindex [callback dotlrn::default_member_email -community_id $community_id -type $type -var_list [list course_name $community_name community_name $community_name]] 0] + if {![llength $default_email]} { + set from_addr [cc_email_from_party [ad_conn user_id]] + set subject "Welcome to ${community_name}!" + } + set from_addr [lindex $default_email 0] + set subject [lindex $default_email 1] + set email [lindex $default_email 2] + } + set package [ad_parameter -package_id [ad_acs_kernel_id] SystemURL] + if {$subject eq ""} { + set subject [_ dotlrn.added_community_subject] + } + if {$email eq ""} { + set email [_ dotlrn.added_community_message] + } + if {$from_addr eq ""} { + set from_addr [cc_email_from_party [ad_conn user_id]] + } + set email [template::util::richtext::create $email text/html] + } -on_submit { + if {![info exists btn_cancel] || $btn_cancel eq ""} { + set email [template::util::richtext::get_property content $email] + if {![empty_string_p $community_id]} { + + foreach one_user_id $user_id { + dotlrn_community::send_member_email \ + -community_id $community_id \ + -to_user $one_user_id \ + -type $type \ + -override_email $email \ + -override_subject $subject + } + + + } + set message [_ dotlrn.Email_Sent] + } else { + set message [_ dotlrn.Email_Cancelled] + } + + ad_returnredirect -message $message $return_url + ad_script_abort +} + +ad_return_template + + Index: openacs-4/packages/dotlrn/tcl/community-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/tcl/community-procs.tcl,v diff -u -r1.197 -r1.198 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 15 Dec 2006 22:45:22 -0000 1.197 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 21 Dec 2006 15:57:53 -0000 1.198 @@ -863,8 +863,6 @@ -op AddUserToCommunity \ -list_args [list $community_id $user_id] - # Send membership email - send_member_email -community_id $community_id -to_user $user_id -type "on join" } } @@ -2344,7 +2342,6 @@ -subject $subject \ -body $message \ -extraheaders $extra_headers - set return_val 1 } else { set return_val 0 Index: openacs-4/packages/dotlrn/www/member-add-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/member-add-3.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/dotlrn/www/member-add-3.tcl 8 Aug 2006 21:26:24 -0000 1.10 +++ openacs-4/packages/dotlrn/www/member-add-3.tcl 21 Dec 2006 15:57:53 -0000 1.11 @@ -29,6 +29,7 @@ set community_id [dotlrn_community::get_community_id] # See if the user is already in the group +set user_ids_to_email [list] foreach uid $user_id { set member_p [dotlrn_community::member_p $community_id $uid] @@ -39,6 +40,12 @@ # Add the relation dotlrn_community::add_user -rel_type $rel_type $community_id $uid + lappend user_ids_to_email $uid + } + +if {[llength $user_ids_to_email]} { + set referer [export_vars -base member-email-confirm {{user_id $user_ids_to_email} community_id {return_url $referer}}] +} ad_returnredirect $referer Index: openacs-4/packages/dotlrn/www/member-email-confirm.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/member-email-confirm.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/www/member-email-confirm.adp 21 Dec 2006 15:57:53 -0000 1.1 @@ -0,0 +1,6 @@ + +@page_title@ +@context@ + +The user(s) have been added to the selected community. You can send an email to welcome the users to the community. + Index: openacs-4/packages/dotlrn/www/member-email-confirm.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/member-email-confirm.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/dotlrn/www/member-email-confirm.tcl 21 Dec 2006 15:57:53 -0000 1.1 @@ -0,0 +1,20 @@ +ad_page_contract { + Confirm an email to be sent +} -query { + community_id +} -validate { + community_id_is_dotlrn_community { + if {[dotlrn_community::get_community_key -community_id $community_id] eq ""} { + ad_complain "$community_id is not a valid community_id" + } + } +} + +permission::require_permission \ + -party_id [ad_conn user_id] \ + -object_id $community_id \ + -privilege admin + +set page_title "Confirm Email" +set context [list $page_title] + Index: openacs-4/packages/dotlrn/www/members-chunk-table.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/members-chunk-table.tcl,v diff -u -r1.27 -r1.28 --- openacs-4/packages/dotlrn/www/members-chunk-table.tcl 8 Aug 2006 21:26:24 -0000 1.27 +++ openacs-4/packages/dotlrn/www/members-chunk-table.tcl 21 Dec 2006 15:57:53 -0000 1.28 @@ -162,16 +162,21 @@ } if {[form is_valid parent_users_form]} { - + set user_ids_to_email [list] foreach user $parent_user_list { set rel [element get_value parent_users_form "selected_user.[ns_set get $user user_id]"] if {![string match $rel none]} { dotlrn_community::add_user -rel_type $rel $community_id [ns_set get $user user_id] + lappend user_ids_to_email [ns_set get $user user_id] } } - - ad_returnredirect [ns_conn url] + if {[llength $user_ids_to_email]} { + set return_url [export_vars -base member-email-confirm {{user_id $user_ids_to_email} community_id}] + } else { + set return_url [ns_conn url] + } + ad_returnredirect $return_url } } Index: openacs-4/packages/dotlrn/www/members-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/members-chunk.tcl,v diff -u -r1.19 -r1.20 --- openacs-4/packages/dotlrn/www/members-chunk.tcl 8 Aug 2006 21:26:24 -0000 1.19 +++ openacs-4/packages/dotlrn/www/members-chunk.tcl 21 Dec 2006 15:57:53 -0000 1.20 @@ -96,12 +96,17 @@ if {[form is_valid parent_users_form]} { set selected_users [element get_values parent_users_form selected_users] - + set user_ids_to_email [list] foreach selected_user $selected_users { dotlrn_community::add_user -rel_type $parent_user_role($selected_user) $community_id $selected_user + lappend user_ids_to_email $selected_user } - - ad_returnredirect [ns_conn url] + if {[llength $user_ids_to_email]} { + set return_url [export_vars -base member-email-confirm {{user_id $user_ids_to_email} community_id}] + } else { + set return_url [ns_conn url] + } + ad_returnredirect $return_url } set selected_users_options [list] Index: openacs-4/packages/dotlrn/www/members.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/members.tcl,v diff -u -r1.24 -r1.25 --- openacs-4/packages/dotlrn/www/members.tcl 8 Aug 2006 21:26:24 -0000 1.24 +++ openacs-4/packages/dotlrn/www/members.tcl 21 Dec 2006 15:57:53 -0000 1.25 @@ -239,16 +239,21 @@ } if {[form is_valid parent_users_form]} { - + set user_ids_to_email [list] foreach user $parent_user_list { set rel [element get_value parent_users_form "selected_user.[ns_set get $user user_id]"] if {![string match $rel none]} { dotlrn_community::add_user -rel_type $rel $community_id [ns_set get $user user_id] + lappend user_ids_to_email [ns_set get $user user_id] } } - - ad_returnredirect [ns_conn url] + if {[llength $user_ids_to_email]} { + set return_url [export_vars -base member-email-confirm {{user_id $user_ids_to_email} community_id}] + } else { + set return_url [ns_conn url] + } + ad_returnredirect $return_url } } Index: openacs-4/packages/dotlrn/www/admin/add-instructor-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/add-instructor-3.tcl,v diff -u -r1.13 -r1.14 --- openacs-4/packages/dotlrn/www/admin/add-instructor-3.tcl 8 Aug 2006 21:26:28 -0000 1.13 +++ openacs-4/packages/dotlrn/www/admin/add-instructor-3.tcl 21 Dec 2006 15:57:53 -0000 1.14 @@ -40,5 +40,5 @@ # Add the relation dotlrn_community::add_user -rel_type dotlrn_instructor_rel $community_id $user_id -ad_returnredirect $referer +ad_returnredirect [export_vars -base ../member-email-confirm {{return_url $referer} community_id user_id}] Index: openacs-4/packages/dotlrn/www/admin/users-add-to-community.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn/www/admin/users-add-to-community.tcl,v diff -u -r1.14 -r1.15 --- openacs-4/packages/dotlrn/www/admin/users-add-to-community.tcl 8 Aug 2006 21:26:28 -0000 1.14 +++ openacs-4/packages/dotlrn/www/admin/users-add-to-community.tcl 21 Dec 2006 15:57:53 -0000 1.15 @@ -32,8 +32,7 @@ set context_bar [list [list users [_ dotlrn.Users]] [list users-search [_ dotlrn.User_Search]] [_ dotlrn.Add_Users_to_Group]] -form create select_community - +form create select_community -html {action select_community action users-add-to-community-email} element create select_community users \ -label " " \ -datatype text \ @@ -61,6 +60,7 @@ -datatype text \ -widget select \ -options "{{} {}} $communities" + } else { element create select_community community_id \ -label "[_ dotlrn.No_groups_to_add_to]" \ @@ -73,37 +73,20 @@ form get_values select_community \ users community_id - if {![empty_string_p $community_id]} { + + if {![empty_string_p $community_id]} { db_transaction { foreach user $users { dotlrn_community::add_user $community_id $user } } + } + set message "Users added to community. " - # Now notify the users that they've been added to the community. + ad_returnredirect [export_vars \ + -base ../member-email-confirm \ + {{user_id $users} community_id}] - set sender_email [cc_email_from_party [ad_conn user_id]] - foreach {community} $communities { - if { $community_id == [lindex $community 1] } { - set community_name [lindex $community 0] - break - } - } - - set package [ad_parameter -package_id [ad_acs_kernel_id] SystemURL] - set subject [_ dotlrn.added_community_subject] - set message [_ dotlrn.added_community_message] - - spam::send \ - -recepients $users \ - -from $sender_email \ - -real_from $sender_email \ - -subject $subject \ - -message $message \ - -message_values [list] - } - - ad_returnredirect $referer ad_script_abort }