Index: openacs-4/packages/acs-admin/www/users/user-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/www/users/user-add-2.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-admin/www/users/user-add-2.tcl 6 Sep 2002 21:49:53 -0000 1.6 +++ openacs-4/packages/acs-admin/www/users/user-add-2.tcl 26 Sep 2003 13:04:18 -0000 1.7 @@ -3,11 +3,7 @@ @cvs-id $Id$ } -query { user_id - email - first_names - last_name password - password_confirmation {referer "/acs-admin/users"} } -properties { context:onevalue @@ -23,83 +19,17 @@ set admin_user_id [ad_verify_and_get_user_id] -# email first_names last_name, user_id - -# Error Count and List -set exception_count 0 -set exception_text "" - -# Check input - -if {![info exists user_id] || [empty_string_p $user_id] } { - incr exception_count - append exception_text "
  • Your browser dropped the user_id variable or something is wrong with our code.\n" +# Get user info +acs_user::get -user_id $user_id -array user +# easier to work with scalar vars than array +foreach var_name [array names user] { + set $var_name $user($var_name) } - - -if {![info exists email] || ![util_email_valid_p $email]} { - incr exception_count - append exception_text "
  • The email address that you typed doesn't look right to us. Examples of valid email addresses are - -" -} else { - set email_count [db_string unused "select count(email) -from parties where email = lower(:email) -and party_id <> :user_id"] - - # note, we dont' produce an error if this is a double click - if {$email_count > 0} { - incr exception_count - append exception_text "
  • $email was already in the database." - } - -} - -if {![info exists first_names] || [empty_string_p $first_names]} { - incr exception_count - append exception_text "
  • You didn't enter a first name." -} - -if {![info exists last_name] || [empty_string_p $last_name]} { - incr exception_count - append exception_text "
  • You didn't enter a last name." -} - -if { ![string equal $password $password_confirmation] } { - incr exception_count - append exception_text "
  • The two passwords didn't match." -} - -# We've checked everything. -# If we have an error, return error page, otherwise, do the insert - -if {$exception_count > 0} { - ad_return_complaint $exception_count $exception_text - return -} - if { [empty_string_p $password] } { set password [ad_generate_random_string] } -if { [db_string double_click {}] != 0 } { - # This was a double-click. Ignore. -} else { - set user_id [ad_user_new $email $first_names $last_name $password "" "" "" "t" "approved" $user_id] - - if { !$user_id } { - # not a double click, and it failed - ad_return_error "Insert Failed" "We were unable to create your user record in the database." - ad_script_abort - } -} - - set administration_name [db_string admin_name "select first_names || ' ' || last_name from persons where person_id = :admin_user_id"]