Index: openacs-4/packages/dotlrn-ecommerce/dotlrn-ecommerce.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/dotlrn-ecommerce.info,v diff -u -r1.36 -r1.37 --- openacs-4/packages/dotlrn-ecommerce/dotlrn-ecommerce.info 6 Sep 2005 14:59:26 -0000 1.36 +++ openacs-4/packages/dotlrn-ecommerce/dotlrn-ecommerce.info 14 Sep 2005 02:42:33 -0000 1.37 @@ -7,15 +7,15 @@ f t - + Roel Canicula Package to tie the dotLRN, Ecommerce, Assessments and dotLRN Catalog packages together 2005-08-10 Solution Grove Package to tie the dotLRN, Ecommerce, Assessments and dotLRN Catalog packages together. Initially intended for the MOS and MGH projects, the goal is to create a reusable module for similar projects. 0 - + @@ -60,6 +60,7 @@ + Index: openacs-4/packages/dotlrn-ecommerce/lib/section.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/section.tcl,v diff -u -r1.29 -r1.30 --- openacs-4/packages/dotlrn-ecommerce/lib/section.tcl 6 Sep 2005 02:46:15 -0000 1.29 +++ openacs-4/packages/dotlrn-ecommerce/lib/section.tcl 14 Sep 2005 02:42:33 -0000 1.30 @@ -116,7 +116,9 @@ # HAM : Let's check if we have MemberPriceP enabled and set # if it is, let's add Member Price text -if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] } { +if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] && + ! [parameter::get -parameter AllowFreeRegistration -default 0] + } { ad_form -extend -name add_section -form { { member_price:currency,to_sql(sql_number) {label "Member Price"} {html {size 6}} } } @@ -347,12 +349,18 @@ lappend validate {price { ![template::util::negative [template::util::currency::get_property whole_part $price]] } "Price can not be negative" -} {price - { !"[template::util::currency::get_property whole_part $price].[template::util::currency::get_property fractional_part $price]" == "0.00" } - "Price can not be zero" +} + +if { ! [parameter::get -parameter AllowFreeRegistration -default 0] } { + lappend validate {price + { !"[template::util::currency::get_property whole_part $price].[template::util::currency::get_property fractional_part $price]" == "0.00" } + "Price can not be zero" + } } -if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0] } { +if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0] && + ! [parameter::get -parameter AllowFreeRegistration -default 0] + } { lappend validate {member_price { ![template::util::negative [template::util::currency::get_property whole_part $member_price]] } "Member Price can not be negative" @@ -426,7 +434,9 @@ where community_id = :assistant_community_id) }] - if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] } { + if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] && + ! [parameter::get -parameter AllowFreeRegistration -default 0] + } { if { [db_0or1row member_price { }] } { # HAM # member_price is using currency_widget @@ -545,7 +555,7 @@ #HAM: create a sale item from the member price # do so only if member price is provided # and MemberPriceP is 1 - if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] && [exists_and_not_null member_price] && $member_price != 0.00} { + if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] && [exists_and_not_null member_price] && $member_price != 0.00 && ! [parameter::get -parameter AllowFreeRegistration -default 0] } { # HAM : FIXME @@ -739,7 +749,7 @@ } # Set member price, this can be 1 to n but ignore for now - if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] && [exists_and_not_null member_price]} { + if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] && [exists_and_not_null member_price] && ! [parameter::get -parameter AllowFreeRegistration -default 0] } { if { [db_0or1row sale_price { }] } { db_dml set_member_price { } } else { Index: openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl,v diff -u -r1.55 -r1.56 --- openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 8 Sep 2005 09:17:11 -0000 1.55 +++ openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 14 Sep 2005 02:42:33 -0000 1.56 @@ -23,6 +23,8 @@ set filters {} +set allow_free_registration_p [parameter::get -parameter AllowFreeRegistration -default 0] + # Generate filters based on categories # set filters { # uncat_f { @@ -255,7 +257,7 @@ -name course_list \ -multirow course_list \ -key course_id \ - -pass_properties { admin_p allow_other_registration_p offer_code_p } \ + -pass_properties { admin_p allow_other_registration_p offer_code_p allow_free_registration_p } \ -actions $actions \ -filters $filters \ -bulk_action_method post \ @@ -301,7 +303,7 @@
@course_list.sessions;noquote@

@course_list.section_zones;noquote@

@course_list.instructor_names;noquote@
-
@course_list.prices;noquote@
+
Free Registration@course_list.prices;noquote@

@course_list.attendees;noquote@ participants ,
@course_list.available_slots;noquote@ available
@@ -750,4 +752,4 @@ set fs_chunk [util_memoize [list dotlrn_ecommerce::section::fs_chunk $section_id] $memoize_max_age] set description [ad_text_to_html $description] -} +} \ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/applications.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/applications.tcl,v diff -u -r1.35 -r1.36 --- openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 7 Sep 2005 21:38:29 -0000 1.35 +++ openacs-4/packages/dotlrn-ecommerce/www/applications.tcl 14 Sep 2005 02:42:33 -0000 1.36 @@ -36,6 +36,8 @@ set enable_applications_p [parameter::get -package_id [ad_conn package_id] -parameter EnableCourseApplicationsP -default 1] +set allow_free_registration_p [parameter::get -parameter AllowFreeRegistration -default 0] + if { [exists_and_not_null type] } { set _type $type } else { @@ -174,7 +176,6 @@ html { width 125 align center nowrap } } - template::list::create \ -name "applications" \ -key rel_id \ @@ -251,7 +252,7 @@ and rr.rel_id <= r.rel_id and rr.community_id = r.community_id and rr.member_state = r.member_state - order by o.creation_date) r) as number, s.product_id, m.session_id + order by o.creation_date) r) as number, s.product_id, m.session_id, p.price from dotlrn_member_rels_full r left join (select * @@ -265,7 +266,13 @@ where session_id in (select max(session_id) from dotlrn_ecommerce_application_assessment_map group by rel_id)) m - on (r.rel_id = m.rel_id), dotlrn_ecommerce_section s, dotlrn_catalogi t, cr_items i, acs_objects o + on (r.rel_id = m.rel_id), + dotlrn_ecommerce_section s + left join ec_products p + on (s.product_id = p.product_id), + dotlrn_catalogi t, + cr_items i, + acs_objects o where r.community_id = s.community_id and s.course_id = t.item_id @@ -281,7 +288,11 @@ }] { set list_type [ad_decode $member_state "needs approval" full "request approval" prereq "awaiting payment" payment full] - set approve_url [export_vars -base application-approve { community_id {user_id $applicant_user_id} {type $list_type} return_url }] + if { ![empty_string_p $price] && $price < 0.01 && $allow_free_registration_p } { + set approve_url [export_vars -base "[ad_conn package_url]ecommerce/shopping-cart-add" { product_id {user_id $patron_id} {participant_id $applicant_user_id} return_url {override_p 1} }] + } else { + set approve_url [export_vars -base application-approve { community_id {user_id $applicant_user_id} {type $list_type} return_url }] + } set reject_url [export_vars -base application-reject { community_id {user_id $applicant_user_id} {type $list_type} return_url }] ns_log Notice "***HAM : $member_state : $applicant_user_id : $community_id ***" if { $member_state == "needs approval" || @@ -368,7 +379,7 @@ set section_edit_url [export_vars -base admin/one-section { section_id return_url }] set person_url [export_vars -base /acs-admin/users/one { {user_id $applicant_user_id} }] - set add_url [export_vars -base "../ecommerce/shopping-cart-add" { product_id {user_id $patron_id} {participant_id $applicant_user_id} return_url }] + set add_url [export_vars -base "[ad_conn package_url]ecommerce/shopping-cart-add" { product_id {user_id $patron_id} {participant_id $applicant_user_id} return_url }] set register_url [export_vars -base admin/participant-add { section_id {user_id $applicant_user_id} return_url add_url }] # get associated comment 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.20 -r1.21 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 6 Sep 2005 04:39:23 -0000 1.20 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 14 Sep 2005 02:42:32 -0000 1.21 @@ -211,6 +211,52 @@ } +# If the product_id is worth $0 and free registration is allowed, skip +# the shopping cart and add the user immediately to the associated community +if { [info exists section_id] } { + set price [dotlrn_ecommerce::section::price $section_id] + + if { $price < 0.01 && [parameter::get -parameter AllowFreeRegistration -default 0] } { + dotlrn_community::add_user $community_id $participant_id + } + + # 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 { [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 { [exists_and_not_null return_url] } { + ad_returnredirect $return_url + } else { + ad_returnredirect [ad_conn package_url] + } + ad_script_abort +} + # added default values to above params so that this page works # when a post from a form to shopping-cart-add originates from another domain.