Index: openacs-4/packages/calendar/calendar.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/calendar.info,v diff -u -r1.10 -r1.11 --- openacs-4/packages/calendar/calendar.info 16 Mar 2002 21:06:44 -0000 1.10 +++ openacs-4/packages/calendar/calendar.info 3 Jun 2002 04:08:17 -0000 1.11 @@ -37,6 +37,8 @@ + + @@ -48,8 +50,10 @@ + + @@ -62,8 +66,6 @@ - - @@ -90,9 +92,20 @@ + + + + + + + + + + + @@ -101,8 +114,6 @@ - - @@ -115,14 +126,20 @@ + + + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar/tcl/cal-item-2-procs-oracle.xql 3 Jun 2002 04:08:17 -0000 1.1 @@ -0,0 +1,36 @@ + + + + oracle8.1.6 + + + + + select + cal_items.cal_item_id, + to_char(start_date,'HH:MIpm')as start_time, + start_date as start_date, + to_char(start_date, 'MM/DD/YYYY') as pretty_short_start_date, + to_char(end_date, 'HH:MIpm') as end_time, + nvl(e.name, a.name) as name, + nvl(e.description, a.description) as description, + recurrence_id, + cal_items.item_type_id, + cal_item_types.type as item_type, + on_which_calendar as calendar_id + from acs_activities a, + acs_events e, + timespans s, + time_intervals t, + cal_items, + cal_item_types + 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 = :cal_item_id + and cal_items.cal_item_id= :cal_item_id + and cal_item_types.item_type_id(+)= cal_items.item_type_id + + + + 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar/tcl/cal-item-2-procs.tcl 3 Jun 2002 04:08:17 -0000 1.1 @@ -0,0 +1,57 @@ + +ad_library { + A beginning of an attempt to rewrite calendar by making + procs cleaner, etc... (ben) + + @author Ben Adida (ben@openforce) + @creation-date 2002-06-02 +} + +namespace eval calendar::item { + + ad_proc -public new { + {-start_date:required} + {-end_date:required} + {-name:required} + {-description:required} + {-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] + } + + ad_proc -public get { + {-cal_item_id:required} + {-array:required} + } { + Get the data for a calendar item + } { + upvar $array row + + db_1row select_item_data {} -column_array row + } + + ad_proc -public edit { + {-cal_item_id:required} + {-start_date:required} + {-end_date:required} + {-name:required} + {-description:required} + {-item_type_id ""} + {-edit_all_p 0} + } { + Edit the item + } { + cal_item_update $cal_item_id $start_date $end_date $name $description $item_type_id $edit_all_p + } + + ad_proc -public delete { + {-cal_item_id:required} + } { + delete the item + } { + cal_item_delete $cal_item_id + } + +} Index: openacs-4/packages/calendar/tcl/cal-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/cal-item-procs.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/calendar/tcl/cal-item-procs.tcl 14 May 2002 05:06:29 -0000 1.8 +++ openacs-4/packages/calendar/tcl/cal-item-procs.tcl 3 Jun 2002 04:08:17 -0000 1.9 @@ -239,9 +239,8 @@ # set the date_format set date_format "YYYY-MM-DD HH24:MI" - # first update the acs_activities - - db_dml update_activity "" + # update the events + db_dml update_event "" # update the time interval based on the timespan id @@ -319,7 +318,8 @@ db_exec_plsql recurrence_timespan_update {} # Update the activities table - db_dml recurrence_activities_update {} + # We shouldn't update activities, I don't think + # db_dml recurrence_activities_update {} # Update the events table db_dml recurrence_events_update {} Index: openacs-4/packages/calendar/tcl/cal-item-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/cal-item-procs.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/calendar/tcl/cal-item-procs.xql 14 May 2002 05:06:29 -0000 1.4 +++ openacs-4/packages/calendar/tcl/cal-item-procs.xql 3 Jun 2002 04:08:17 -0000 1.5 @@ -32,6 +32,15 @@ + + + update acs_events + set name = :name, + description = :description + where event_id= :cal_item_id + + + select interval_id Index: openacs-4/packages/calendar/tcl/calendar-2-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/calendar-2-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/calendar/tcl/calendar-2-procs.tcl 16 Mar 2002 21:09:34 -0000 1.1 +++ openacs-4/packages/calendar/tcl/calendar-2-procs.tcl 3 Jun 2002 04:08:17 -0000 1.2 @@ -9,6 +9,143 @@ namespace eval calendar { + ad_proc -public from_sql_datetime { + {-sql_date:required} + {-format:required} + } { + # for now, we recognize only "YYYY-MM-DD" "HH12:MIam" and "HH24:MI" + + set date [template::util::date::create] + + switch -exact -- $format { + {YYYY-MM-DD} { + regexp {([0-9]*)-([0-9]*)-([0-9]*)} $sql_date all year month day + + set date [template::util::date::set_property format $date {DD MONTH YYYY}] + set date [template::util::date::set_property year $date $year] + set date [template::util::date::set_property month $date $month] + set date [template::util::date::set_property day $date $day] + } + + {HH12:MIam} { + regexp {([0-9]*):([0-9]*) *([aApP][mM])} $sql_date all hours minutes ampm + + set date [template::util::date::set_property format $date {HH12:MI am}] + set date [template::util::date::set_property hours $date $hours] + set date [template::util::date::set_property minutes $date $minutes] + set date [template::util::date::set_property ampm $date [string tolower $ampm]] + } + + {HH24:MI} { + regexp {([0-9]*):([0-9]*)} $sql_date all hours minutes + + set date [template::util::date::set_property format $date {HH24:MI}] + set date [template::util::date::set_property hours $date $hours] + set date [template::util::date::set_property minutes $date $minutes] + } + + {HH24} { + set date [template::util::date::set_property format $date {HH24:MI}] + set date [template::util::date::set_property hours $date $sql_date] + set date [template::util::date::set_property minutes $date 0] + } + } + + return $date + } + + ad_proc -public to_sql_datetime { + {-date:required} + {-time:required} + {-time_p 1} + } { + This takes two date chunks, one for date one for time, + and combines them correctly. + + The issue here is the incoming format. + date: ANSI SQL YYYY-MM-DD + time: we return HH24. + } { + # Set the time to 0 if necessary + if {!$time_p} { + set hours 0 + set minutes 0 + } else { + set hours [template::util::date::get_property hours $time] + set minutes [template::util::date::get_property minutes $time] + } + + set year [template::util::date::get_property year $date] + set month [template::util::date::get_property month $date] + set day [template::util::date::get_property day $date] + + # put together the timestamp + return "$year-$month-$day $hours:$minutes" + } + + ad_proc -public calendar_list { + {-package_id ""} + {-user_id ""} + } { + return [adjust_calendar_list -calendar_list "" -package_id $package_id -user_id $user_id] + } + + ad_proc -public adjust_calendar_list { + {-calendar_list:required} + {-package_id ""} + {-user_id ""} + } { + # If no user_id + if {[empty_string_p $user_id]} { + set user_id [ad_conn user_id] + } + + if {[empty_string_p $package_id]} { + set package_id [ad_conn package_id] + } + + if {[string compare $calendar_list {{}}] == 0} { + set calendar_list [list] + } + + if {[llength $calendar_list] > 0} { + set sql_clause "and calendar_id in ([join $calendar_list ","]) " + } else { + set sql_clause "" + } + + set new_list [db_list select_calendar_list {}] + } + + ad_proc -public adjust_date { + {-date ""} + {-julian_date ""} + } { + if {[empty_string_p $date]} { + if {![empty_string_p $julian_date]} { + set date [dt_julian_to_ansi $julian_date] + } else { + set date [dt_sysdate] + } + } + + return $date + } + + ad_proc -public new { + {-owner_id:required} + {-private_p "f"} + {-calendar_name:required} + {-package_id:required} + } { + set extra_vars [ns_set create] + oacs_util::vars_to_ns_set -ns_set $extra_vars -var_list {owner_id private_p calendar_name package_id} + + set calendar_id [package_instantiate_object -extra_vars $extra_vars calendar] + + return $calendar_id + } + ad_proc -public get_item_types { {-calendar_id:required} } { Index: openacs-4/packages/calendar/tcl/calendar-2-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/tcl/Attic/calendar-2-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/calendar/tcl/calendar-2-procs.xql 16 Mar 2002 21:11:36 -0000 1.1 +++ openacs-4/packages/calendar/tcl/calendar-2-procs.xql 3 Jun 2002 04:08:17 -0000 1.2 @@ -1,6 +1,14 @@ + + +select calendar_id from calendars +where package_id= :package_id +$sql_clause + + + select item_type_id, type from cal_item_types Index: openacs-4/packages/calendar/www/cal-item-create-recurrence.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-create-recurrence.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/calendar/www/cal-item-create-recurrence.adp 21 Mar 2002 16:57:16 -0000 1.4 +++ openacs-4/packages/calendar/www/cal-item-create-recurrence.adp 3 Jun 2002 04:08:17 -0000 1.5 @@ -9,7 +9,7 @@ Calendars: Recurrence - +Add Recurrence You are choosing to make this event recurrent, so that it appears more than once in your calendar. The event's details are: Index: openacs-4/packages/calendar/www/cal-item-delete-confirm.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-delete-confirm.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/calendar/www/cal-item-delete-confirm.adp 10 May 2002 20:27:17 -0000 1.3 +++ openacs-4/packages/calendar/www/cal-item-delete-confirm.adp 3 Jun 2002 04:08:17 -0000 1.4 @@ -16,32 +16,32 @@

- + @cal_nav@ - +
@item_data.description@
Date and Time:@item_data.start_date@, from @item_data.start_time@ to @item_data.end_time@
Title:@item_data.name@
Type:@item_data.item_type@
Type:@item_data.item_type@

- - - - This is a repeating event. You may choose to:

Are you sure you want to delete this event? + + + + Index: openacs-4/packages/calendar/www/cal-item-delete-confirm.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-delete-confirm.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/calendar/www/cal-item-delete-confirm.tcl 29 Apr 2002 15:21:59 -0000 1.2 +++ openacs-4/packages/calendar/www/cal-item-delete-confirm.tcl 3 Jun 2002 04:08:17 -0000 1.3 @@ -54,4 +54,6 @@ # no time? set item_data(no_time_p) [dt_no_time_p -start_time $start_time -end_time $end_time] +set cal_nav [dt_widget_calendar_navigation "view" day $raw_start_date "calendar_id"] + ad_return_template Index: openacs-4/packages/calendar/www/cal-item-delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar/www/cal-item-delete.tcl 3 Jun 2002 04:08:17 -0000 1.1 @@ -0,0 +1,20 @@ + +ad_page_contract { + Delete a calendar item + + @author Ben Adida (ben@openforce) + @creation-date 2002-06-02 +} { + cal_item_id:integer,notnull + {return_url "view"} + {confirm_p 0} +} + +if {!$confirm_p} { + ad_returnredirect "cal-item-delete-confirm?cal_item_id=$cal_item_id" + return +} + +calendar::item::delete -cal_item_id $cal_item_id + +ad_returnredirect $return_url Index: openacs-4/packages/calendar/www/cal-item-edit.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-item-edit.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar/www/cal-item-edit.adp 3 Jun 2002 04:08:17 -0000 1.1 @@ -0,0 +1,22 @@ + +Calendar: Edit Item +Edit + + + + + + + + +
+

+ @cal_nav@ +

+ +

+ + + +
+ Index: openacs-4/packages/calendar/www/cal-item-edit.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-item-edit.tcl,v diff -u -r1.10 -r1.11 --- openacs-4/packages/calendar/www/cal-item-edit.tcl 14 May 2002 05:06:29 -0000 1.10 +++ openacs-4/packages/calendar/www/cal-item-edit.tcl 3 Jun 2002 04:08:17 -0000 1.11 @@ -3,88 +3,98 @@ ad_page_contract { edit an existing calendar item - - @author Gary Jin (gjin@arsdigita.com) - @creation-date Dec 14, 2000 + (totally rewritten, this was nasty) + + @author Ben Adida (ben@openforce) + @creation-date 2002-06-02 @cvs-id $Id$ } { - {cal_item_id:integer} - {view day} - {action edit} - {no_time_p ""} - {event_date:array ""} - {start_time:array ""} - {end_time:array ""} - {name ""} - {description ""} - {return_url ""} - {item_type_id ""} - {confirm_p 0} - {edit_all_p 0} + cal_item_id:integer,notnull } -# Fix up the return URL -if {[empty_string_p $return_url]} { - set return_url "?[export_url_vars date view]" -} +# Permissions +# FIXME: we need to add a permissions check here! -# find out the user_id -set user_id [ad_verify_and_get_user_id] +# Create the form +form create cal_item +element create cal_item cal_item_id \ + -label "Calendar Item ID" -datatype integer -widget hidden -value $cal_item_id -#------------------------------------------------------ -# if the action is set to delete -# we call the delete proc and return to -# to index with the passed through options +element create cal_item title \ + -label "Title" -datatype text -widget text -html {size 60} -if { $action == "delete" } { +element create cal_item date \ + -label "Date" -datatype date -widget date - if {!$confirm_p} { - ad_returnredirect "cal-item-delete-confirm?cal_item_id=$cal_item_id&show_cal_nav=0" - return - } - - cal_item_delete $cal_item_id +element create cal_item time_p \ + -label " " -datatype text -widget radio -options {{{All Day Event} 0} {{Use Hours Below:} 1}} - ad_returnredirect $return_url +element create cal_item start_time \ + -label "Start Time" -datatype date -widget date -format "HH12:MI AM" - return -} +element create cal_item end_time \ + -label "End Time" -datatype date -widget date -format "HH12:MI AM" -#------------------------------------------------------ -# extract the time info +element create cal_item description \ + -label "Description" -datatype text -widget textarea -html {cols 60 rows 3 wrap soft} -if {$no_time_p == 1} { - set no_time(hours) 0 - set no_time(minutes) 0 - set start_datetime [calendar_make_datetime [array get event_date] [array get no_time]] - set end_datetime [calendar_make_datetime [array get event_date] [array get no_time]] -} else { - set start_datetime [calendar_make_datetime [array get event_date] [array get start_time]] - set end_datetime [calendar_make_datetime [array get event_date] [array get end_time]] +element create cal_item item_type_id \ + -label "Type" -datatype integer -widget select -optional + +element create cal_item repeat_p \ + -label "Edit All Occurrences?" -datatype text -widget radio -options {{Yes 1} {No 0}} -value 0 + + +if {[form is_valid cal_item]} { + template::form get_values cal_item cal_item_id title date time_p start_time end_time description item_type_id repeat_p + + # 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] + + ns_log Notice "BMA3: $repeat_p" + + # Do the edit + calendar::item::edit -cal_item_id $cal_item_id \ + -start_date $start_date \ + -end_date $end_date \ + -name $title \ + -description $description \ + -item_type_id $item_type_id \ + -edit_all_p $repeat_p + + # Redirect + ad_returnredirect "cal-item-view?cal_item_id=$cal_item_id" + ad_script_abort } +# Select info for the item +calendar::item::get -cal_item_id $cal_item_id -array cal_item -#----------------------------------------------------------------- -# validate time interval ( start_time <= end_time ) +# Prepare the form nicely +element set_properties cal_item item_type_id -options [calendar::get_item_types -calendar_id $cal_item(calendar_id)] -if { [dt_interval_check $start_datetime $end_datetime] < 0 } { - ad_return_complaint 1 "your end time can't happen before start time" +element set_properties cal_item cal_item_id -value $cal_item(cal_item_id) +element set_properties cal_item title -value $cal_item(name) +element set_properties cal_item date -value [calendar::from_sql_datetime -sql_date $cal_item(start_date) -format {YYYY-MM-DD}] +element set_properties cal_item start_time -value [calendar::from_sql_datetime -sql_date $cal_item(start_time) -format {HH12:MIam}] +element set_properties cal_item end_time -value [calendar::from_sql_datetime -sql_date $cal_item(end_time) -format {HH12:MIam}] +element set_properties cal_item description -value $cal_item(description) +element set_properties cal_item item_type_id -value $cal_item(item_type_id) + +if {[dt_no_time_p -start_time $cal_item(start_time) -end_time $cal_item(end_time)]} { + element set_properties cal_item time_p -value 0 +} else { + element set_properties cal_item time_p -value 1 } +# if no recurrence, don't show the repeat stuff +if {[empty_string_p $cal_item(recurrence_id)]} { + element set_properties cal_item repeat_p -widget hidden +} -#------------------------------------------------------------------ -# update the exsiting calendar_item -set cal_item_id [cal_item_update $cal_item_id \ - $start_datetime \ - $end_datetime \ - $name \ - $description \ - $item_type_id \ - $edit_all_p] +set cal_nav [dt_widget_calendar_navigation "view" day $cal_item(start_date) "calendar_id"] -# set the proper rediret value to view and date -set action "view" -set date [calendar_make_date [array get event_date]] +ad_return_template -ad_returnredirect $return_url Index: openacs-4/packages/calendar/www/cal-item-new.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-new.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar/www/cal-item-new.adp 3 Jun 2002 04:08:17 -0000 1.1 @@ -0,0 +1,22 @@ + +Calendar: Add Item +Add + + + + + + + + +
+

+ @cal_nav@ +

+ +

+ + + +
+ 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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar/www/cal-item-new.tcl 3 Jun 2002 04:08:17 -0000 1.1 @@ -0,0 +1,112 @@ + +ad_page_contract { + + Creating a new Calendar Item + + @author Ben Adida (ben@openforce) + @creation-date May 29, 2002 + @cvs-id $Id: cal-item-new.tcl,v 1.1 2002/06/03 04:08:17 ben Exp $ +} { + {calendar_id ""} + {date ""} + {julian_date ""} + {start_time ""} + {end_time ""} +} + +set package_id [ad_conn package_id] + +set date [calendar::adjust_date -date $date -julian_date $julian_date] + +if {[empty_string_p $calendar_id]} { + set calendar_list [calendar::calendar_list] + + if {[llength $calendar_list] > 1} { + set return_url [ns_urlencode "cal-item-new?date=$date&start_time=$start_time&end_time=$end_time"] + ad_returnredirect "calendar-choose?return_url=$return_url" + ad_script_abort + } + + set calendar_id [lindex $calendar_list 0] +} + + +# Create the form +form create cal_item + +element create cal_item calendar_id \ + -label "Calendar ID" -datatype integer -widget hidden -value $calendar_id + +element create cal_item title \ + -label "Title" -datatype text -widget text -html {size 60} + +element create cal_item date \ + -label "Date" -datatype date -widget date + +element create cal_item time_p \ + -label " " -datatype text -widget radio -options {{{All Day Event} 0} {{Use Hours Below:} 1}} + +element create cal_item start_time \ + -label "Start Time" -datatype date -widget date -format "HH12:MI AM" -optional + +element create cal_item end_time \ + -label "End Time" -datatype date -widget date -format "HH12:MI AM" -optional + +element create cal_item description \ + -label "Description" -datatype text -widget textarea -html {cols 60 rows 3 wrap soft} + +element create cal_item item_type_id \ + -label "Type" -datatype integer -widget select -options [calendar::get_item_types -calendar_id $calendar_id] -optional + +element create cal_item repeat_p \ + -label "Repeat?" -datatype text -widget radio -options {{Yes 1} {No 0}} -value 0 + +# Process the form +if {[form is_valid cal_item]} { + template::form get_values cal_item calendar_id title date time_p start_time end_time description item_type_id repeat_p + + # 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 \ + -description $description \ + -calendar_id $calendar_id \ + -item_type_id $item_type_id] + + # If repeat_p, go to repetition page + if {$repeat_p} { + ad_returnredirect "cal-item-create-recurrence?cal_item_id=$cal_item_id" + } else { + ad_returnredirect "cal-item-view?cal_item_id=$cal_item_id" + } + + # Stop here + ad_script_abort +} + +# Set some properties +element set_properties cal_item date -value [calendar::from_sql_datetime -sql_date $date -format "YYYY-MM-DD"] + +if {[dt_no_time_p -start_time $start_time -end_time $end_time]} { + # No time event + element set_properties cal_item time_p -value 0 +} else { + if {![empty_string_p $start_time]} { + set start_time_date [calendar::from_sql_datetime -sql_date $start_time -format {HH24}] + element set_properties cal_item start_time -value $start_time_date + } + + if {![empty_string_p $end_time]} { + set end_time_date [calendar::from_sql_datetime -sql_date $end_time -format {HH24}] + element set_properties cal_item end_time -value $end_time_date + } + + element set_properties cal_item time_p -value 1 +} + +set cal_nav [dt_widget_calendar_navigation "view" day $date "calendar_id=$calendar_id"] + +ad_return_template Index: openacs-4/packages/calendar/www/cal-item-outlook.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-outlook.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar/www/cal-item-outlook.tcl 3 Jun 2002 04:08:17 -0000 1.1 @@ -0,0 +1,16 @@ +# /packages/calendar/www/cal-item.tcl + +ad_page_contract { + + Output an item as ics for Outlook + + @author Ben Adida (ben@openforce) + @creation-date May 28, 2002 + @cvs-id $Id: cal-item-outlook.tcl,v 1.1 2002/06/03 04:08:17 ben Exp $ +} { + cal_item_id:integer +} + +set ics_stuff [calendar::outlook::format_item -cal_item_id $cal_item_id] + +ns_return 200 application/x-msoutlook $ics_stuff Index: openacs-4/packages/calendar/www/cal-item-view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-view.adp,v diff -u -r1.7 -r1.8 --- openacs-4/packages/calendar/www/cal-item-view.adp 10 May 2002 20:27:17 -0000 1.7 +++ openacs-4/packages/calendar/www/cal-item-view.adp 3 Jun 2002 04:08:17 -0000 1.8 @@ -8,26 +8,26 @@ -Calendar Item: @item_data.name@ +Calendar Item: @cal_item.name@ Item Index: openacs-4/packages/calendar/www/cal-item-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-item-view.tcl,v diff -u -r1.4 -r1.5 --- openacs-4/packages/calendar/www/cal-item-view.tcl 29 Apr 2002 15:21:59 -0000 1.4 +++ openacs-4/packages/calendar/www/cal-item-view.tcl 3 Jun 2002 04:08:17 -0000 1.5 @@ -26,43 +26,13 @@ # admin permission set admin_p [ad_permission_p $cal_item_id calendar_admin] -# Select information about the calendar item -if {![db_0or1row get_item_data { - select to_char(start_date,'HH:MIpm')as start_time, - start_date as raw_start_date, - to_char(start_date, 'MM/DD/YYYY') as start_date, - to_char(end_date, 'HH:MIpm') as end_time, - nvl(a. name, e.name) as name, - nvl(e.description, a.description) as description, - recurrence_id, - cal_item_types.type as item_type, - on_which_calendar as calendar_id - from acs_activities a, - acs_events e, - timespans s, - time_intervals t, - cal_items, - cal_item_types - 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 = :cal_item_id - and cal_items.cal_item_id= :cal_item_id - and cal_item_types.item_type_id(+)= cal_items.item_type_id -}]} { - ad_returnredirect "./" - return -} +calendar::item::get -cal_item_id $cal_item_id -array cal_item -set item_data(start_time) $start_time -set item_data(start_date) $start_date -set item_data(end_time) $end_time -set item_data(name) $name -set item_data(description) $description -set item_data(item_type) $item_type - # no time? -set item_data(no_time_p) [dt_no_time_p -start_time $start_time -end_time $end_time] +set cal_item(no_time_p) [dt_no_time_p -start_time $cal_item(start_time) -end_time $cal_item(end_time)] +# cal nav +set cal_nav [dt_widget_calendar_navigation "view" day $cal_item(start_date) "calendar_id="] + ad_return_template Index: openacs-4/packages/calendar/www/cal-item.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/Attic/cal-item.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/calendar/www/cal-item.tcl 26 Apr 2002 19:51:07 -0000 1.11 +++ openacs-4/packages/calendar/www/cal-item.tcl 3 Jun 2002 04:08:17 -0000 1.12 @@ -2,7 +2,7 @@ ad_page_contract { - Management of cal-items. Takes in the parameters for the adp pages. + Single calendar item view @author Gary Jin (gjin@arsdigita.com) @creation-date Dec 14, 2000 Index: openacs-4/packages/calendar/www/cal-options.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-options.adp,v diff -u -r1.2 -r1.3 --- openacs-4/packages/calendar/www/cal-options.adp 18 Feb 2002 15:14:56 -0000 1.2 +++ openacs-4/packages/calendar/www/cal-options.adp 3 Jun 2002 04:08:17 -0000 1.3 @@ -6,73 +6,11 @@ @creation-date Dec 14, 2000 @cvs-id $Id$ --> - -

- + @cal_nav@

- - - - + + + +
@description@
Date and Time:@item_data.start_date@, from @item_data.start_time@ to @item_data.end_time@
Title:@item_data.name@
Type:@item_data.item_type@
@cal_item.description@
Date and Time:@cal_item.pretty_short_start_date@, from @cal_item.start_time@ to @cal_item.end_time@
Title:@cal_item.name@
Type:@cal_item.item_type@

- edit | delete + edit | delete

- - - - - - - - - - - - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- Calendar Views: -
- No Other Calendars -
- - - - Private - -
- - - - @calendars.calendar_name@ - -
- -
- Manage Your Calendars -
+ +
    + +
  • @calendars.calendar_name@ + +
- - Index: openacs-4/packages/calendar/www/cal-options.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/cal-options.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/calendar/www/cal-options.tcl 18 Feb 2002 15:14:56 -0000 1.2 +++ openacs-4/packages/calendar/www/cal-options.tcl 3 Jun 2002 04:08:17 -0000 1.3 @@ -12,172 +12,25 @@ @calendar_id @calendar_list - @author Gary Jin (gjin@arsdigita.com) - @creation-date Dec 14, 2000 + @author Gary Jin (gjin@arsdigita.com), Ben Adida (ben@openforce) + @creation-date Dec 14, 2000, May 29th, 2002 @cvs-id $Id$ } { - {action ""} - {view day} - {date now} - {calendar_id:integer "-1"} - {calendar_list:multiple,optional {}} - -} -properties { - - private_id:onevalue - private_checked_p:onevalue - - date:onevalue - view:onevalue - - calendars:multirow - calendar_id_list:multirow - } # get a user_id set user_id [ad_verify_and_get_user_id] -# An abort of this if we're adding or editing an item, because this -# then becomes more confusing than anything (ben - OpenACS) -if {$action == "add" || $action == "edit"} { - set empty_p 1 - ad_return_template - return -} else { - set empty_p 0 -} +set calendar_list [calendar::calendar_list] -# get a list of the calendars that the user has read access to -# NOTE: this query would need to optimized. Its take a major -# performence hit when the system have a lot of objects (ie. -# 20000+ rows of geographical data) -# -# A possbile solution for a later release would be to query out -# only objects with acs_object_type of calendar or calendar events -# and then include that as a subquery on permissions (basically -# construct a calendar only version of the acs_object_party_privilege_map +set calendar_list_sql "[join $calendar_list ","]" -# select unique(object_id) as calendar_id, - # calendar.name(object_id) as calendar_name, - # ' ' as checked_p - # from acs_object_party_privilege_map - # where calendar.show_p(object_id, :user_id) = 't' - # and calendar.readable_p(object_id, :user_id) = 't' - # and party_id = :user_id - # and acs_object_util.object_type_p(object_id, 'calendar') = 't' - # and calendar.private_p(object_id) = 'f' +db_multirow calendars select_calendars " + select calendar_id, calendar_name + from calendars + where calendar_id in ($calendar_list_sql) +" - #union - -# select cal_item.on_which_calendar(object_id) as calendar_id, -# calendar.name(cal_item.on_which_calendar(object_id)) as calendar_name, -# ' ' as checked_p -# from acs_object_party_privilege_map -# where privilege = 'cal_item_read' -# and calendar.show_p(cal_item.on_which_calendar(object_id), :user_id) = 't' -# and party_id = :user_id -# and acs_object_util.object_type_p(object_id, 'cal_item') = 't' - # and calendar.private_p(cal_item.on_which_calendar(object_id)) = 'f' - - -db_multirow calendars get_readable_calendars { - - select unique(calendar_id) as calendar_id, - calendar_name, - ' ' as checked_p - from calendars - where acs_permission.permission_p(calendar_id, :user_id, 'calendar_read') = 't' - and acs_permission.permission_p(calendar_id, :user_id, 'calendar_show') = 't' - and private_p = 'f' - - union - - select unique(on_which_calendar) as calendar_id, - calendar.name(on_which_calendar) as calendar_name, - ' ' as checked_p - from cal_items - where acs_permission.permission_p(cal_item_id, :user_id, 'cal_item_read') = 't' - and calendar.private_p(on_which_calendar) = 'f' - - -} - - -#------------------------------------------------------------- - -# initialize the private marker -set private_checked_p "" - -# get a list of the calendar_id that's currently selected -# multirow method is going to be used to send the ids to -# the template. - - -if { [llength $calendar_list] == 0 } { - # in the case when a single calendar is selected (when a user - # clicked on the link as oppse to using the check box and hit - # the button, then the calendar_list will be empty and we - # use the calendar_id instead. - - # check for private calendar - # if not, then do the comparison - - if { [string equal $calendar_id "-1"] } { - set private_checked_p "checked" - - } else { - - # check the selected calendar - for {set i 1} {$i <= [multirow size calendars] } {incr i} { - if { [string equal [multirow get calendars $i calendar_id] $calendar_id] } { - multirow set calendars $i checked_p "checked" - } - } - - } - -} else { - - # we cross check the existing calendar_id - # with the id that from the selected list. - # if calendar_id are being selected, we - # set checked_p to "checked" - # - # this is quite ineifficent since i am looking - # the id through two loops. But which ever way - # i perform this cross check, i would have to - # cycle through all of the ids in one set to math - # with all the id in another set. - - - foreach items $calendar_list { - - # check for private calendar (when id = -1) - if { [string equal [lindex $items 0] "-1"] } { - set private_checked_p "checked" - } - - # checked the selected calendar - for {set i 1} {$i <= [multirow size calendars]} {incr i} { - - if { [string equal [multirow get calendars $i calendar_id] [lindex $items 0]] } { - multirow set calendars $i checked_p "checked" - } - } - - } - - -} - -return ad_return_template - - - - - - Index: openacs-4/packages/calendar/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/index.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/calendar/www/index.tcl 14 Mar 2002 04:58:29 -0000 1.6 +++ openacs-4/packages/calendar/www/index.tcl 3 Jun 2002 04:08:17 -0000 1.7 @@ -2,85 +2,13 @@ ad_page_contract { - Main Calendar Page. + Main Calendar Page + totally redone by Ben - @author Gary Jin (gjin@arsdigita.com) - @creation-date Dec 14, 2000 + @author Ben Adida (ben@openforce) + @creation-date June 2, 2002 @cvs-id $Id$ } { - {view day} - {action view} - {date ""} - {julian_date ""} - {calendar_list:multiple,optional {}} - {return_url ""} - {force_calendar_id ""} - {show_cal_nav 1} -} -properties { - package_id:onevalue - user_id:onevalue - name:onevalue - date:onevalue - view:onevalue } -if {[empty_string_p $date]} { - if {[empty_string_p $julian_date]} { - set date now - } else { - set date [db_string select_from_julian "select to_date(:julian_date ,'J') from dual"] - } -} - -# find out the user_id -set user_id [ad_verify_and_get_user_id] - -db_0or1row user_name_select { - select first_names || ' ' || last_name as name, email - from persons, parties - where person_id = :user_id - and person_id = party_id -} - -set package_id [ad_conn package_id] - - - -ad_return_template - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ad_returnredirect "view" Index: openacs-4/packages/calendar/www/view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/calendar/www/view.adp 29 May 2002 23:20:55 -0000 1.1 +++ openacs-4/packages/calendar/www/view.adp 3 Jun 2002 04:08:17 -0000 1.2 @@ -1,6 +1,6 @@ - + Calendars - +Calendar Index: openacs-4/packages/calendar/www/view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar/www/view.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/calendar/www/view.tcl 29 May 2002 23:20:55 -0000 1.1 +++ openacs-4/packages/calendar/www/view.tcl 3 Jun 2002 04:08:17 -0000 1.2 @@ -10,25 +10,21 @@ {view day} {date ""} {julian_date ""} - {calendar_list:multiple,optional {}} + {calendar_list:multiple ""} } set package_id [ad_conn package_id] +set user_id [ad_conn user_id] -if {[empty_string_p $date]} { - if {![empty_string_p $julian_date]} { - set date [dt_julian_to_ansi $julian_date] - } else { - set date [dt_sysdate] - } -} +set calendar_list [calendar::adjust_calendar_list -calendar_list $calendar_list -package_id $package_id -user_id $user_id] +set date [calendar::adjust_date -date $date -julian_date $julian_date] # Calendar ID list # Set up some template -set item_template "\$item" -set hour_template "\$hour" -set item_add_template "ADD" +set item_template "\$item" +set hour_template "\$hour" +set item_add_template "ADD" # Depending on the view, make a different widget if {$view == "day"} { @@ -45,7 +41,7 @@ if {$view == "week"} { set cal_stuff [calendar::one_week_display \ -item_template $item_template \ - -day_template "\$day - \$pretty_date     (Add Item)" \ + -day_template "\$day - \$pretty_date     (Add Item)" \ -date $date \ -calendar_id_list $calendar_list \ -prev_week_template "<" \ @@ -78,40 +74,3 @@ set cal_nav [dt_widget_calendar_navigation "view" $view $date "calendar_list="] ad_return_template - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -