+ #acs-subsite.Notice# #acs-subsite.Elements_not_editable#
+
\ No newline at end of file
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/lib/user-info.tcl 2 Jun 2005 06:39:41 -0000 1.1
@@ -0,0 +1,247 @@
+#
+# Expects:
+# user_id:optional
+# return_url:optional
+# edit_p:optional
+# message:optional
+#
+
+if { ! [empty_string_p $cancel] } {
+ ad_returnredirect $return_url
+ ad_script_abort
+}
+
+auth::require_login -account_status closed
+
+if { ![exists_and_not_null user_id] } {
+ set user_id [ad_conn untrusted_user_id]
+} elseif { $user_id != [auth::get_user_id -account_status closed] } {
+ permission::require_permission -object_id $user_id -privilege admin
+}
+
+if { ![exists_and_not_null return_url] } {
+ set return_url [ad_conn url]
+}
+
+
+set action_url "[subsite::get_element -element url]user/basic-info-update"
+
+acs_user::get -user_id $user_id -array user -include_bio
+
+set authority_name [auth::authority::get_element -authority_id $user(authority_id) -element pretty_name]
+
+set form_elms { authority_id username first_names last_name email screen_name url bio }
+foreach elm $form_elms {
+ set elm_mode($elm) {}
+}
+set read_only_elements [auth::sync::get_sync_elements -authority_id $user(authority_id)]
+set read_only_notice_p [expr [llength $read_only_elements] > 0]
+if { ![acs_user::site_wide_admin_p] } {
+ lappend read_only_elements authority_id username
+}
+foreach elm $read_only_elements {
+ set elm_mode($elm) {display}
+}
+set first_element {}
+foreach elm $form_elms {
+ if { [empty_string_p $elm_mode($elm)] && (![string equal $elm "username"] && [auth::UseEmailForLoginP]) } {
+ set first_element $elm
+ break
+ }
+}
+set focus "user_info.$first_element"
+set edit_mode_p [expr ![empty_string_p [form::get_action user_info]]]
+
+set form_mode display
+if { [exists_and_equal edit_p 1] } {
+ set form_mode edit
+}
+
+ad_form -name user_info -cancel_url $return_url -mode $form_mode -export {section_id community_id} -form {
+ {user_id:integer(hidden),optional}
+ {return_url:text(hidden),optional}
+ {message:text(hidden),optional}
+}
+
+if { [llength [auth::authority::get_authority_options]] > 1 } {
+ ad_form -extend -name user_info -form {
+ {authority_id:text(select)
+ {mode $elm_mode(authority_id)}
+ {label "[_ acs-subsite.Authority]"}
+ {options {[auth::authority::get_authority_options]}}
+ }
+ }
+}
+if { $user(authority_id) != [auth::authority::local] || ![auth::UseEmailForLoginP] || \
+ ([acs_user::site_wide_admin_p] && [llength [auth::authority::get_authority_options]] > 1) } {
+ ad_form -extend -name user_info -form {
+ {username:text(text)
+ {label "[_ acs-subsite.Username]"}
+ {mode $elm_mode(username)}
+ }
+ }
+}
+
+# TODO: Use get_registration_form_elements, or auto-generate the form somehow? Deferred.
+
+
+ad_form -extend -name user_info -form {
+ {first_names:text
+ {label "[_ acs-subsite.First_names]"}
+ {html {size 50}}
+ {mode $elm_mode(first_names)}
+ }
+ {last_name:text
+ {label "[_ acs-subsite.Last_name]"}
+ {html {size 50}}
+ {mode $elm_mode(last_name)}
+ }
+ {email:text
+ {label "[_ acs-subsite.Email]"}
+ {html {size 50}}
+ {mode $elm_mode(email)}
+ }
+}
+
+if {[apm_package_enabled_p "categories"]} {
+ set main_site_id [subsite::main_site_id]
+ if {![empty_string_p [category_tree::get_mapped_trees $main_site_id]]} {
+ category::ad_form::add_widgets -container_object_id $main_site_id -categorized_object_id $user_id -form_name user_info
+ }
+}
+
+if { ![string equal [acs_user::ScreenName] "none"] } {
+ ad_form -extend -name user_info -form \
+ [list \
+ [list screen_name:text[ad_decode [acs_user::ScreenName] "solicit" ",optional" ""] \
+ {label "[_ acs-subsite.Screen_name]"} \
+ {html {size 50}} \
+ {mode $elm_mode(screen_name)} \
+ ]]
+}
+
+ad_form -extend -name user_info -form {
+ {url:text,optional
+ {label "[_ acs-subsite.Home_page]"}
+ {html {size 50}}
+ {mode $elm_mode(url)}
+ }
+ {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,optional
+ {label "Grade"}
+ {html {size 10}}
+ }
+
+ {allergies:text,optional
+ {label "Allergies"}
+ {html {size 40}}
+ }
+
+ {age:integer,optional
+ {label "Age"}
+ {html {size 10}}
+ }
+
+ {add:text(submit) {label "Update Participant"}}
+ {addpatron:text(submit) {label "Update Participant and Select Patron"}}
+ {cancel:text(submit) {label "Cancel"}}
+} -on_request {
+ foreach var { authority_id first_names last_name email username screen_name url bio } {
+ set $var $user($var)
+ }
+ db_0or1row person_info {
+ select *
+ from person_info
+ where person_id = :user_id
+ }
+} -on_submit {
+ set user_info(authority_id) $user(authority_id)
+ set user_info(username) $user(username)
+ foreach elm $form_elms {
+ if { [empty_string_p $elm_mode($elm)] && [info exists $elm] } {
+ set user_info($elm) [string trim [set $elm]]
+ }
+ }
+
+ array set result [auth::update_local_account \
+ -authority_id $user(authority_id) \
+ -username $user(username) \
+ -array user_info]
+
+
+ # Handle authentication problems
+ switch $result(update_status) {
+ ok {
+ # Continue below
+ }
+ default {
+ # Adding the error to the first element, but only if there are no element messages
+ if { [llength $result(element_messages)] == 0 } {
+ form set_error user_info $first_element $result(update_message)
+ }
+
+ # Element messages
+ foreach { elm_name elm_error } $result(element_messages) {
+ form set_error user_info $elm_name $elm_error
+ }
+ break
+ }
+ }
+
+ if {[apm_package_enabled_p "categories"]} {
+ category::map_object -object_id $user_id [category::ad_form::get_categories -container_object_id $main_site_id]
+ }
+
+ # Roel: Extra info for students
+ if { [db_0or1row person_info {
+ select 1
+ from person_info
+ where person_id = :user_id
+ }] } {
+ db_dml update_extra_info {
+ update person_info
+ set grade = :grade,
+ allergies = :allergies,
+ age = :age
+ where person_id = :user_id
+ }
+ } else {
+ db_dml insert_extra_info {
+ insert into person_info (person_id, grade, allergies, age)
+ values (:user_id, :grade, :allergies, :age)
+ }
+ }
+
+ dotlrn::user_add -user_id $user_id
+} -after_submit {
+ if { [string equal [ad_conn account_status] "closed"] } {
+ auth::verify_account_status
+ }
+
+ if { ! [empty_string_p [template::element get_value user_info add]] } {
+ ad_returnredirect $add_url
+ } elseif { ! [empty_string_p [template::element get_value user_info addpatron]] } {
+ ad_returnredirect $addpatron_url
+ } else {
+ ad_returnredirect $return_url
+ }
+ ad_script_abort
+}
+
+# LARS HACK: Make the URL and email elements real links
+if { ![form is_valid user_info] } {
+ element set_properties user_info email -display_value "