caldav::CalDAV instproc calendar-multiget (public)

 <instance of caldav::CalDAV[i]> calendar-multiget prop

Defined in /var/www/openacs.org/packages/caldav/tcl/caldav-procs.tcl

calendar-multiget REPORT is used to retrieve specific calendar object resources from within a collection, if the Request- URI is a collection, or to retrieve a specific calendar object resource, if the Request-URI is a calendar object resource. This report is similar to the CALDAV:calendar-query REPORT (see Section 7.8), except that it takes a list of DAV:href elements, instead of a CALDAV:filter element, to determine which calendar object resources to return. https://icalendar.org/CalDAV-Access-RFC-4791/7-9-caldav-calendar-multiget-report.html

Parameters:
prop (required)

Testcases:
REPORT_ios
Source code:
#ns_log notice "==== calendar-multiget {$prop}"
set cal_uids {}
set act_ids {}

foreach node [$prop selectNodes -namespaces {d DAV:} //d:href/text()] {
    set href [$node asText]
    set id [:get_uid_from_href $href]
    if {$id eq ""} {
        ns_log notice "CalDAV calendar-multiget: ignore href '$href'"
        continue
    }
    if {[string is integer -strict $id]
        && [::xo::dc get_value -prepare integer is_activity_id {
            select 1 from acs_activities where activity_id = :id
        } 0] != 0
    } {
        lappend act_ids $id
    } else {
        lappend cal_uids [ns_urldecode $id]
    }
}

#
# GN TODO: it is probably better to use a UNION instead of the
# construct of "coalesce()" and "OR" below. We need to
# test/benchmark with a full database with real-world data for
# this.
#
set uid_clauses {}
if {[llength $cal_uids] > 0} {
    lappend uid_clauses "u.cal_uid in ([ns_dbquotelist $cal_uids])"
}
if {[llength $act_ids] > 0} {
    lappend uid_clauses "e.activity_id in ([ns_dbquotelist $act_ids])"
}
ns_log notice uid_clauses=$uid_clauses

set recurrences {}
set ics_set {}

#
# TODO: why not [calendar get_calitems] ?
#

foreach row [::xo::dc list_of_lists get_calitems [subst {
    select
    md5(last_modified::text) as etag,
    coalesce(cal_uid, e.activity_id::varchar),
    ical_vars,
    on_which_calendar,
    c.item_type_id,
    to_char(start_date, 'YYYY-MM-DD HH24:MI:SS'),
    to_char(end_date, 'YYYY-MM-DD HH24:MI:SS'),
    coalesce(e.name, a.name),
    coalesce(e.description, a.description),
    c.cal_item_id,
    recurrence_id,
    creation_date,
    last_modified
    from
    acs_objects ao,
    acs_events e
    left outer join cal_uids u on u.on_which_activity = e.activity_id,
    acs_activities a,
    timespans s,
    time_intervals t,
    cal_items c
    where e.event_id = ao.object_id
    and a.activity_id = e.activity_id
    and c.cal_item_id = e.event_id
    and e.timespan_id = s.timespan_id
    and s.interval_id = t.interval_id
    and ( [join $uid_clauses " or "])
    order by start_date asc
}]] {
    lassign $row etag cal_uid ical_vars calendar_id item_type  start_date end_date name description  cal_item_id recurrence_id creation_date last_modified

    if {$recurrence_id ne "" && $recurrence_id in $recurrences} {
        continue
    }
    # set item [::caldav::calitem new   #               -id $cal_item_id  #               -uid $cal_uid  #               -ical_vars $ical_vars  #               -etag $etag  #               -calendar $calendar_id  #               -creation_date $creation_date  #               -last_modified $last_modified  #               -dtstart $start_date  #               -is_day_item [dt_no_time_p -start_time $start_date -end_time $end_date]  #               -formatted_recurrences [calendars format_recurrence -recurrence_id $recurrence_id]  #               -dtend $end_date  #               -summary $name  #               -description $description  #               -item_type $item_type]
    set item [::caldav::calitem new   -uid $cal_uid  -ical_vars $ical_vars  -etag $etag  -creation_date $creation_date  -last_modified $last_modified  -dtstart $start_date  -is_day_item [dt_no_time_p -start_time $start_date -end_time $end_date]  -formatted_recurrences [calendars format_recurrence -recurrence_id $recurrence_id]  -dtend $end_date  -summary $name  -description $description  ]
    $item destroy_on_cleanup
    lappend ics_set $item
    lappend recurrences $recurrence_id
}
return $ics_set
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: