Index: openacs-4/packages/forums/www/admin/subscribe-others-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/www/admin/subscribe-others-2.tcl,v diff -u -r1.1.2.1 -r1.1.2.2 --- openacs-4/packages/forums/www/admin/subscribe-others-2.tcl 8 Apr 2005 18:41:58 -0000 1.1.2.1 +++ openacs-4/packages/forums/www/admin/subscribe-others-2.tcl 8 Apr 2005 23:43:05 -0000 1.1.2.2 @@ -9,6 +9,7 @@ } { forum_id:integer,notnull type_id:integer,notnull + {lines ""} {return_url "."} interval:notnull delivery_method:notnull @@ -34,8 +35,10 @@ ns_write "Subscribing users" -set lines [split $emails "\n"] +set lines [join $emails "\n"] + + db_transaction { foreach line $lines { @@ -56,30 +59,43 @@ set lname "(no last name)" } - ns_write "

fname:$fname
lname:$lname
email:$email
" - + ns_write "

---$email---" + if {![util_email_valid_p $email]} { set user_id "" + ns_write "
invalid email address" } else { - set user_id [db_string get_party_id { - select party_id - from parties + + if {[db_0or1row get_party_id { + select party_id, first_names as fname, last_name as lname + from cc_users where lower(email) = lower(:email) limit 1 - } -default ""] + }]} { + set user_id $party_id + ns_write "
account exists" + } else { + set user_id "" + } + } + + ns_write "
Name:$fname $lname" - + + # user_id is blank if the account doesn't exist or if the + # email account looks invalid. + if {[empty_string_p $user_id]} { # shall we create the new user? if {[string is true $create_new_users_p]} { if {[util_email_valid_p $email]} { - ns_write "creating new user: $fname, $lname ($email)
" + ns_write "creating new user: $fname $lname ($email)
" # create new user - set user_exists_p [db_0or1row user_id "select party_id from parties where email = lower(:email)"] + set user_exists_p [db_0or1row user_id "select party_id from parties where email = lower(:email) limit 1"] if {[string is false $user_exists_p]} { set password [ad_generate_random_string] @@ -89,10 +105,10 @@ set user_id $auth_status_array(user_id) } } else { - ns_write "invalid email address: $fname, $lname ($email)
" + ns_write "
invalid email address: $email" } } else { - ns_write "skipping user: $fname, $lname ($email)
" + ns_write "
skipping user (not creating): $fname $lname ($email)" } } @@ -103,9 +119,9 @@ set request_id [notification::request::get_request_id -type_id $type_id -object_id $forum_id -user_id $user_id] if {![empty_string_p $request_id]} { - ns_write "already subscribed ($fname, $lname ($email)
" + ns_write "
already subscribed ($fname $lname ($email)
" } else { - ns_write "subscribing ($fname, $lname ($email)
" + ns_write "subscribing ($fname $lname ($email)
" notification::request::new \ -type_id $type_id \ -user_id $user_id \