Index: openacs-4/packages/dotlrn-ecommerce/www/admin/course-add-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/course-add-edit.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/dotlrn-ecommerce/www/admin/course-add-edit.tcl 13 Sep 2005 11:12:26 -0000 1.10 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/course-add-edit.tcl 20 Sep 2005 17:38:29 -0000 1.11 @@ -69,6 +69,7 @@ set aditional_type "" set aditional_elements "" set help_text "" + switch [lindex $attribute 4] { string { if { [string equal [lindex $attribute 2] "assessment_id"]} { @@ -93,6 +94,10 @@ set help_text [list help_text "[_ dotlrn-ecommerce.as_widget_help]"] } } + boolean { + set aditional_type "(radio)" + set aditional_elements [list options {{Yes t} {No f}}] + } } if { $count > 3 } { append aditional_type ",optional" @@ -226,11 +231,13 @@ set page_title "[_ dotlrn-catalog.new_course]" set revision_id "-1" set display_p t + set auto_register_p f } -edit_request { set context [list [list course-list "[_ dotlrn-catalog.course_list]"] "[_ dotlrn-catalog.edit_course]"] set page_title "[_ dotlrn-catalog.edit_course]" db_1row get_course_info { } db_string get_course_assessment { } -default "[_ dotlrn-catalog.not_associated]" + set auto_register_p [ad_decode $auto_register_p "" f $auto_register_p] } -after_submit { if { $return_url == "" } { # set return_url [export_vars -base course-info {course_id course_name course_key} ] Index: openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.tcl 16 Jul 2005 12:51:06 -0000 1.6 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/course-attribute-add.tcl 20 Sep 2005 17:38:29 -0000 1.7 @@ -26,10 +26,11 @@ {widget:text(select) {label "Widget"} {options { {"String (textfield)" string} \ {"Text (textbox)" text} \ - {Integer integer} + {Integer integer} \ + {Boolean boolean} }}} } -on_submit { - array set spec [list string text text text integer integer] + array set spec [list string text text text integer integer boolean boolean] content::type::attribute::new \ -content_type "dotlrn_catalog" \ Index: openacs-4/packages/dotlrn-ecommerce/www/admin/course-attributes.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/admin/course-attributes.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/dotlrn-ecommerce/www/admin/course-attributes.tcl 16 Jul 2005 12:51:06 -0000 1.6 +++ openacs-4/packages/dotlrn-ecommerce/www/admin/course-attributes.tcl 20 Sep 2005 17:38:28 -0000 1.7 @@ -17,8 +17,6 @@ set attribute_list [package_object_attribute_list -start_with dotlrn_catalog dotlrn_catalog] -ns_log notice "DEBUG:: ATTRIBUTES:: $attribute_list" - template::multirow create attributes attribute_id name title sort_order widget set count 1 Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl,v diff -u -r1.22 -r1.23 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl 13 Sep 2005 03:08:08 -0000 1.22 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/application-request.tcl 20 Sep 2005 17:38:28 -0000 1.23 @@ -36,6 +36,7 @@ switch $type { full { set member_state "needs approval" + set assessment_id "" } prereq { set member_state "request approval" @@ -63,76 +64,76 @@ $participant_id \ ]} errmsg]} { ad_return_complaint "There was a problem with your request" $errmsg -} else { - switch -- $member_state { - "awaiting payment" { - dotlrn_community::send_member_email -community_id $community_id -to_user $email_user_id -type "awaiting payment" - } - "needs approval" - - "request approval" { - set mail_from [parameter::get -package_id [ad_acs_kernel_id] -parameter OutgoingSender] - set community_name [dotlrn_community::get_community_name $community_id] + ad_script_abort +} - if { [parameter::get -package_id [ad_conn package_id] -parameter NotifyApplicantOnRequest] } { - dotlrn_community::send_member_email -community_id $community_id -to_user $email_user_id -type $member_state +switch -- $member_state { + "awaiting payment" { + dotlrn_community::send_member_email -community_id $community_id -to_user $email_user_id -type "awaiting payment" + } + "needs approval" - + "request approval" { + set mail_from [parameter::get -package_id [ad_acs_kernel_id] -parameter OutgoingSender] + set community_name [dotlrn_community::get_community_name $community_id] - } - } + if { [parameter::get -package_id [ad_conn package_id] -parameter NotifyApplicantOnRequest] } { + dotlrn_community::send_member_email -community_id $community_id -to_user $email_user_id -type $member_state + + } } - ns_log notice "DEBUG:: RELATION $participant_id, $community_id, $rel_id" - set wait_list_notify_email [parameter::get -package_id [ad_acs_kernel_id] -parameter AdminOwner] - set mail_from [parameter::get -package_id [ad_acs_kernel_id] -parameter OutgoingSender] +} +ns_log notice "DEBUG:: RELATION $participant_id, $community_id, $rel_id" +set wait_list_notify_email [parameter::get -package_id [ad_acs_kernel_id] -parameter AdminOwner] +set mail_from [parameter::get -package_id [ad_acs_kernel_id] -parameter OutgoingSender] - ns_log notice "application-request: wait list notify: potential community is $community_id" - if {[db_0or1row get_nwn { - select s.notify_waiting_number, - s.section_name - from dotlrn_ecommerce_section s - where s.community_id = :community_id - }]} { - if {![empty_string_p $notify_waiting_number]} { - set current_waitlisted [db_string get_cw { - select count(*) - from membership_rels m, - acs_rels r - where m.member_state in ('needs approval', 'awaiting payment') - and m.rel_id = r.rel_id - and r.rel_type = 'dotlrn_member_rel' - and r.object_id_one = :community_id - }] - ns_log notice "application-request: wait list notify: community $community_id wait number is $notify_waiting_number" - ns_log notice "application-request: wait list notify: community $community_id waitlisteed is $current_waitlisted" - if {$current_waitlisted >= $notify_waiting_number} { - set subject "Waitlist notification for $section_name" - set body "$section_name is set to notify when the waitlist reaches ${notify_waiting_number}. +ns_log notice "application-request: wait list notify: potential community is $community_id" +if {[db_0or1row get_nwn { + select s.notify_waiting_number, + s.section_name + from dotlrn_ecommerce_section s + where s.community_id = :community_id +}]} { + if {![empty_string_p $notify_waiting_number]} { + set current_waitlisted [db_string get_cw { + select count(*) + from membership_rels m, + acs_rels r + where m.member_state in ('needs approval', 'awaiting payment') + and m.rel_id = r.rel_id + and r.rel_type = 'dotlrn_member_rel' + and r.object_id_one = :community_id + }] + ns_log notice "application-request: wait list notify: community $community_id wait number is $notify_waiting_number" + ns_log notice "application-request: wait list notify: community $community_id waitlisteed is $current_waitlisted" + if {$current_waitlisted >= $notify_waiting_number} { + set subject "Waitlist notification for $section_name" + set body "$section_name is set to notify when the waitlist reaches ${notify_waiting_number}. Total persons in the waiting list for ${section_name}: $current_waitlisted" - acs_mail_lite::send \ - -to_addr $wait_list_notify_email \ - -from_addr $mail_from \ - -subject $subject \ - -body $body - ns_log notice "application-request: wait list notify: community $community_id sending email" - } else { - ns_log notice "application-request: wait list notify: community $community_id NOT sending email" - } + acs_mail_lite::send \ + -to_addr $wait_list_notify_email \ + -from_addr $mail_from \ + -subject $subject \ + -body $body + ns_log notice "application-request: wait list notify: community $community_id sending email" + } else { + ns_log notice "application-request: wait list notify: community $community_id NOT sending email" } } +} - # Set the rel_id's creation user to the purchaser - if { [info exists user_id] && $user_id != [ad_conn user_id] } { - db_dml set_purchaser { - update acs_objects - set creation_user = :user_id - where object_id = :rel_id - } +# Set the rel_id's creation user to the purchaser +if { [info exists user_id] && $user_id != [ad_conn user_id] } { + db_dml set_purchaser { + update acs_objects + set creation_user = :user_id + where object_id = :rel_id } } dotlrn_ecommerce::section::flush_cache -user_id $participant_id $section_id if { [empty_string_p $assessment_id] || $assessment_id == -1 || $type == "full" } { ad_returnredirect $next_url - ad_script_abort } else { # Start a new session as::assessment::data -assessment_id $assessment_id @@ -162,3 +163,5 @@ set return_url [export_vars -base "[ad_conn package_url]ecommerce/application-request-2" { user_id {return_url $next_url} }] ad_returnredirect [export_vars -base "[apm_package_url_from_id [parameter::get -parameter AssessmentPackage]]assessment" { assessment_id return_url session_id }] } + +ad_script_abort Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl,v diff -u -r1.23 -r1.24 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 19 Sep 2005 22:11:38 -0000 1.23 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 20 Sep 2005 17:38:28 -0000 1.24 @@ -36,7 +36,8 @@ {participant_id:integer 0} {override_p 0} - + {override_course_application_p 0} + offer_code:optional return_url:notnull,optional } @@ -109,27 +110,36 @@ $member_state != "payment received" && ($override_p == 0 || $admin_p == 0) } { - + # Check application assessment - if { [db_0or1row get_assessment { - select c.assessment_id - - from dotlrn_ecommerce_section s, - dotlrn_catalogi c, - cr_items i - - where s.course_id = c.item_id - and c.item_id = i.item_id - and i.live_revision = c.course_id - and s.product_id = :product_id - - limit 1 - }] } { - if { ! [empty_string_p $assessment_id] && $assessment_id != -1 } { - set return_url [export_vars -base "[ad_conn package_url]application-confirm" { product_id {member_state "awaiting payment"} }] - ad_returnredirect [export_vars -base application-request { user_id participant_id community_id {next_url $return_url} { type payment } }] - ad_script_abort + if { ! $override_course_application_p } { + if { [db_0or1row get_assessment { + select c.assessment_id, c.auto_register_p + from dotlrn_ecommerce_section s, + dotlrn_catalogi c, + cr_items i + + where s.course_id = c.item_id + and c.item_id = i.item_id + and i.live_revision = c.course_id + and s.product_id = :product_id + + limit 1 + }] } { + if { ! [empty_string_p $assessment_id] && $assessment_id != -1 } { + if { $auto_register_p == "t" } { + set form [rp_getform] + ns_set delkey $form override_course_application_p + + set return_url [export_vars -base [ad_return_url] { {override_course_application_p 1} }] + ad_returnredirect [export_vars -base "[apm_package_url_from_id [parameter::get -parameter AssessmentPackage]]assessment" { assessment_id return_url }] + } else { + set return_url [export_vars -base "[ad_conn package_url]application-confirm" { product_id {member_state "awaiting payment"} }] + ad_returnredirect [export_vars -base application-request { user_id participant_id community_id {next_url $return_url} { type payment } }] + } + ad_script_abort + } } } @@ -218,46 +228,46 @@ if { $price < 0.01 } { dotlrn_community::add_user $community_id $participant_id - } - # Adding these for correctness, taken from the after-checkout - # callback + # Adding these for correctness, taken from the after-checkout + # callback - if { [lsearch [parameter::get -parameter WelcomeEmailRecipients] purchaser] != -1 } { - if {$user_id != $participant_id} { - # if they are the participant, then - # they will get the welcome email for the community - dotlrn_community::send_member_email -community_id $community_id -to_user $participant_id -type "on join" -email_send_to $user_id -override_enabled + if { [lsearch [parameter::get -parameter WelcomeEmailRecipients] purchaser] != -1 } { + if {$user_id != $participant_id} { + # if they are the participant, then + # they will get the welcome email for the community + dotlrn_community::send_member_email -community_id $community_id -to_user $participant_id -type "on join" -email_send_to $user_id -override_enabled + } } - } - - if { [db_0or1row member_rel { - select rel_id - from dotlrn_member_rels_full - where community_id = :community_id - and user_id = :participant_id - limit 1 - }] } { - set patron_rel_id [db_exec_plsql relate_patron { - select acs_rel__new (null, - 'membership_patron_rel', - :rel_id, - :user_id, - null, - null, - null) - }] - } + + if { [db_0or1row member_rel { + select rel_id + from dotlrn_member_rels_full + where community_id = :community_id + and user_id = :participant_id + limit 1 + }] } { + set patron_rel_id [db_exec_plsql relate_patron { + select acs_rel__new (null, + 'membership_patron_rel', + :rel_id, + :user_id, + null, + null, + null) + }] + } - # Flush cache - dotlrn_ecommerce::section::flush_cache $section_id + # Flush cache + dotlrn_ecommerce::section::flush_cache $section_id - if { [exists_and_not_null return_url] } { - ad_returnredirect $return_url - } else { - ad_returnredirect [ad_conn package_url] + if { [exists_and_not_null return_url] } { + ad_returnredirect $return_url + } else { + ad_returnredirect [ad_conn package_url] + } + ad_script_abort } - ad_script_abort } # added default values to above params so that this page works