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.191.2.6 -r1.191.2.7 --- openacs-4/packages/dotlrn/tcl/community-procs.tcl 4 Aug 2005 18:47:00 -0000 1.191.2.6 +++ openacs-4/packages/dotlrn/tcl/community-procs.tcl 7 Aug 2005 20:10:22 -0000 1.191.2.7 @@ -2210,6 +2210,7 @@ {-community_id:required} {-to_user:required} {-type "on join"} + {-var_list ""} } { Send a membership email to the user @@ -2224,16 +2225,21 @@ @error } { - if { [db_0or1row member_email { + set course_name [dotlrn_community::get_community_name $community_id] + lappend var_list course_name $course_name community_name $course_name + set var_list [lindex [callback dotlrn::member_email_var_list -community_id $community_id -to_user $to_user -type $type] 0] + + if {![db_0or1row member_email { select from_addr, subject, email from dotlrn_member_emails where enabled_p and community_id = :community_id and type = :type - }] } else { - set default_email [lindex [callback dotlrn::default_member_email -community_id $community_id -to_user $to_user -type $type] 0] + }] } { + # no email in database, use default + set default_email [lindex [callback dotlrn::default_member_email -community_id $community_id -to_user $to_user -type $type -var_list $var_list] 0] if {[llength $default_email]} { set from_addr [lindex $default_email 0] set subject [lindex $default_email 1] @@ -2242,6 +2248,18 @@ } if {[exists_and_not_null email]} { + # user %varname% to substitute variables in email + set subject_vars [lang::message::get_embedded_vars $subject] + set email_vars [lang::message::get_embedded_vars $email] + foreach var [concat $subject_vars $email_vars] { + if {![info exists vars($var)]} { + set vars($var) "" + } + } + set var_list [array get vars] + set subject [lang::message::format $subject $var_list] + set email "[lang::message::format $email $var_list]" + # Shamelessly cut & pasted from bulk mail if { [empty_string_p $from_addr] } { set from_addr [ad_system_owner]