Index: openacs-4/packages/calendar/tcl/cal-item-2-procs-oracle.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/cal-item-2-procs-oracle.xql,v diff -u -N -r1.4 -r1.5 --- openacs-4/packages/calendar/tcl/cal-item-2-procs-oracle.xql 22 Jul 2002 21:46:19 -0000 1.4 +++ openacs-4/packages/calendar/tcl/cal-item-2-procs-oracle.xql 13 Aug 2002 22:06:38 -0000 1.5 @@ -3,6 +3,18 @@ oracle8.1.6 + + + + select CASE WHEN (to_date(:start_date,:date_format) - to_date(:end_date,:date_format)) < 0 + THEN 1 + ELSE -1 + END + from dual + + + + Index: openacs-4/packages/calendar/tcl/cal-item-2-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/cal-item-2-procs-postgresql.xql,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/calendar/tcl/cal-item-2-procs-postgresql.xql 26 Jul 2002 03:20:28 -0000 1.3 +++ openacs-4/packages/calendar/tcl/cal-item-2-procs-postgresql.xql 13 Aug 2002 22:06:38 -0000 1.4 @@ -3,6 +3,15 @@ postgresql7.1 + + + select CASE WHEN (:start_date::timestamp - :end_date::timestamp) < 0 + THEN 1 + ELSE -1 + END + + + select Index: openacs-4/packages/calendar/tcl/cal-item-2-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/cal-item-2-procs.tcl,v diff -u -N -r1.3 -r1.4 --- openacs-4/packages/calendar/tcl/cal-item-2-procs.tcl 22 Jul 2002 21:46:19 -0000 1.3 +++ openacs-4/packages/calendar/tcl/cal-item-2-procs.tcl 13 Aug 2002 22:06:38 -0000 1.4 @@ -9,6 +9,24 @@ namespace eval calendar::item { + ad_proc -private dates_valid_p { + {-start_date:required} + {-end_date:required} + } { + A sanity check that the start time is before the end time. + } { + # set the date_format for oracle - from cal_item_create + set date_format "YYYY-MM-DD HH24:MI" + + set dates_valid_p [db_string dates_valid_p_select {}] + + if {[string equal $dates_valid_p 1]} { + return 1 + } else { + return 0 + } + } + ad_proc -public new { {-start_date:required} {-end_date:required} @@ -17,8 +35,16 @@ {-calendar_id:required} {-item_type_id ""} } { - # For now we call the old nasty version - return [cal_item_create $start_date $end_date $name $description $calendar_id [ad_conn peeraddr] [ad_conn user_id] $item_type_id] + # if the dates are invalid, don't create the item + if {[dates_valid_p -start_date $start_date -end_date $end_date]} { + # For now we call the old nasty version + return [cal_item_create $start_date $end_date $name $description $calendar_id [ad_conn peeraddr] [ad_conn user_id] $item_type_id] + } else { + # FIXME: do this better + ad_return_complaint 1 "Start Time must be before End Time" + ad_script_abort + } + } ad_proc -public get { Index: openacs-4/packages/calendar/www/cal-item-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-new.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/calendar/www/cal-item-new.tcl 3 Jun 2002 04:08:17 -0000 1.1 +++ openacs-4/packages/calendar/www/cal-item-new.tcl 13 Aug 2002 22:06:38 -0000 1.2 @@ -68,7 +68,7 @@ # Set up the datetimes set start_date [calendar::to_sql_datetime -date $date -time $start_time -time_p $time_p] set end_date [calendar::to_sql_datetime -date $date -time $end_time -time_p $time_p] - + set cal_item_id [calendar::item::new -start_date $start_date \ -end_date $end_date \ -name $title \