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.86 -r1.87 --- openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 24 Jan 2007 18:34:42 -0000 1.86 +++ openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.tcl 31 Jan 2007 18:02:39 -0000 1.87 @@ -17,6 +17,10 @@ {active_calendar_id 0} {all_sessions_p 0} } + +if {![info exists list_style]} { + set list_style courses +} if {![info exists show_filters_p]} { set show_filters_p 1 } @@ -278,7 +282,7 @@ set allow_other_registration_p [parameter::get -parameter AllowRegistrationForOtherUsers -default 1] set offer_code_p [parameter::get -parameter OfferCodesP -default 0] -lappend filters course_id {where_clause "ci.item_id=:course_id" hide_p 1} section_id {} +lappend filters course_id {where_clause "ci.item_id=:course_id" hide_p 1} template::list::create \ -name course_list \ @@ -481,7 +485,7 @@ label "Group by" type multivar values { - { { Go to course [_ dotlrn-ecommerce.edit] [_ dotlrn-ecommerce.add_section] + {{ @course_list.course_name@ [_ dotlrn-ecommerce.edit] [_ dotlrn-ecommerce.add_section]
@course_list.course_grades@

@course_list.course_info;noquote@ Index: openacs-4/packages/dotlrn-ecommerce/www/one-course.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/one-course.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/dotlrn-ecommerce/www/one-course.adp 24 Jan 2007 18:44:55 -0000 1.3 +++ openacs-4/packages/dotlrn-ecommerce/www/one-course.adp 31 Jan 2007 18:02:39 -0000 1.4 @@ -1,2 +1,154 @@ - \ No newline at end of file +Course Info: @course_name@ +

Course Info

+

@course_name@ @course_id@

+ +

#dotlrn-ecommerce.edit#

+
+
+
+ + +

Course Description

+

@sections.course_info@

+ +

@categories.tree_name@

+@categories.category_names@ +
+
+
+
+
+ +

@sections.section_name@

+ +

#dotlrn-ecommerce.edit# + + #dotlrn-ecommerce.This_section_is_hidden# #dotlrn-ecommerce.Show_this_section##dotlrn-ecommerce.Hide_this_section# +

+

@sections.description;noquote@

+ +
@sections.sessions;noquote@
+
@sections.section_zones;noquote@
+
@sections.instructor_names;noquote@
+
#dotlrn-ecommerce.lt_There_is_no_fee_for_t#@sections.prices;noquote@
+ +
@sections.attendees;noquote@ #dotlrn-ecommerce.participant#s + ,
@sections.available_slots;noquote@ #dotlrn-ecommerce.available#
+ +
#dotlrn-ecommerce.lt_This_section_is_curre# +
+
+ +
+ @sections.fs_chunk;noquote@ +
+ + + + + +
+ + + + + + +
+ + + [_ dotlrn-ecommerce.Offer_Code]
+ +
+ +
+ + @sections.button@ + +
+ + @sections.button@ + +
+ + + + + + + +
+ + + [_ dotlrn-ecommerce.Offer_Code]
+ +
+ +
+ + @sections.button@ + +
+ + @sections.button@ + + +
+
+
+ + [_ dotlrn-ecommerce.register] + + + + [_ dotlrn-ecommerce.application_pending] + + + [_ dotlrn-ecommerce.lt_You_are_number_course] + + + @sections.asm_url;noquote@ + + + [_ dotlrn-ecommerce.awaiting_approval] + + + [_ dotlrn-ecommerce.view_applications] + +
+ + +
+ + + [_ dotlrn-ecommerce.lt_Your_application_was_]

+ + + [_ dotlrn-ecommerce.lt_A_place_is_now_availa]

+ + + +

+

+ + + [_ dotlrn-ecommerce.Offer_Code]
+ +
+
+ + [_ dotlrn-ecommerce.lt_Continue_Registration] + +
+
+
+ +
+ @sections.patron_message;noquote@ +
+ + +


+
+
\ No newline at end of file Index: openacs-4/packages/dotlrn-ecommerce/www/one-course.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/one-course.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/dotlrn-ecommerce/www/one-course.tcl 24 Jan 2007 18:32:36 -0000 1.2 +++ openacs-4/packages/dotlrn-ecommerce/www/one-course.tcl 31 Jan 2007 18:02:39 -0000 1.3 @@ -10,10 +10,234 @@ cal_item_id:integer,optional } +set user_id [ad_conn user_id] +set admin_p [permission::permission_p \ + -object_id [ad_conn package_id] \ + -party_id $user_id \ + -privilege admin] if {[info exists cal_item_id] && ![string equal "" $cal_item_id]} { set course_key [db_string get_course_key "select d1.course_key from dotlrn_catalog d1,cr_items ci, (select distinct des.course_id from cal_items c,dotlrn_ecommerce_section des, dotlrn_communities dc, portal_element_map pem, portal_pages pp, portal_element_parameters pep where pep.key='calendar_id' and pep.value=c.on_which_calendar and pem.element_id=pep.element_id and pem.page_id=pp.page_id and pp.portal_id=dc.portal_id and c.cal_item_id=:cal_item_id and dc.community_id=des.community_id) d2 where d1.course_id=ci.live_revision and ci.item_id=d2.course_id" -default ""] } +set course_return_url [ad_conn url] +# get categories mapped to course +set cc_package_id [apm_package_id_from_key "dotlrn-catalog"] +set category_trees [category_tree::get_mapped_trees $cc_package_id] +template::multirow create categories tree_name category_names +foreach category_tree $category_trees { + set category_names [join [category::get_names [category::get_mapped_categories -tree_id [lindex $category_tree 0] [content::item::get_latest_revision -item_id $course_id]]] ", "] + template::multirow append categories [lindex $category_tree 1] $category_names +} +set allow_free_registration_p [parameter::get -parameter AllowFreeRegistration -default 0] +set allow_other_registration_p [parameter::get -parameter AllowRegistrationForOtherUsers -default 1] +set memoize_max_age [parameter::get -parameter CatalogMemoizeAge -default 120] + +set patron_communities [db_list patron_communities { + select r.community_id from + dotlrn_member_rels_full r, + acs_objects o + where o.object_id = r.rel_id + and r.member_state in ('request approval', 'request approved', 'needs approval', 'waitinglist approved') + and o.creation_user=:user_id + and r.user_id <> o.creation_user +}] +set offer_code_p [parameter::get -parameter OfferCodesP -default 0] +if { $offer_code_p } { + set discount_clause [db_map discount] +} else { + set discount_clause "" +} + + +db_multirow -extend {toggle_display_url patron_message member_state fs_chunk section_folder_id section_pages_url category_name community_url section_add_url section_edit_url course_grades section_grades section_zones sections_url member_p sessions instructor_names price prices shopping_cart_add_url attendees available_slots pending_p waiting_p approved_p instructor_p registration_approved_url button waiting_list_number asm_url cancel_url} sections get_sections { + select dc.course_id, trim(dc.course_key) as course_key, dc.course_name, + dc.assessment_id, dec.section_id, dec.section_name, + dec.product_id, dec.community_id, dc.course_info, + ci.item_id, v.maxparticipants, dec.show_participants_p, dec.show_sessions_p, dec.description, v.show_description_p, v.display_section_p, dec.show_price_p + + from dotlrn_catalog dc, + cr_items ci + left join dotlrn_ecommerce_section dec + on (ci.item_id = dec.course_id) + left join ec_custom_product_field_values v + on (dec.product_id = v.product_id) + + where dc.course_id = ci.live_revision + and ci.item_id = :course_id + and (v.display_section_p is null or v.display_section_p = 't' or :admin_p = 1) + + order by lower(dc.course_name), lower(dec.section_name) +} { + set course_name $course_name + set course_rev_id $course_id + set course_item_id $item_id + + # HAM : check NoPayment parameter + # if we're not asking for payment, change shopping cart url + # to dotlrn-ecommerce/register + if { [parameter::get -package_id [ad_conn package_id] -parameter NoPayment -default 0] } { + set shopping_cart_add_url [export_vars -base register/ { community_id product_id }] + } else { + if { $allow_other_registration_p } { + set shopping_cart_add_url [export_vars -base [ad_conn package_url]ecommerce/participant-change { user_id product_id return_url }] + } else { + set return_url [export_vars -base [ad_conn package_url]ecommerce/shopping-cart-add { user_id product_id }] + if { $user_id == 0 } { + set shopping_cart_add_url [export_vars -base [ad_conn package_url]ecommerce/login { return_url }] + } else { + set shopping_cart_add_url $return_url + } + } + } + + set registration_approved_url [export_vars -base ecommerce/shopping-cart-add { user_id product_id}] + + set prices "" + if { ! [empty_string_p $product_id] } { + set prices [ec_pretty_price [set price [util_memoize [list dotlrn_ecommerce::section::price $section_id] $memoize_max_age]]] + if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] } { + set member_price [util_memoize [list dotlrn_ecommerce::section::member_price $section_id] $memoize_max_age] + if { $member_price } { + if { ! [empty_string_p $member_price] } { + append prices " / [ec_pretty_price $member_price]" + } + } + } + + # HAM : if the NoPayment parameter is set to "1" don't show the prices + if { [parameter::get -package_id [ad_conn package_id] -parameter NoPayment -default 0] } { + set prices "" + } + } + + set member_state [util_memoize [list dotlrn_ecommerce::section::member_state $user_id $community_id] $memoize_max_age] + + + set waiting_p 0 + set pending_p 0 + set approved_p 0 + switch $member_state { + "needs approval" { + set waiting_p 1 + set waiting_list_number [util_memoize [list dotlrn_ecommerce::section::waiting_list_number $user_id $community_id] $memoize_max_age] + } + "application sent" { + set waiting_p 2 + if { ![empty_string_p $assessment_id] } { + set rel_id [db_string membership_rel { + select m.rel_id + from acs_rels r, + membership_rels m + where r.rel_id = m.rel_id + and r.object_id_one = :community_id + and r.object_id_two = :user_id + limit 1 + }] + + if { [db_0or1row assessment { + select m.session_id, completed_datetime + from dotlrn_ecommerce_application_assessment_map m, as_sessions s + where m.session_id = s.session_id + and rel_id = :rel_id + order by m.session_id desc + limit 1 + }] } { + set edit_asm_url [export_vars -base /assessment/assessment { assessment_id session_id }] + set cancel_url [export_vars -base application-reject { community_id user_id {send_email_p 0} {return_url $course_return_url} }] + + if { ! [empty_string_p $completed_datetime] } { + set review_asm_url [export_vars -base /assessment/session { session_id }] + set asm_url [subst { + [_ dotlrn-ecommerce.review_application] + [_ dotlrn-ecommerce.lt_Edit_your_application] + [_ dotlrn-ecommerce.lt_Cancel_your_applicati] + }] + } else { + set asm_url [subst { + [_ dotlrn-ecommerce.lt_Your_application_is_i] + [_ dotlrn-ecommerce.lt_Cancel_your_applicati] + }] + } + } + } + } + "request approval" { + set pending_p 1 + } + "application approved" { + set approved_p 1 + if {![empty_string_p $assessment_id]} { + set rel_id [db_string membership_rel { + select m.rel_id + from acs_rels r, + membership_rels m + where r.rel_id = m.rel_id + and r.object_id_one = :community_id + and r.object_id_two = :user_id + limit 1 + }] + + if { [db_0or1row assessment { + select m.session_id, completed_datetime + from dotlrn_ecommerce_application_assessment_map m, as_sessions s + where m.session_id = s.session_id + and rel_id = :rel_id + order by m.session_id desc + limit 1 + }] } { + if { ! [empty_string_p $completed_datetime] } { + set asm_url [export_vars -base /assessment/session { session_id }] + set asm_url [subst { + [_ dotlrn-ecommerce.review_application] + }] + } else { + set asm_url [export_vars -base /assessment/assessment { assessment_id session_id }] + set asm_url [subst {[_ dotlrn-ecommerce.lt_Your_application_is_i]}] + } + } + } + } + "waitinglist approved" - + "request approved" { + set approved_p 1 + } + } + + # The above was the users waiting list and applications + # Get the patron information + + set patron_message "" + + if {[lsearch $patron_communities $community_id] >= 0} { + + + set patron_message [util_memoize [list dotlrn_ecommerce::patron_catalog_message $community_id $user_id $product_id] $memoize_max_age] + } + + # HAM : if we don't have an instructor id + set instructor_p -1 + if { [exists_and_not_null instructor_ids] } { + set instructor_p [lsearch $instructor_ids $user_id] + } + + set assessment_id [util_memoize [list dotlrn_ecommerce::section::application_assessment $section_id] $memoize_max_age] + if { ! [empty_string_p $assessment_id] && $assessment_id != -1 } { + set button "[_ dotlrn-ecommerce.apply_for_course]" + } + + if {[catch {set fs_chunk [util_memoize [list uplevel dotlrn_ecommerce::section::fs_chunk $section_id] $memoize_max_age]} errmsg]} { + ns_log notice "ERROR:DAVEB tree-chunk.tcl calling fs_chunk section_id='${section_id} \n tree_id = '${tree_id}' \n ------ \n $errmsg \n ----- \n'" + } + set description [ad_text_to_html $description] + + if { ! [dotlrn_ecommerce::util::param::get -default 1 ShowPriceOptionP] } { + set show_price_p f + } + set section_edit_url [export_vars -base admin/one-section { course_id section_id }] + set toggle_display_url [export_vars -base admin/toggle-display {section_id {return_url $course_return_url}}] +} + +set course_edit_url [export_vars -base admin/course-info { course_id course_name course_key }]