Index: openacs-4/packages/acs-subsite/www/members/user-batch-add-2.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/members/user-batch-add-2.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/acs-subsite/www/members/user-batch-add-2.tcl 21 Jan 2018 00:35:29 -0000 1.8
+++ openacs-4/packages/acs-subsite/www/members/user-batch-add-2.tcl 3 Sep 2024 15:37:34 -0000 1.9
@@ -14,7 +14,7 @@
subsite::assert_user_may_add_member
-# parse the notify_ids arguments
+# parse the notify_ids arguments
# ...
set exception_text ""
@@ -34,73 +34,73 @@
set email [string trim [lindex $row 0]]
set first_names [string trim [lindex $row 1]]
set last_name [string trim [lindex $row 2]]
-
+
if {![info exists email] || ![util_email_valid_p $email]} {
- append exception_text "
Couldn't find a valid email address in ($row).\n"
- continue
+ append exception_text "Couldn't find a valid email address in ($row).\n"
+ continue
} else {
- set user_exists_p [db_0or1row user_id {select party_id from parties where email = lower(:email)}]
-
- if {$user_exists_p > 0} {
+ set user_exists_p [db_0or1row user_id {select party_id from parties where email = lower(:email)}]
+ if {$user_exists_p > 0} {
+
# Add user to subsite as a member
-
+
group::add_member \
-group_id $group_id \
-user_id $party_id
-
- append exception_text " $email was already in the database.\n"
- continue
- }
+ append exception_text " $email was already in the database.\n"
+
+ continue
+ }
}
-
+
if {![info exists first_names] || $first_names eq ""} {
- append exception_text " No first name in ($row)\n"
- continue
+ append exception_text " No first name in ($row)\n"
+ continue
}
-
+
if {![info exists last_name] || $last_name eq ""} {
- append exception_text " No last name in ($row)\n"
- continue
+ append exception_text " No last name in ($row)\n"
+ continue
}
-
+
# We've checked everything.
-
+
set password [ad_generate_random_string]
-
+
array set auth_status_array [auth::create_user -email $email -first_names $first_names -last_name $last_name -password $password]
set user_id $auth_status_array(user_id)
-
+
append success_text "Created user $user_id for ($row)
"
# Add user to subsite as a member
-
+
group::add_member \
-group_id $group_id \
-user_id $user_id
-
+
# if anything goes wrong here, stop the whole process
if { !$user_id } {
- ad_return_error \
+ ad_return_error \
"Insert Failed" \
"We were unable to create a user record for ($row)."
- ad_script_abort
+ ad_script_abort
}
# send email
set key_list [list first_names last_name email password]
set value_list [list $first_names $last_name $email $password]
-
+
set sub_message $message
foreach key $key_list value $value_list {
- regsub -all "<$key>" $sub_message $value sub_message
+ regsub -all -- "<$key>" $sub_message $value sub_message
}
-
+
if {[catch {acs_mail_lite::send -send_immediately -to_addr $email -from_addr $from -subject $subject -body $sub_message} errmsg]} {
ad_return_error \
"Mail Failed" \