caldav::CalDAV instproc GET (public)
<instance of caldav::CalDAV> GET
Defined in /var/www/openacs.org/packages/caldav/tcl/caldav-procs.tcl
GET calendar content in ical syntax. The method can either return an individual calendar item based on a cal_uid or a full calendar (may be an aggregated calendar) depending on the syntax of the URL. - individual cal_items (must end with .ics) /caldav/calendar/12872/12907.ics - complete calendar /caldav/calendar /caldav/calendar?calendar_ids=12872 /caldav/calendar/12872 where the "12872" is a calendar_id and "12907" is the UID of a calendar item.
- Testcases:
- GET
Source code: # the following getcontent call is just for consistent logging :getcontent # # set tail [lindex ${:urlv} end] set mimetype "text/calendar" set code 404 set resp "" :debug ":urlv [list ${:urlv}]" if {[file extension $tail] eq ".ics"} { # # Retrieve a single item identified by an UID # set uid [:get_uid_from_href ${:uri}] :debug "return single calendar item for uid $uid" # # We need the calendar_ids for consistent naming of # calendars (aggregated, etc.).... # if {[string is integer -strict [lindex ${:urlv} end-1]]} { set calendar_ids [lindex ${:urlv} end-1] } else { set calendar_ids "" } :calendar_ids $calendar_ids # # GN TODO: running two queries is not optimal but having # these separate eases type mismatch. # # cal_uids(cal_uid, on_which_activity references acs_activities(activity_id), ical_vars) # cal_items(cal_item_id references acs_events(event_id), on_which_calendar, ...) # acs_events(event_id, ..., activity_id references acs_activities(activity_id), ...) # set cal_items [::xo::dc list_of_lists -prepare varchar get_calitem { select e.event_id as cal_item_id, u.ical_vars, a.creation_date, a.last_modified from cal_uids u, acs_events e, acs_objects a where u.cal_uid = :uid and e.activity_id = u.on_which_activity and a.object_id = e.event_id limit 1 }] :debug "cal_items 1 (join on <$uid>): <$cal_items>" if {[llength $cal_items] == 0 && [string is integer -strict $uid]} { set cal_items [::xo::dc list_of_lists -prepare integer get_calitem { select e.event_id as cal_item_id, '' as ical_vars, a.creation_date, a.last_modified from acs_events e, acs_objects a where e.activity_id = :uid and a.object_id = e.event_id limit 1 }] } #:debug "cal_items 2: <$cal_items>" if {[llength $cal_items] == 1} { lassign [lindex $cal_items 0] cal_item_id ical_vars creation_date last_modified calendar::item::get -cal_item_id $cal_item_id -array c :debug "calendar::item::get -cal_item_id $cal_item_id->\n[array get c]" set vevent [calitem new -uid $uid -creation_date $creation_date -last_modified $last_modified -dtstart $c(start_date_ansi) -is_day_item [dt_no_time_p -start_time $c(start_date_ansi) -end_time $c(end_date_ansi)] -formatted_recurrences [calendars format_recurrence -recurrence_id $c(recurrence_id)] -dtend $c(end_date_ansi) -ical_vars $ical_vars -location $c(location) -summary $c(name) -description $c(description)] unset -nocomplain c append resp [$vevent as_ical_calendar -calendar_name [:calendarName]] $vevent destroy # GN TODO: do we need always the database to get an etag ? ns_set put [ns_conn outputheaders] ETag [subst {"[:getETagByUID $uid]"}] set code 200 } else { # # Nothing found or a weird result (multiple items). If # nothing is found, we have the error status code from # above. On too many results, raise an exception. # if {[llength $cal_items] > 1} { error "cal_item query based on cal_uid $uid lead to multiple results [llength $cal_items]" } } } else { # # Retrieve a calendar. # # This query is run currently without a time constraints. # # GN TODO: not sure, returning always the full calendar is # a good idea, my personal calendar has more than 10 years # of data ... but maybe this is not often executed. # # The query parameter "calendar_ids" is used e.g. for # regression testing. # # GN TODO: # if {[llength ${:urlv}] > 1} { set calendar_ids [lindex ${:urlv} 1] } else { set calendar_ids [ns_queryget calendar_ids ""] } :calendar_ids $calendar_ids if {$calendar_ids ne ""} { # # For specified calendars, return the calendar name of # the first calendar_id # set calendar_query "-calendar_ids $calendar_ids" } else { set calendar_query "" } set resp [calendars header -calendar_name [:calendarName]] foreach item [calendars get_calitems -user_id ${:user_id} {*}$calendar_query] { append resp [$item as_ical_event] } append resp [calendars footer] set code 200 } :response $code $mimetype $respXQL Not present: Generic, PostgreSQL, Oracle