Index: openacs-4/packages/acs-subsite/lib/user-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/lib/user-new.tcl,v diff -u -N -r1.19.2.3 -r1.19.2.4 --- openacs-4/packages/acs-subsite/lib/user-new.tcl 25 May 2016 13:07:25 -0000 1.19.2.3 +++ openacs-4/packages/acs-subsite/lib/user-new.tcl 23 Apr 2017 20:36:14 -0000 1.19.2.4 @@ -1,30 +1,39 @@ -# Expects parameters: -# -# self_register_p - Is the form for users who self register (1) or -# for administrators who create other users (0)? -# next_url - Any url to redirect to after the form has been submitted. The -# variables user_id, password, and account_messages will be added to the URL. Optional. -# email - Prepopulate the register form with given email. Optional. -# return_url - URL to redirect to after creation, will not get any query vars added -# rel_group_id - The name of a group which you want to relate this user to after creating the user. -# Will add an element to the form where the user can pick a relation among the permissible -# rel-types for the group. +ad_include_contract { + ADP include for adding new users -# Check if user can self register -auth::self_registration + Expects parameters: + + @param self_register_p Is the form for users who self register (1) or + for administrators who create oher users (0)? + + @param next_url Any url to redirect to after the form has been + submitted. The variables user_id, + password, and account_messages will be + added to the URL. Optional. -# Set default parameter values -array set parameter_defaults { - self_register_p 1 - next_url {} - return_url {} + @email Prepopulate the register form with given email. + Optional. + + @return_url URL to redirect to after creation, will not get any + query vars added + + @rel_group_id The name of a group which you want to relate this + user to after creating the user. Will add + an element to the form where the user can + pick a relation among the permissible + rel-types for the group. Can be empty. + +} { + {self_register_p:boolean 1} + {next_url ""} + {email ""} + {return_url ""} + {rel_group_id:integer ""} } -foreach parameter [array names parameter_defaults] { - if { (![info exists $parameter] || $parameter eq "") } { - set $parameter $parameter_defaults($parameter) - } -} +# Check if user can self register +auth::self_registration + # Redirect to HTTPS if so configured if { [security::RestrictLoginToSSLP] } { security::require_secure_conn @@ -59,7 +68,7 @@ } } -if { [info exists rel_group_id] && $rel_group_id ne "" } { +if { $rel_group_id ne "" } { ad_form -extend -name register -form { {rel_group_id:integer(hidden),optional} } @@ -100,7 +109,7 @@ -secret_question $secret_question \ -secret_answer $secret_answer] - if { $creation_info(creation_status) eq "ok" && ([info exists rel_group_id] && $rel_group_id ne "") } { + if { $creation_info(creation_status) eq "ok" && $rel_group_id ne "" } { group::add_member \ -group_id $rel_group_id \ -user_id $user_id \ @@ -167,7 +176,7 @@ # User is registered and logged in - if { ![info exists return_url] || $return_url eq "" } { + if { $return_url eq "" } { # Redirect to subsite home page. set return_url [subsite::get_element -element url] } @@ -190,7 +199,9 @@ if { $creation_info(account_message) ne "" && $self_register_p } { # Only do this if user is self-registering # as opposed to creating an account for someone else - ad_returnredirect [export_vars -base "[subsite::get_element -element url]register/account-message" { { message $creation_info(account_message) } return_url }] + ad_returnredirect [export_vars -base "[subsite::get_element -element url]register/account-message" { + { message $creation_info(account_message) } return_url + }] ad_script_abort } else { # No messages