Index: openacs-4/packages/dotlrn-ecommerce/lib/user-info.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/user-info.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/dotlrn-ecommerce/lib/user-info.tcl 23 Jul 2005 13:30:02 -0000 1.6 +++ openacs-4/packages/dotlrn-ecommerce/lib/user-info.tcl 28 Jul 2005 23:43:43 -0000 1.7 @@ -1,10 +1,6 @@ -# -# Expects: -# user_id:optional -# return_url:optional -# edit_p:optional -# message:optional -# +if { ![exists_and_not_null user_type] } { + set user_type participant +} if { ! [empty_string_p $cancel] } { ad_returnredirect $return_url @@ -122,44 +118,54 @@ # ]] # } -set tree_id [parameter::get -package_id [ad_conn package_id] -parameter GradeCategoryTree -default 0] -set grade_options [list {}] -foreach tree [category_tree::get_tree $tree_id] { - lappend grade_options [list [lindex $tree 1] [lindex $tree 0]] -} - -# {url:text,optional -# {label "[_ acs-subsite.Home_page]"} -# {html {size 50}} -# {mode $elm_mode(url)} -# } - ad_form -extend -name user_info -export { section_id add_url } -form { {bio:text(textarea),optional {label "[_ acs-subsite.About_You]"} {html {rows 8 cols 60}} {mode $elm_mode(bio)} {display_value {[ad_text_to_html -- $user(bio)]}} } - - {grade:text(select),optional - {label "[_ dotlrn-ecommerce.Grade]"} - {options {$grade_options}} - } +} - {allergies:text,optional - {label "[_ dotlrn-ecommerce.Medical_Issues]"} - {html {size 60}} +if { $user_type == "participant" } { + set tree_id [parameter::get -package_id [ad_conn package_id] -parameter GradeCategoryTree -default 0] + set grade_options [list {}] + foreach tree [category_tree::get_tree $tree_id] { + lappend grade_options [list [lindex $tree 1] [lindex $tree 0]] } - {special_needs:text,optional - {label "[_ dotlrn-ecommerce.Special_Needs]"} - {html {size 60}} + ad_form -extend -name user_info -form { + {grade:text(select),optional + {label "[_ dotlrn-ecommerce.Grade]"} + {options {$grade_options}} + } + + {allergies:text,optional + {label "[_ dotlrn-ecommerce.Medical_Issues]"} + {html {size 60}} + } + + {special_needs:text,optional + {label "[_ dotlrn-ecommerce.Special_Needs]"} + {html {size 60}} + } } +} else { + ad_form -extend -name register -form { + {grade:text(hidden) {value ""}} + {allergies:text(hidden) {value ""}} + {special_needs:text(hidden) {value ""}} + } +} + +if { [exists_and_equal edit_p 1] } { + ad_form -extend -name user_info -form { + {add:text(submit) {label "[_ dotlrn-ecommerce.Proceed]"}} + {cancel:text(submit) {label "[_ dotlrn-ecommerce.Cancel]"}} + } +} - {add:text(submit) {label "[_ dotlrn-ecommerce.Proceed]"}} - {cancel:text(submit) {label "[_ dotlrn-ecommerce.Cancel]"}} -} -on_request { +ad_form -extend -name user_info -form {} -on_request { foreach var { authority_id first_names last_name email username bio } { set $var $user($var) } @@ -235,11 +241,7 @@ auth::verify_account_status } - if { ! [empty_string_p [template::element get_value user_info add]] } { - ad_returnredirect $add_url - } else { - ad_returnredirect $return_url - } + ad_returnredirect $add_url ad_script_abort } Index: openacs-4/packages/dotlrn-ecommerce/lib/user-new.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/user-new.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/dotlrn-ecommerce/lib/user-new.adp 2 Jun 2005 06:39:41 -0000 1.1 +++ openacs-4/packages/dotlrn-ecommerce/lib/user-new.adp 28 Jul 2005 23:43:43 -0000 1.2 @@ -1 +1,11 @@ - \ No newline at end of file + + + + + \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl 23 Jul 2005 13:30:02 -0000 1.7 +++ openacs-4/packages/dotlrn-ecommerce/lib/user-new.tcl 28 Jul 2005 23:43:43 -0000 1.8 @@ -14,12 +14,12 @@ auth::self_registration # Set default parameter values +# user_type - participant or purchaser for now array set parameter_defaults { self_register_p 1 next_url {} return_url {} - add_url {} - addpatron_url {} + user_type participant } foreach parameter [array names parameter_defaults] { if { ![exists_and_not_null $parameter] } { @@ -51,10 +51,36 @@ set user_id [db_nextval acs_object_id_seq] set form [auth::get_registration_form_elements] +# Roel - remove password, url fields improve this set form [lrange $form 0 3] +set formlen [llength $form] -ad_form -name register -export {next_url user_id return_url add_url addpatron_url {password ""} {password_confirm ""} {screen_name ""} {url ""} {secret_question ""} {secret_answer ""} } -form $form +set allow_no_email_p [parameter::get -parameter AllowNoEmailForPurchaser] +set validate [list] +if { $user_type == "purchaser" && $allow_no_email_p } { + for { set i 0 } { $i < $formlen } { incr i } { + set field [lindex $form $i] + if { [lindex $field 0] == "email:text(text)" } { + set field [lreplace $field 0 0 "email:text(text),optional"] + set form [lreplace $form $i $i $field] + } + } + + set form [linsert $form 1 {no_email_p:integer(checkbox),optional + {label ""} + {options {{"[_ dotlrn-ecommerce.User_has_no_email]" 1}}} + {html {onchange "this.form.email.disabled = ! this.form.email.disabled;"}} + }] + + lappend validate {email + { ![empty_string_p $email] || [template::element::get_value register no_email_p] == 1 } + "[_ dotlrn-ecommerce.Email_is_required]" + } +} + +ad_form -name register -export {next_url user_id return_url {password ""} {password_confirm ""} {screen_name ""} {url ""} {secret_question ""} {secret_answer ""} } -form $form + if { [exists_and_not_null rel_group_id] } { ad_form -extend -name register -form { {rel_group_id:integer(hidden),optional} @@ -77,57 +103,86 @@ } # Roel: Extra info for students -set tree_id [parameter::get -package_id [ad_conn package_id] -parameter GradeCategoryTree -default 0] -set grade_options [list {}] -foreach tree [category_tree::get_tree $tree_id] { - lappend grade_options [list [lindex $tree 1] [lindex $tree 0]] -} +if { $user_type == "participant" } { -if { [llength $grade_options] > 0 } { + set tree_id [parameter::get -package_id [ad_conn package_id] -parameter GradeCategoryTree -default 0] + set grade_options [list {}] + foreach tree [category_tree::get_tree $tree_id] { + lappend grade_options [list [lindex $tree 1] [lindex $tree 0]] + } + + if { [llength $grade_options] > 0 } { + ad_form -extend -name register -form { + {grade:text(select) + {label "[_ dotlrn-ecommerce.Grade]"} + {options {$grade_options}} + } + } + } else { + ad_form -extend -name register -form { + {grade:text(select),optional + {label "[_ dotlrn-ecommerce.Grade]"} + {options {$grade_options}} + } + } + } ad_form -extend -name register -form { - {grade:text(select) - {label "[_ dotlrn-ecommerce.Grade]"} - {options {$grade_options}} + {allergies:text,optional + {label "[_ dotlrn-ecommerce.Medical_Issues]"} + {html {size 60}} } + + {special_needs:text,optional + {label "[_ dotlrn-ecommerce.Special_Needs]"} + {html {size 60}} + } } + } else { ad_form -extend -name register -form { - {grade:text(select),optional - {label "[_ dotlrn-ecommerce.Grade]"} - {options {$grade_options}} - } + {grade:text(hidden) {value ""}} + {allergies:text(hidden) {value ""}} + {special_needs:text(hidden) {value ""}} } } -ad_form -extend -name register -form { - {allergies:text,optional - {label "[_ dotlrn-ecommerce.Medical_Issues]"} - {html {size 60}} - } - {special_needs:text,optional - {label "[_ dotlrn-ecommerce.Special_Needs]"} - {html {size 60}} +switch $user_type { + participant { + ad_form -extend -name register -form { + {add:text(submit) {label "[_ dotlrn-ecommerce.Add_Participant]"}} + } } - - {add:text(submit) {label "[_ dotlrn-ecommerce.Add_Participant]"}} + purchaser { + ad_form -extend -name register -form { + {add:text(submit) {label "[_ dotlrn-ecommerce.Add_Purchaser]"}} + } + } } -ad_form -extend -name register -on_request { +ad_form -extend -name register -validate $validate -on_request { # Populate elements from local variables - # Try to default to Adult, this may not exist - set locale [ad_conn locale] - db_0or1row default_grade { - select c.category_id as grade - from category_translations t, categories c - where t.category_id = c.category_id - and t.name = 'Adult' - and t.locale = :locale - and c.tree_id = :tree_id + if { $user_type == "participant" } { + # Try to default to Adult, this may not exist + set locale [ad_conn locale] + db_0or1row default_grade { + select c.category_id as grade + from category_translations t, categories c + where t.category_id = c.category_id + and t.name = 'Adult' + and t.locale = :locale + and c.tree_id = :tree_id + } } } -on_submit { db_transaction { + if { [empty_string_p $email] } { + # Generate an email address + set domain [parameter::get -parameter DefaultEmailDomain] + set email "noemail-[util_text_to_url "$first_names $last_name"]-$user_id@$domain" + } + array set creation_info [auth::create_user \ -user_id $user_id \ -verify_password_confirm \ @@ -199,14 +254,6 @@ } -after_submit { -# if { ! [empty_string_p [template::element get_value register add]] } { -# ad_returnredirect [export_vars -base $add_url { user_id }] -# ad_script_abort -# } elseif { ! [empty_string_p [template::element get_value register addpatron]] } { -# ad_returnredirect [export_vars -base $addpatron_url { user_id }] -# ad_script_abort -# } - if { ![empty_string_p $next_url] } { # Add user_id and account_message to the URL ad_returnredirect [export_vars -base $next_url {user_id password {account_message $creation_info(account_message)}}] Index: openacs-4/packages/dotlrn-ecommerce/www/home.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/home.adp,v diff -u -r1.5 -r1.6 --- openacs-4/packages/dotlrn-ecommerce/www/home.adp 21 Jul 2005 09:01:49 -0000 1.5 +++ openacs-4/packages/dotlrn-ecommerce/www/home.adp 28 Jul 2005 23:43:43 -0000 1.6 @@ -10,7 +10,7 @@

#acs-subsite.Basic_Information#

- +

#acs-subsite.lt_What_other_people_see#

Index: openacs-4/packages/dotlrn-ecommerce/www/home.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/home.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn-ecommerce/www/home.tcl 21 Jul 2005 09:01:49 -0000 1.3 +++ openacs-4/packages/dotlrn-ecommerce/www/home.tcl 28 Jul 2005 23:43:43 -0000 1.4 @@ -3,6 +3,8 @@ ad_page_contract { user's workspace page @cvs-id $Id$ +} { + {cancel ""} } -properties { system_name:onevalue context:onevalue @@ -44,8 +46,10 @@ set system_name [ad_system_name] -set portrait_upload_url [export_vars -base "../user/portrait/upload" { { return_url [ad_return_url] } }] +set return_url [ad_return_url] +set portrait_upload_url [export_vars -base "../user/portrait/upload" { return_url }] + if { [llength [lang::system::get_locales]] > 1 } { set change_locale_url [apm_package_url_from_key "acs-lang"] }