Index: openacs-4/packages/ae-portlet/tcl/apm-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/ae-portlet/tcl/apm-callback-procs.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/ae-portlet/tcl/apm-callback-procs.tcl 9 Jun 2005 05:54:36 -0000 1.1
+++ openacs-4/packages/ae-portlet/tcl/apm-callback-procs.tcl 19 Jun 2005 06:05:05 -0000 1.2
@@ -17,7 +17,7 @@
ae_admin_portlet::after_install
}
-ad_proc -public apm::anon-eval_portlet::before_uninstall {} {
+ad_proc -public apm::ae_portlet::before_uninstall {} {
Anon-Eval Portlet package uninstall proc
} {
Index: openacs-4/packages/attendance/lib/cp-attendance.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/lib/cp-attendance.adp,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/attendance/lib/cp-attendance.adp 9 Jun 2005 05:54:37 -0000 1.1
+++ openacs-4/packages/attendance/lib/cp-attendance.adp 19 Jun 2005 06:05:05 -0000 1.2
@@ -1,8 +1,6 @@
-
Sessions
-
Index: openacs-4/packages/attendance/lib/cp-attendance.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/attendance/lib/cp-attendance.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/attendance/lib/cp-attendance.tcl 9 Jun 2005 05:54:37 -0000 1.1
+++ openacs-4/packages/attendance/lib/cp-attendance.tcl 19 Jun 2005 06:05:05 -0000 1.2
@@ -1,9 +1,14 @@
-set current_url [ad_conn url]
+set current_url [ad_conn url]?[ad_conn query]
-set package_id [ad_conn package_id]
-set community_id [dotlrn_community::get_community_id]
+if {![info exists package_id]} {
+ set package_id [ad_conn package_id]
+}
+if {![info exists community_id]} {
+ set community_id [dotlrn_community::get_community_id]
+}
+
set attendance_package_id [db_string "getattpack" "select object_id from acs_objects a, apm_packages b where a.object_id = b.package_id and a.context_id = :package_id and b.package_key = 'attendance';"]
set attendance_url [apm_package_url_from_id $attendance_package_id]
@@ -29,16 +34,21 @@
-key task_id \
-no_data "No sessions" \
-elements {
- task_name {
- label "Session"
- }
- action {
- label "Actions"
- display_template { Edit | Mark Attendance }
- }
+ task_name {
+ label "Session"
}
+ date_time {
+ label "Date and Time"
+ }
+ action {
+ label "Actions"
+ html "nowrap"
+ display_template { Edit | Attendance }
+ }
+ }
-db_multirow -extend {cal_item_id} session_list get_sessions {
+
+db_multirow -extend {cal_item_id date_time} session_list get_sessions {
select et.task_name, et.number_of_members, et.task_id, et.grade_item_id,
to_char(et.due_date,'YYYY-MM-DD HH24:MI:SS') as due_date_ansi,
et.online_p,
@@ -62,5 +72,14 @@
and cri.live_revision = et.task_id
and et.mime_type = crmt.mime_type
} {
- set cal_item_id [db_string "getcalid" "select cal_item_id from evaluation_cal_task_map where task_item_id=:item_id"]
+ set cal_item_id [db_string "getcalid" "select cal_item_id from evaluation_cal_task_map where task_item_id=:item_id"]
+ set date_time [db_string datetime {
+ select to_char(start_date, 'Mon dd, yyyy hh:miam-')||to_char(end_date, 'hh:miam')
+ from cal_items ci, acs_events e, acs_activities a, timespans s, time_intervals t
+ where e.timespan_id = s.timespan_id
+ and s.interval_id = t.interval_id
+ and e.activity_id = a.activity_id
+ and e.event_id = ci.cal_item_id
+ and ci.cal_item_id = :cal_item_id
+ } -default ""]
}
\ No newline at end of file
Index: openacs-4/packages/dotlrn-attendance/dotlrn-attendance.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-attendance/dotlrn-attendance.info,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/dotlrn-attendance/dotlrn-attendance.info 31 May 2005 22:03:56 -0000 1.1
+++ openacs-4/packages/dotlrn-attendance/dotlrn-attendance.info 19 Jun 2005 06:05:05 -0000 1.2
@@ -1,7 +1,7 @@
-
+
dotLRN Attendance Applet
dotLRn Attendance Applets
f
Index: openacs-4/packages/dotlrn-attendance/sql/postgresql/dotlrn-attendance-admin-portlet-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-attendance/sql/postgresql/dotlrn-attendance-admin-portlet-create.sql,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-attendance/sql/postgresql/dotlrn-attendance-admin-portlet-create.sql 19 Jun 2005 06:05:06 -0000 1.1
@@ -0,0 +1,182 @@
+
+create function inline_0()
+returns integer as '
+declare
+ ds_id portal_datasources.datasource_id%TYPE;
+begin
+ ds_id := portal_datasource__new(
+ ''dotlrn_attendance_admin_portlet'', -- name
+ ''Displays the dotlrn_attendance_admin'' -- description
+ );
+
+ -- 4 defaults procs
+
+ -- shadeable_p
+ perform portal_datasource__set_def_param (
+ ds_id, -- datasource_id
+ ''t'', -- config_required_p
+ ''t'', -- configured_p
+ ''shadeable_p'', -- key
+ ''f'' -- value
+ );
+
+ -- shaded_p
+ perform portal_datasource__set_def_param (
+ ds_id, -- datasource_id
+ ''t'', -- config_required_p
+ ''t'', -- configured_p
+ ''shaded_p'', -- key
+ ''f'' -- value
+ );
+
+ -- hideable_p
+ perform portal_datasource__set_def_param (
+ ds_id, -- datasource_id
+ ''t'', -- config_required_p
+ ''t'', -- configured_p
+ ''hideable_p'', -- key
+ ''t'' -- value
+ );
+
+ -- user_editable_p
+ perform portal_datasource__set_def_param (
+ ds_id, -- datasource_id
+ ''t'', -- config_required_p
+ ''t'', -- configured_p
+ ''user_editable_p'', -- key
+ ''f'' -- value
+ );
+
+ -- link_hideable_p
+ perform portal_datasource__set_def_param (
+ ds_id, -- datasource_id
+ ''t'', -- config_required_p
+ ''t'', -- configured_p
+ ''link_hideable_p'', -- key
+ ''t'' -- value
+ );
+
+
+ -- attendance_admin-specific procs
+
+ -- package_id must be configured
+ perform portal_datasource__set_def_param (
+ ds_id, -- datasource_id
+ ''t'', -- config_required_p
+ ''f'', -- configured_p
+ ''package_id'', -- key
+ '''' -- value
+ );
+
+ return 0;
+
+end;' language 'plpgsql';
+select inline_0();
+drop function inline_0();
+
+
+create function inline_0()
+returns integer as '
+declare
+ foo integer;
+begin
+ -- create the implementation
+ perform acs_sc_impl__new (
+ ''portal_datasource'',
+ ''dotlrn_attendance_admin_portlet'',
+ ''dotlrn_attendance_admin_portlet''
+ );
+ return 0;
+
+end;' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
+
+create function inline_0()
+returns integer as '
+declare
+ foo integer;
+begin
+
+ -- add all the hooks
+ perform acs_sc_impl_alias__new (
+ ''portal_datasource'',
+ ''dotlrn_attendance_admin_portlet'',
+ ''GetMyName'',
+ ''dotlrn_attendance_admin_portlet::get_my_name'',
+ ''TCL''
+ );
+
+ perform acs_sc_impl_alias__new (
+ ''portal_datasource'',
+ ''dotlrn_attendance_admin_portlet'',
+ ''GetPrettyName'',
+ ''dotlrn_attendance_admin_portlet::get_pretty_name'',
+ ''TCL''
+ );
+
+ perform acs_sc_impl_alias__new (
+ ''portal_datasource'',
+ ''dotlrn_attendance_admin_portlet'',
+ ''Link'',
+ ''dotlrn_attendance_admin_portlet::link'',
+ ''TCL''
+ );
+
+ perform acs_sc_impl_alias__new (
+ ''portal_datasource'',
+ ''dotlrn_attendance_admin_portlet'',
+ ''AddSelfToPage'',
+ ''dotlrn_attendance_admin_portlet::add_self_to_page'',
+ ''TCL''
+ );
+
+ perform acs_sc_impl_alias__new (
+ ''portal_datasource'',
+ ''dotlrn_attendance_admin_portlet'',
+ ''Show'',
+ ''dotlrn_attendance_admin_portlet::show'',
+ ''TCL''
+ );
+
+ perform acs_sc_impl_alias__new (
+ ''portal_datasource'',
+ ''dotlrn_attendance_admin_portlet'',
+ ''Edit'',
+ ''dotlrn_attendance_admin_portlet::edit'',
+ ''TCL''
+ );
+
+ perform acs_sc_impl_alias__new (
+ ''portal_datasource'',
+ ''dotlrn_attendance_admin_portlet'',
+ ''RemoveSelfFromPage'',
+ ''dotlrn_attendance_admin_portlet::remove_self_from_page'',
+ ''TCL''
+ );
+
+ return 0;
+
+end;' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
+
+create function inline_0()
+returns integer as '
+declare
+ foo integer;
+begin
+
+ -- Add the binding
+ perform acs_sc_binding__new (
+ ''portal_datasource'', -- contract_name
+ ''dotlrn_attendance_admin_portlet'' -- impl_name
+ );
+ return 0;
+
+end;' language 'plpgsql';
+
+select inline_0();
+drop function inline_0();
Index: openacs-4/packages/dotlrn-attendance/tcl/dotlrn-attendance-admin-portlet-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-attendance/tcl/dotlrn-attendance-admin-portlet-procs.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-attendance/tcl/dotlrn-attendance-admin-portlet-procs.tcl 19 Jun 2005 06:05:06 -0000 1.1
@@ -0,0 +1,76 @@
+ad_library {
+
+ Procedures to support attendance admin portlets
+
+ @creation-date May 2005
+ @author hamilton.chua@gmail.com
+ @version $Id: dotlrn-attendance-admin-portlet-procs.tcl,v 1.1 2005/06/19 06:05:06 hamiltonc Exp $
+}
+
+namespace eval dotlrn_attendance_admin_portlet {
+
+ ad_proc -private get_my_name {
+ } {
+ return "dotlrn_attendance_admin_portlet"
+ }
+
+ ad_proc -public get_pretty_name {
+ } {
+ return "Attendance Administration"
+ }
+
+ ad_proc -private my_package_key {
+ } {
+ return "dotlrn-attendance"
+ }
+
+ ad_proc -public link {
+ } {
+ return ""
+ }
+
+ ad_proc -public add_self_to_page {
+ {-portal_id:required}
+ {-package_id:required}
+ } {
+ Adds a attendance admin PE to the admin portal
+
+ @return new element_id
+ } {
+ return [portal::add_element_parameters \
+ -portal_id $portal_id \
+ -portlet_name [get_my_name] \
+ -pretty_name [get_pretty_name] \
+ -key package_id \
+ -value $package_id
+ ]
+ }
+
+ ad_proc -public remove_self_from_page {
+ {-portal_id:required}
+ } {
+ Removes the attendance admin PE from the portal
+ } {
+ portal::remove_element \
+ -portal_id $portal_id \
+ -portlet_name [get_my_name]
+ }
+
+ ad_proc -public show {
+ cf
+ } {
+ } {
+ portal::show_proc_helper \
+ -package_key [my_package_key] \
+ -config_list $cf \
+ -template_src "dotlrn-attendance-admin-portlet"
+ }
+
+ ad_proc -public edit {
+ cf
+ } {
+ } {
+ return ""
+ }
+
+}
Index: openacs-4/packages/dotlrn-attendance/tcl/dotlrn-attendance-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-attendance/tcl/dotlrn-attendance-procs.tcl,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/dotlrn-attendance/tcl/dotlrn-attendance-procs.tcl 31 May 2005 22:03:56 -0000 1.1
+++ openacs-4/packages/dotlrn-attendance/tcl/dotlrn-attendance-procs.tcl 19 Jun 2005 06:05:06 -0000 1.2
@@ -56,16 +56,31 @@
Add the attendance applet to a specifc community
} {
set portal_id [dotlrn_community::get_portal_id \
- -community_id $community_id
- ]
+ -community_id $community_id ]
# create the package instance (all in one, I've mounted it)
set package_id [dotlrn::instantiate_and_mount \
$community_id \
[package_key]
]
+
+ #
+ # portlet stuff
+ #
+
+ # set up the admin portlet
+
+ set admin_portal_id [dotlrn_community::get_admin_portal_id \
+ -community_id $community_id
+ ]
+
+ dotlrn_attendance_admin_portlet::add_self_to_page \
+ -portal_id $admin_portal_id \
+ -package_id $package_id
+
# return the package_id
return $package_id
+
}
ad_proc -public remove_applet_from_community {
@@ -117,7 +132,11 @@
@portal_id
} {
- # noop
+ set args [ns_set create]
+ ns_set put $args package_id 0
+ ns_set put $args param_action "overwrite"
+
+ add_portlet_helper $portal_id $args
}
ad_proc -public add_portlet_helper {
@@ -130,7 +149,10 @@
@param portal_id
@param args An ns_set
} {
- #noop
+ dotlrn_attendance_admin_portlet::add_self_to_page \
+ -portal_id $portal_id \
+ -package_id [ns_set get $args "package_id"] \
+ -param_action [ns_set get $args "param_action"]
}
ad_proc -public remove_portlet {
@@ -142,7 +164,9 @@
@param portal_id
@param args An ns_set
} {
- #noop
+ dotlrn_attendance_admin_portlet::remove_self_from_page \
+ -portal_id $portal_id \
+ -package_id [ns_set get $args "package_id"]
}
ad_proc -public clone {
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 -N -r1.2 -r1.3
--- openacs-4/packages/dotlrn-ecommerce/dotlrn-ecommerce.info 2 Jun 2005 06:39:41 -0000 1.2
+++ openacs-4/packages/dotlrn-ecommerce/dotlrn-ecommerce.info 19 Jun 2005 06:05:06 -0000 1.3
@@ -14,15 +14,13 @@
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.
-
-
-
+
Index: openacs-4/packages/dotlrn-ecommerce/lib/cal-view.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/cal-view.adp,v
diff -u -N -r1.2 -r1.3
--- openacs-4/packages/dotlrn-ecommerce/lib/cal-view.adp 4 Jun 2005 10:05:17 -0000 1.2
+++ openacs-4/packages/dotlrn-ecommerce/lib/cal-view.adp 19 Jun 2005 06:05:06 -0000 1.3
@@ -6,6 +6,9 @@
border-collapse: collapse;
font-size: 11px;
}
+div.cal-month-event {
+ font-size: 12px;
+}
Index: openacs-4/packages/dotlrn-ecommerce/lib/cal-view.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/cal-view.tcl,v
diff -u -N -r1.2 -r1.3
--- openacs-4/packages/dotlrn-ecommerce/lib/cal-view.tcl 4 Jun 2005 10:05:17 -0000 1.2
+++ openacs-4/packages/dotlrn-ecommerce/lib/cal-view.tcl 19 Jun 2005 06:05:06 -0000 1.3
@@ -19,27 +19,45 @@
set package_id [ad_conn package_id]
set user_id [ad_conn user_id]
-set filters [list]
-set view calendar
-# Generate filters based on categories
-lappend filters category_f {
- label "[_ dotlrn-catalog.categories]"
- values { ${Course Type} }
- where_clause { ${Course Type_where_query} }
- } uncat_f {
- label "[_ dotlrn-catalog.uncat]"
- values { "Watch" }
- where_clause { dc.course_id not in ( select object_id from category_object_map where category_id in \
- ( select category_id from categories where tree_id =:tree_id ))
- }
- }
+set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
+set filters {}
+# Generate filters based on categories
+# set filters {
+# uncat_f {
+# label "[_ dotlrn-catalog.uncat]"
+# values { "Watch" }
+# where_clause { dc.course_id not in ( select object_id from category_object_map where category_id in \
+# ( select category_id from categories where tree_id =:tree_id ))
+# }
+# }
+# }
+
set filter_list [list category_f]
-set form [ns_getform]
+set form [rp_getform]
+set category_trees [concat [category_tree::get_mapped_trees $cc_package_id] [category_tree::get_mapped_trees $package_id]]
+set course_categories [list]
+set section_categories [list]
+
+foreach tree [category_tree::get_mapped_trees $cc_package_id] {
+ set tree_name [lindex $tree 1]
+ regsub -all { } $tree_name _ f
+ set f [string tolower $f]_f
+
+ ns_log notice "DEBUG:: CATEGORY:: $tree_name"
+
+ lappend filter_list $f
+ set ff [ns_set get $form $f]
+
+ if { ! [empty_string_p $ff] } {
+ set $f $ff
+ }
+ lappend course_categories [lindex $tree 0]
+}
foreach tree [category_tree::get_mapped_trees $package_id] {
set tree_name [lindex $tree 1]
regsub -all { } $tree_name _ f
@@ -53,6 +71,7 @@
if { ! [empty_string_p $ff] } {
set $f $ff
}
+ lappend section_categories [lindex $tree 0]
}
ns_log notice "DEBUG:: FILTER:: $filter_list"
@@ -75,9 +94,9 @@
}
# Get all tree categories
-set category_trees [linsert [category_tree::get_mapped_trees $package_id] 0 $tree_id]
+#set category_trees [linsert [category_tree::get_mapped_trees $package_id] 0 $tree_id]
+#set category_trees [category_tree::get_mapped_trees $cc_package_id]
-set count 0
foreach tree_id $category_trees {
set tree_id [lindex $tree_id 0]
@@ -104,12 +123,8 @@
lappend $name [list "${spacer}[lindex "$element" 1]" "[lindex $element 0]&level=[lindex $element 3]" ]
}
- if { $count == 0 } {
- set f category_f
- } else {
- regsub -all { } $name _ f
- set f [string tolower $f]_f
- }
+ regsub -all { } $name _ f
+ set f [string tolower $f]_f
# Get all sub categories
set map_tree "("
@@ -141,7 +156,7 @@
append map_tree "0)"
}
- if { $count == 0 } {
+ if { [lsearch $course_categories $tree_id] != -1 } {
if { [string equal $[set ${f}_category_v] ""] } {
set ${name}_where_query "dc.course_id in ( select object_id from category_object_map_tree where tree_id = $tree_id )"
} else {
@@ -154,10 +169,9 @@
set ${name}_where_query "dec.community_id in ( select object_id from category_object_map_tree where tree_id = $tree_id and category_id in $map_tree )"
}
}
- incr count
}
-foreach tree [category_tree::get_mapped_trees $package_id] {
+foreach tree $category_trees {
set tree_name [lindex $tree 1]
regsub -all { } $tree_name _ f
set f [string tolower $f]_f
@@ -170,23 +184,6 @@
]
}
-
-# Section categories
-#foreach section_tree [category_tree::get_mapped_trees $package_id] {
-# set tree_list [category_tree::get_tree -all $section_tree]
-#}
-
-# age_description_f {
-# label "Age Description"
-# values { ${Age Description} }
-# where_clause { ${Age Description_where_query} }
-# }
-
-set filters [linsert $filters 0 date {} view {
- label "View"
- values { {List ""} {"" ""} }
-}]
-
set instructor_community_id [parameter::get -package_id [ad_conn package_id] -parameter InstructorCommunityId -default 0 ]
set _instructors [dotlrn_community::list_users $instructor_community_id]
if { [llength $_instructors] == 0 } {
@@ -209,6 +206,11 @@
and r.rel_type = 'dotlrn_admin_rel'
and r.user_id in ([join $instructor ,]))}}]
+set filters [linsert $filters 0 date {} view {
+ label "View"
+ values { {List ""} }
+}]
+
set cc_package_id [apm_package_id_from_key "dotlrn-catalog"]
set admin_p [permission::permission_p -object_id $cc_package_id -privilege "admin"]
template::list::create \
Index: openacs-4/packages/dotlrn-ecommerce/lib/dotlrn-ecommerce-admin-portlet.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/dotlrn-ecommerce-admin-portlet.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/lib/dotlrn-ecommerce-admin-portlet.adp 19 Jun 2005 06:05:06 -0000 1.1
@@ -0,0 +1,17 @@
+
+
+
\ No newline at end of file
Index: openacs-4/packages/dotlrn-ecommerce/lib/dotlrn-ecommerce-admin-portlet.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/dotlrn-ecommerce-admin-portlet.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/lib/dotlrn-ecommerce-admin-portlet.tcl 19 Jun 2005 06:05:06 -0000 1.1
@@ -0,0 +1,42 @@
+
+# where are we
+
+# get the package_id
+set package_id [ad_conn package_id]
+
+# get community_id
+set community_id [dotlrn_community::get_community_id]
+
+# where is dotlrn-ecommerce mounted
+set dotlrn_ecommerce_url [apm_package_url_from_key "dotlrn-ecommerce"]
+
+# show admin links
+# we test to see if there is section info
+# if not then show_admin is set to 0
+# this happens in template sections
+set show_admin 1
+
+# retrieve section _info
+if { [db_0or1row "get_section_info" "select section_id, product_id from dotlrn_ecommerce_section where community_id = :community_id"] } {
+
+ set community_url [dotlrn_community::get_community_url $community_id]
+
+ db_1row attendees {
+ select count(*) as attendees
+ from dotlrn_member_rels_approved
+ where community_id = :community_id
+ and (rel_type = 'dotlrn_member_rel'
+ or rel_type = 'dotlrn_club_student_rel')
+ }
+
+ set calendar_id [dotlrn_calendar::get_group_calendar_id -community_id $community_id]
+
+ set calendar_url [calendar_portlet_display::get_url_stub $calendar_id]
+
+ set item_type_id [db_string item_type_id "select item_type_id from cal_item_types where type='Session' and calendar_id = :calendar_id limit 1" -default 0]
+
+ set num_sessions [db_string num_sessions "select count(cal_item_id) from cal_items where on_which_calendar = :calendar_id and item_type_id = :item_type_id"]
+
+} else {
+ set show_admin 0
+}
\ No newline at end of file
Index: openacs-4/packages/dotlrn-ecommerce/lib/section.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/section.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/lib/section.adp 19 Jun 2005 06:05:06 -0000 1.1
@@ -0,0 +1,3 @@
+
+
+
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 -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/dotlrn-ecommerce/lib/section.tcl 19 Jun 2005 06:05:06 -0000 1.1
@@ -0,0 +1,728 @@
+# expected vars
+# section_id, course_id
+
+# optional
+# mode
+# return_url
+# has_edit
+
+if {![info exists has_edit]} {
+ set has_edit 0
+}
+
+
+
+dotlrn_catalog::get_course_data -course_id $course_id
+#set item_id [dotlrn_catalog::get_item_id -revision_id $course_id]
+
+set package_id [ad_conn package_id]
+set validate [list]
+
+catch {
+ db_1row template_community {
+ select community_id as template_community_id
+ from dotlrn_catalogi
+ where course_id = :course_id
+ }
+ set template_calendar_id [dotlrn_calendar::get_group_calendar_id -community_id $template_community_id]
+ set template_item_type_id [db_string item_type_id "select item_type_id from cal_item_types where type='Session' and calendar_id = :template_calendar_id limit 1" -default 0]
+}
+
+if {![info exists mode]} {
+ set mode edit
+}
+
+
+ad_form -name add_section -mode $mode -has_edit $has_edit -form {
+ section_id:key
+ {product_id:integer(hidden)}
+ {return_url:text(hidden) {value $return_url}}
+ {course_id:text(hidden) {value $course_id}}
+}
+
+if { [ad_form_new_p -key section_id] } {
+ ad_form -extend -name add_section -form {
+ {section_key:text {label "Section Key"}
+ {help_text "Short name used in URL"}
+ }
+ }
+
+ lappend validate {section_key
+ { [dotlrn_community::check_community_key_valid_p -community_key $section_key] }
+ "The section '$section_key' key already exists"
+ }
+
+} else {
+ ad_form -extend -name add_section -form {
+ {section_key:text(inform) {label "Section Key"}}
+ }
+
+}
+
+ad_form -extend -name add_section -form {
+ {section_name:text {label "Section Name"}}
+ {price:currency,to_sql(sql_number) {label "Regular Price"} {html {size 6}}}
+}
+
+
+# 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 ] } {
+ ad_form -extend -name add_section -form {
+ { member_price:currency,to_sql(sql_number) {label "Member Price"} {html {size 6}} }
+ }
+
+ lappend validate {member_price
+ { ![template::util::negative [template::util::currency::get_property whole_part $member_price]] }
+ "Member price can not be negative"
+ } {member_price
+ { !"[template::util::currency::get_property whole_part $member_price].[template::util::currency::get_property fractional_part $member_price]" == "0.00" }
+ "Member price can not be zero"
+ }
+}
+
+# HAM : Let's get the community id's for both Instructors and Assistants
+
+set instructor_community_id [parameter::get -package_id [ad_conn package_id] -parameter InstructorCommunityId -default 0 ]
+set assistant_community_id [parameter::get -package_id [ad_conn package_id] -parameter AssistantCommunityId -default 0 ]
+
+
+# HAM : Let's check if we have InstructorCommunityId enabled and set
+if { $instructor_community_id == 0 && ![db_0or1row "checkinstructorcommunity" "select community_id from dotlrn_communities where community_id = :instructor_community_id"] } {
+ ad_return_complaint 1 "Parameter InstructorCommunityId is not set or Community Id does not exist."
+} else {
+ # community_id is valid
+ # list users
+ set _instructors [dotlrn_community::list_users $instructor_community_id]
+ set instructors_list [list]
+ foreach instructor $_instructors {
+ set instructor_user_id [ns_set get $instructor user_id]
+ set instructor_name "[ns_set get $instructor first_names] [ns_set get $instructor last_name]"
+ lappend instructors_list [list $instructor_name $instructor_user_id ]
+ }
+
+ ad_form -extend -name add_section -form {
+ { instructors:string(multiselect),multiple,optional {label "Instructors"} {options { $instructors_list } } }
+ }
+}
+
+# HAM : Let's check if we have AssistantCommunityId enabled and set
+if { $assistant_community_id == 0 && ![db_0or1row "checkassistantcommunity" "select community_id from dotlrn_communities where community_id = :assistant_community_id"] } {
+ ad_return_complaint 1 "Parameter AssistantCommunityId is not set or Community Id does not exist."
+} else {
+ # community_id is valid
+ set _assistants [dotlrn_community::list_users $assistant_community_id]
+ set assistants_list [list]
+ foreach assistant $_assistants {
+ set assistant_user_id [ns_set get $assistant user_id]
+ set assistant_name "[ns_set get $assistant first_names] [ns_set get $assistant last_name]"
+ lappend assistants_list [list $assistant_name $assistant_user_id ]
+ }
+
+ ad_form -extend -name add_section -form {
+ { assistants:string(multiselect),multiple,optional {label "Assistants"} {options { $assistants_list } } }
+ }
+
+}
+
+
+if { ! [ad_form_new_p -key section_id] } {
+ db_1row community {
+ select community_id
+ from dotlrn_ecommerce_section
+ where section_id = :section_id
+ }
+ ad_form -extend -name add_section -form {
+ {categories:text(category),multiple,optional
+ {label "Categories"}
+ {html {size 4}}
+ {value "$community_id $package_id"}
+ }
+ }
+} else {
+ ad_form -extend -name add_section -form {
+ {categories:text(category),multiple,optional
+ {label "Categories"}
+ {html {size 4}}
+ }
+ }
+}
+
+
+# ecommerce stuff
+
+set exclude_list [list "'classid'"]
+
+db_foreach custom_fields_select "
+ select field_identifier,
+ field_name,
+ default_value,
+ column_type
+ from ec_custom_product_fields
+ where active_p='t'
+ and field_identifier not in ([join $exclude_list ", "])
+ order by creation_date" {
+ # date
+ if {[string equal $column_type date] || [string equal $column_type timestamp]} {
+ if {[string equal $field_identifier enddate]} {
+ ad_form -extend -name add_section -form [list \
+ [list "${field_identifier}:date,optional" {label $field_name} {value $default_value} {help_text "Not required for Distance Learning Courses"}]]
+ } else {
+ ad_form -extend -name add_section -form [list \
+ [list "${field_identifier}:date,optional" {label $field_name} {value $default_value}] \
+ ]
+ }
+ } elseif {[string equal $column_type integer] || [string equal $column_type number]} {
+ ad_form -extend -name add_section -form [list \
+ [list "${field_identifier}:float,optional" {label $field_name} {value $default_value} {html {size 5}}] \
+ ]
+ } elseif {[string equal $column_type "varchar(200)"]} {
+ ad_form -extend -name add_section -form [list \
+ [list "${field_identifier}:text(text),optional" {label $field_name} {value $default_value} {html {size 50 maxlength 200}}] \
+ ]
+ } elseif {[string equal $column_type "varchar(4000)"]} {
+ ad_form -extend -name add_section -form [list \
+ [list "${field_identifier}:text(textarea),optional" {label $field_name} {value $default_value} {html {rows 4 cols 60}}] \
+ ]
+ } else {
+ ad_form -extend -name add_section -form [list \
+ [list "${field_identifier}:text(radio),optional" {label $field_name} {value $default_value} {options {{Yes t} {No f}}}] \
+ ]
+ }
+}
+
+# Create the section for predefined sessions
+if { [info exists template_calendar_id] } {
+ set sessions_list [db_list_of_lists sessions {
+ select 'cal_item_id',
+ ci.cal_item_id,
+ 'typical_start_time',
+ to_char(start_date,'HH24:MI') as typical_start_time,
+ 'typical_end_time',
+ to_char(end_date,'HH24:MI') as typical_end_time,
+ 'session_name',
+ coalesce(e.name, a.name) as session_name,
+ 'session_description',
+ coalesce(e.status_summary, a.status_summary) as session_description,
+ 'start_date',
+ to_char(start_date, 'yyyy-mm-dd'),
+ 'end_date',
+ to_char(end_date, 'yyyy-mm-dd')
+ from acs_activities a,
+ acs_events e,
+ timespans s,
+ time_intervals t,
+ calendars cals,
+ cal_items ci left join
+ cal_item_types cit on cit.item_type_id = ci.item_type_id
+ where e.timespan_id = s.timespan_id
+ and s.interval_id = t.interval_id
+ and e.activity_id = a.activity_id
+ and ci.cal_item_id= e.event_id
+ and cals.calendar_id = ci.on_which_calendar
+ and e.event_id = ci.cal_item_id
+ and ci.on_which_calendar = :template_calendar_id
+ and ci.item_type_id = :template_item_type_id
+ }]
+} else {
+ set sessions_list [list]
+}
+
+if { [llength $sessions_list] } {
+ ad_form -extend -name add_section -form {
+ {-section "Predefined Sessions"}
+ }
+}
+
+foreach s $sessions_list {
+ array set session $s
+ template::util::array_to_vars session
+
+ # Roel: It might be better to create a widget for all these
+ set checked " checked"
+ if { [llength $sessions] } {
+ if { [lsearch $sessions $cal_item_id] == -1 } {
+ set checked ""
+ }
+ }
+
+ ad_form -extend -name add_section -form [subst -nobackslashes -nocommands {
+ {$cal_item_id:text(text),optional
+ {label {$session_name}}
+ {html {id sel$cal_item_id}}
+ {before_html { Create this session
}}
+ {after_html { \[y-m-d \]}}
+ }
+ {${cal_item_id}_start_time:date,optional {label "From"} {format {[lc_get formbuilder_time_format]}}}
+ {${cal_item_id}_end_time:date,optional {label "To"} {format {[lc_get formbuilder_time_format]}}}
+ }]
+
+ lappend validate [subst -nobackslashes -nocommands {$cal_item_id
+ { [lsearch {$sessions} $cal_item_id] == -1 || ! [empty_string_p "[set $cal_item_id]"] }
+ "You must enter a date for \"$session_name\""
+ }]
+}
+
+ns_log notice "DEBUG:: $validate"
+
+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 -package_id [ad_conn package_id] -parameter MemberPriceP -default 0] } {
+ lappend validate {member_price
+ { ![template::util::negative [template::util::currency::get_property whole_part $member_price]] }
+ "Member Price can not be negative"
+ }
+}
+
+
+
+
+ad_form -extend -name add_section -validate $validate -on_request {
+ # Set session times
+ foreach s $sessions_list {
+ array set session $s
+ template::util::array_to_vars session
+
+ set start_time [split $typical_start_time :]
+ set ${cal_item_id}_start_time [list {} {} {} [lindex $start_time 0] [lindex $start_time 1] {} {HH24:MI}]
+ set end_time [split $typical_end_time :]
+ set ${cal_item_id}_end_time [list {} {} {} [lindex $end_time 0] [lindex $end_time 1] {} {HH24:MI}]
+
+ set ${cal_item_id} $start_date
+ }
+} -new_request {
+ set product_id 0
+ set price [template::util::currency::create "$" "0" "." "00" ]
+ set member_price [template::util::currency::create "$" "0" "." "00" ]
+} -edit_request {
+ set course_item_id $course_id
+ db_1row community {
+ select des.*, p.price, c.community_key as section_key
+ from dotlrn_ecommerce_section des, ec_products p, dotlrn_communities c
+ where des.product_id = p.product_id
+ and des.community_id = c.community_id
+ and des.section_id = :section_id
+ }
+ set course_id $course_item_id
+
+ # HAM
+ # price is using currency_widget
+ set price_split [split $price .]
+ set price [template::util::currency::create "$" [lindex $price_split 0] [lindex $price_split 1] ]
+
+ db_1row custom_fields {
+ select * from ec_custom_product_field_values where product_id = :product_id
+ }
+
+ # Get instructors and assistants
+ set instructors [db_list instructors {
+ select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :community_id
+ and rel_type = 'dotlrn_admin_rel'
+ and user_id in (select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :instructor_community_id)
+ }]
+
+ set assistants [db_list assistants {
+ select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :community_id
+ and rel_type = 'dotlrn_club_instructor_rel'
+ and user_id in (select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :assistant_community_id)
+ }]
+
+ if { [parameter::get -package_id [ad_conn package_id] -parameter MemberPriceP -default 0 ] } {
+ if { [db_0or1row member_price {
+ select sale_price as member_price
+ from ec_sale_prices
+ where product_id = :product_id
+ limit 1
+ }] } {
+ # HAM
+ # member_price is using currency_widget
+ set member_price_split [split $member_price .]
+ set member_price [template::util::currency::create "$" [lindex $member_price_split 0] [lindex $member_price_split 1] ]
+ }
+ }
+} -new_data {
+ db_transaction {
+ # create the class instance
+ # See if we have a template community
+ # If yes, clone it
+ if { [exists_and_not_null template_community_id] } {
+ set community_id [dotlrn_community::clone \
+ -community_id $template_community_id \
+ -key $section_key \
+ -pretty_name "$course_data(name): Section $section_name"]
+
+ ns_log notice "DEBUG:: Cloned $community_id from $template_community_id"
+ } else {
+ set community_id [dotlrn_community::new \
+ -community_type dotlrn_club \
+ -object_type dotlrn_club \
+ -community_key $section_key \
+ -pretty_name "$course_data(name): Section $section_name"]
+
+ ns_log notice "DEBUG:: New community created"
+ }
+
+ # HAM : Let's add chosen instructors in the role of instructors
+ # and assistants in the role of assistants
+ foreach instructor $instructors {
+ dotlrn_club::add_user -rel_type "dotlrn_admin_rel" -community_id $community_id -user_id $instructor -member_state "approved"
+ }
+ foreach assistant $assistants {
+ dotlrn_club::add_user -rel_type "dotlrn_club_instructor_rel" -community_id $community_id -user_id $assistant -member_state "approved"
+ }
+
+
+ # add the calendar item type "session"
+ set calendar_id [dotlrn_calendar::get_group_calendar_id -community_id $community_id]
+ if { ! [db_0or1row session_type {
+ select item_type_id from cal_item_types where type='Session' and calendar_id = :calendar_id limit 1
+ }] } {
+ set item_type_id [calendar::item_type_new -calendar_id $calendar_id -type "Session"]
+ }
+
+
+ # create an ecommerce product
+ set product_id [db_nextval acs_object_id_seq]
+
+ set user_id [ad_conn user_id]
+ set context_id [ad_conn package_id]
+ set product_name "$section_name"
+ set sku ""
+ set one_line_description "$section_name"
+ set detailed_description ""
+ set search_keywords ""
+ set present_p "t"
+ set stock_status ""
+ # let's have dirname be the first four letters (lowercase) of the product_name
+ # followed by the product_id (for uniqueness)
+ regsub -all {[^a-zA-Z]} $product_name "" letters_in_product_name
+ set letters_in_product_name [string tolower $letters_in_product_name]
+ if [catch {set dirname "[string range $letters_in_product_name 0 3]$product_id"}] {
+ #maybe there aren't 4 letters in the product name
+ set dirname "$letters_in_product_name$product_id"
+ }
+ set color_list ""
+ set size_list ""
+ set peeraddr [ad_conn peeraddr]
+ set product_id [db_exec_plsql product_insert {
+ select ec_product__new(
+ :product_id,
+ :user_id,
+ :context_id,
+ :product_name,
+ :price,
+ :sku,
+ :one_line_description,
+ :detailed_description,
+ :search_keywords,
+ :present_p,
+ :stock_status,
+ :dirname,
+ to_date(now(), 'YYYY-MM-DD'),
+ :color_list,
+ :size_list,
+ :peeraddr
+ )
+ }]
+
+ db_dml product_update {
+ update ec_products
+ set active_p = 't', no_shipping_avail_p = 't'
+ where product_id = :product_id
+ }
+ # take care of custom fields
+ # we have to generate audit information
+ set audit_fields "last_modified, last_modifying_user, modified_ip_address"
+ set audit_info "now(), :user_id, :peeraddr"
+
+ # things to insert into ec_custom_product_field_values if they exist
+ set custom_columns_to_insert [list product_id]
+ set custom_column_values_to_insert [list ":product_id"]
+ set bind_set [ns_set create]
+ ns_set put $bind_set product_id $product_id
+ ns_set put $bind_set user_id $user_id
+ ns_set put $bind_set peeraddr $peeraddr
+
+ db_foreach custom_columns_select {
+ select field_identifier, column_type
+ from ec_custom_product_fields
+ where active_p='t'
+ } {
+ if {[info exists $field_identifier] } {
+ lappend custom_columns_to_insert $field_identifier
+ lappend custom_column_values_to_insert ":$field_identifier"
+ if {[string equal $column_type date] || [string equal $column_type timestamp]} {
+ set one_date [template::util::date::get_property linear_date_no_time [subst $$field_identifier]]
+ ns_set put $bind_set $field_identifier $one_date
+ } else {
+ ns_set put $bind_set $field_identifier [subst $$field_identifier]
+ }
+ }
+ }
+ db_dml custom_fields_insert "
+ insert into ec_custom_product_field_values
+ ([join $custom_columns_to_insert ", "], $audit_fields)
+ values
+ ([join $custom_column_values_to_insert ","], $audit_info)
+ " -bind $bind_set
+
+ #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} {
+
+ # HAM : FIXME
+
+ # not sure if these values are correct
+ # comment out when properly tested
+
+ set sale_price_id [db_nextval ec_sale_price_id_sequence]
+ set sale_price $member_price
+ set offer_code ""
+
+ db_dml sale_insert "
+ insert into ec_sale_prices
+ (sale_price_id, product_id, sale_price, sale_begins, sale_ends, sale_name, offer_code, last_modified, last_modifying_user, modified_ip_address)
+ values
+ (:sale_price_id, :product_id, :sale_price, to_date(now() - '1 day':: interval,'YYYY-MM-DD HH24:MI:SS'), to_date(now() + '99 years':: interval,'YYYY-MM-DD HH24:MI:SS'), 'MemberPrice', :offer_code, now(), :user_id, :peeraddr)"
+ }
+
+ #CM: We should probably add ecomerce_product_id to ecommerce_Section and insert it here.
+
+ # Use item_id as course_id coz course_id is the revision and
+ # its easier to keep track of the item_id
+ db_dml add_section {
+ insert into dotlrn_ecommerce_section(section_id, course_id, section_name, community_id,product_id) values
+ (:section_id, :item_id, :section_name, :community_id, :product_id)
+ }
+
+ # for this to work, dotlrn_eccomerce_section must be an object
+ # just use community_id DAVEB
+ # where do the terms options come from?! DAVEB
+
+ category::map_object -object_id $community_id $categories
+
+ # Map patron relationships
+ set tree_id [parameter::get -package_id [ad_conn package_id] -parameter PatronRelationshipCategoryTree -default 0]
+ category_tree::map -tree_id $tree_id -object_id $community_id
+
+ }
+
+ # HAM : let's now add a "Section Administration" portlet for this new section
+ set admin_portal_id [dotlrn_community::get_admin_portal_id -community_id $community_id]
+ set element_id [dotlrn_ecommerce_admin_portlet::add_self_to_page -portal_id $admin_portal_id -package_id $package_id]
+ ns_log Notice "DEBUG : Added Admin Portal $element_id"
+ # we want the section admin portlet to be at the top
+ db_dml "bring_portlet_to_top" "update portal_element_map set sort_key=0, region=1 where element_id=:element_id"
+
+
+ if { [info exists calendar_id] } {
+ # Set predefined categories
+ # Unfortunately this seems to hang when inside the transaction
+ foreach s $sessions_list {
+ array set session $s
+ template::util::array_to_vars session
+
+ if { [lsearch $sessions $cal_item_id] != -1 } {
+ set date [set $cal_item_id]
+ set date [split $date "-"]
+ lappend date "" "" "" "YYYY MM DD"
+
+ set start_time [set ${cal_item_id}_start_time]
+ set end_time [set ${cal_item_id}_end_time]
+ set start_date [calendar::to_sql_datetime -date $date -time $start_time -time_p 1]
+ set end_date [calendar::to_sql_datetime -date $date -time $end_time -time_p 1]
+
+ set cal_item_id [calendar::item::new \
+ -start_date $start_date \
+ -end_date $end_date \
+ -name $session_name \
+ -description "$session_description" \
+ -calendar_id $calendar_id \
+ -item_type_id $item_type_id]
+ }
+ }
+ }
+
+} -edit_data {
+
+ if { $categories == [list [list $community_id $package_id]] } {
+ set categories ""
+ }
+
+ db_transaction {
+ db_dml update_section {
+ update dotlrn_ecommerce_section set
+ section_name = :section_name
+ where section_id = :section_id
+ }
+
+ # Change the community's name
+ dotlrn_community::set_community_name \
+ -community_id $community_id \
+ -pretty_name $section_name
+
+ # Update price
+ db_dml update_price {
+ update ec_products set price = :price where product_id = :product_id
+ }
+
+ # things to insert into ec_custom_product_field_values if they exist
+ set user_id [ad_conn user_id]
+ set peeraddr [ad_conn peeraddr]
+ set custom_columns_to_insert [list product_id]
+ set custom_column_values_to_insert [list ":product_id"]
+ set bind_set [ns_set create]
+ ns_set put $bind_set product_id $product_id
+ ns_set put $bind_set user_id $user_id
+ ns_set put $bind_set peeraddr $peeraddr
+
+ db_foreach custom_columns_select {
+ select field_identifier, column_type
+ from ec_custom_product_fields
+ where active_p='t'
+ } {
+ if {[info exists $field_identifier] } {
+ lappend custom_columns_to_update "$field_identifier = :$field_identifier"
+ if {[string equal $column_type date] || [string equal $column_type timestamp]} {
+ set one_date [template::util::date::get_property linear_date_no_time [subst $$field_identifier]]
+ ns_set put $bind_set $field_identifier $one_date
+ } else {
+ ns_set put $bind_set $field_identifier [subst $$field_identifier]
+ }
+ }
+ }
+ db_dml custom_fields_insert "
+ update ec_custom_product_field_values set [join $custom_columns_to_update ,] where product_id = :product_id
+ " -bind $bind_set
+
+ category::map_object -remove_old -object_id $community_id $categories
+
+ # Set instructors
+ set original_instructors [db_list instructors {
+ select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :community_id
+ and rel_type = 'dotlrn_admin_rel'
+ and user_id in (select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :instructor_community_id)
+ }]
+
+ set original_assistants [db_list assistants {
+ select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :community_id
+ and rel_type = 'dotlrn_club_instructor_rel'
+ and user_id in (select user_id
+ from dotlrn_member_rels_approved
+ where community_id = :assistant_community_id)
+ }]
+
+ # Remove unwanted instructors and assistants from community
+ foreach instructor $original_instructors {
+ if { [lsearch $instructors $instructor] == -1 } {
+ catch {dotlrn_community::remove_user $community_id $instructor}
+ }
+ }
+
+ foreach assistant $original_assistants {
+ if { [lsearch $assistants $assistant] == -1 } {
+ catch {dotlrn_community::remove_user $community_id $assistant}
+ }
+ }
+
+ # Add new instructors and assistants
+ foreach instructor $instructors {
+ if { [lsearch $original_instructors $instructor] == -1 } {
+ catch {dotlrn_community::add_user -rel_type dotlrn_admin_rel $community_id $instructor}
+ }
+ }
+
+ foreach assistant $assistants {
+ if { [lsearch $original_assistants $assistant] == -1 } {
+ catch {dotlrn_community::add_user -rel_type dotlrn_club_instructor_rel $community_id $assistant}
+ }
+ }
+
+ # 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 { [db_0or1row sale_price {
+ select sale_price
+ from ec_sale_prices
+ where product_id = :product_id
+ limit 1
+ }] } {
+ db_dml set_member_price {
+ update ec_sale_prices
+ set sale_price = :member_price
+ where product_id = :product_id
+ }
+ } else {
+ set sale_price_id [db_nextval ec_sale_price_id_sequence]
+ set sale_price $member_price
+ set offer_code ""
+
+ db_dml sale_insert "
+ insert into ec_sale_prices
+ (sale_price_id, product_id, sale_price, sale_begins, sale_ends, sale_name, offer_code, last_modified, last_modifying_user, modified_ip_address)
+ values
+ (:sale_price_id, :product_id, :sale_price, to_date(now() - '1 day':: interval,'YYYY-MM-DD HH24:MI:SS'), to_date(now() + '99 years':: interval,'YYYY-MM-DD HH24:MI:SS'), 'MemberPrice', :offer_code, now(), :user_id, :peeraddr)"
+ }
+ }
+
+ set calendar_id [dotlrn_calendar::get_group_calendar_id -community_id $community_id]
+ set item_type_id [db_string item_type_id "select item_type_id from cal_item_types where type='Session' and calendar_id = :calendar_id"]
+
+ foreach s $sessions_list {
+ array set session $s
+ template::util::array_to_vars session
+
+ if { [lsearch $sessions $cal_item_id] != -1 } {
+ set date [set $cal_item_id]
+ set date [split $date "-"]
+ lappend date "" "" "" "YYYY MM DD"
+
+ set start_time [set ${cal_item_id}_start_time]
+ set end_time [set ${cal_item_id}_end_time]
+ set start_date [calendar::to_sql_datetime -date $date -time $start_time -time_p 1]
+ set end_date [calendar::to_sql_datetime -date $date -time $end_time -time_p 1]
+
+ set cal_item_id [calendar::item::new \
+ -start_date $start_date \
+ -end_date $end_date \
+ -name $session_name \
+ -description "$session_description" \
+ -calendar_id $calendar_id \
+ -item_type_id $item_type_id]
+ }
+ }
+
+ dotlrn_ecommerce::section::flush_cache $section_id
+ }
+} -after_submit {
+ if {![info exists return_url] || [empty_string_p $return_url]} {
+ set return_url "one-section?section_id=$section_id"
+ }
+
+ ad_returnredirect $return_url
+}
+
+
+
+# Used by en_US version of new_class_instance message
+set class_instances_pretty_name [parameter::get -localize -parameter class_instances_pretty_name]
Index: openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.adp,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.adp 31 May 2005 22:04:53 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/lib/tree-chunk.adp 19 Jun 2005 06:05:06 -0000 1.2
@@ -1,5 +1,3 @@
-
-