mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-31 03:34:18 +00:00
Convert PUT entirely to iCalComponent from iCalendar.
This commit is contained in:
parent
f7eda3bd1c
commit
87fe232586
@ -17,6 +17,11 @@
|
|||||||
|
|
||||||
include_once("iCalendar.php");
|
include_once("iCalendar.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A regex which will match most reasonable timezones acceptable to PostgreSQL.
|
||||||
|
*/
|
||||||
|
$tz_regex = ':^(Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Brazil|Canada|Chile|Etc|Europe|Indian|Mexico|Mideast|Pacific|US)/[a-z]+$:i';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function launches an error
|
* This function launches an error
|
||||||
* @param boolean $caldav_context Whether we are responding via CalDAV or interactively
|
* @param boolean $caldav_context Whether we are responding via CalDAV or interactively
|
||||||
@ -123,14 +128,13 @@ function public_events_only( $user_no, $dav_name ) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create scheduling requests in the schedule inbox for the
|
* Create scheduling requests in the schedule inbox for the
|
||||||
* @param iCalendar $ic The iCalendar object we should create scheduling requests for.
|
* @param iCalComponent $component The VEVENT/VTODO/... resource we are scheduling
|
||||||
*/
|
*/
|
||||||
function create_scheduling_requests( $ic ) {
|
function create_scheduling_requests( $resource ) {
|
||||||
$component =& $ic->component->FirstNonTimezone();
|
$attendees = $resource->GetPropertiesByPath('/VCALENDAR/*/ATTENDEE');
|
||||||
$attendees = $component->GetProperties('ATTENDEE');
|
|
||||||
if ( preg_match( '# iCal/\d#', $_SERVER['HTTP_USER_AGENT']) ) {
|
if ( preg_match( '# iCal/\d#', $_SERVER['HTTP_USER_AGENT']) ) {
|
||||||
dbg_error_log( "POST", "Non-compliant iCal request. Using X-WR-ATTENDEE property" );
|
dbg_error_log( "POST", "Non-compliant iCal request. Using X-WR-ATTENDEE property" );
|
||||||
$wr_attendees = $component->GetProperties('X-WR-ATTENDEE');
|
$wr_attendees = $resource->GetPropertiesByPath('/VCALENDAR/*/X-WR-ATTENDEE');
|
||||||
foreach( $wr_attendees AS $k => $v ) {
|
foreach( $wr_attendees AS $k => $v ) {
|
||||||
$attendees[] = $v;
|
$attendees[] = $v;
|
||||||
}
|
}
|
||||||
@ -151,75 +155,40 @@ function create_scheduling_requests( $ic ) {
|
|||||||
* Any VEVENTs with the same UID will be concatenated together
|
* Any VEVENTs with the same UID will be concatenated together
|
||||||
*/
|
*/
|
||||||
function import_collection( $ics_content, $user_no, $path, $caldav_context ) {
|
function import_collection( $ics_content, $user_no, $path, $caldav_context ) {
|
||||||
global $c, $session;
|
global $c, $session, $tz_regex;
|
||||||
// According to RFC2445 we should always end with CRLF, but the CalDAV spec says
|
|
||||||
// that normalising XML parsers often muck with it and may remove the CR.
|
|
||||||
$icalendar = preg_replace('/\r?\n /', '', $ics_content );
|
|
||||||
if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['put'])) ) {
|
if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['put'])) ) {
|
||||||
$fh = fopen('/tmp/PUT-2.txt','w');
|
$fh = fopen('/tmp/PUT-2.txt','w');
|
||||||
if ( $fh ) {
|
if ( $fh ) {
|
||||||
fwrite($fh,$icalendar);
|
fwrite($fh,$ics_content);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = preg_split('/\r?\n/', $icalendar );
|
$calendar = new iCalComponent($ics_content);
|
||||||
|
$timezones = $calendar->GetComponents('VTIMEZONE',true);
|
||||||
|
$components = $calendar->GetComponents('VTIMEZONE',false);
|
||||||
|
|
||||||
$events = array();
|
$tz_ids = array();
|
||||||
$event_ids = array();
|
foreach( $timezones AS $k => $tz ) {
|
||||||
$timezones = array();
|
$tz_ids[$tz->GetPValue('TZID')] = $k;
|
||||||
|
}
|
||||||
|
|
||||||
$current = "";
|
/** Build an array of resources. Each resource is an array of iCalComponent */
|
||||||
unset($event_id);
|
$resources = array();
|
||||||
$state = "";
|
foreach( $components AS $k => $comp ) {
|
||||||
$tzid = 'unknown';
|
$uid = $comp->GetPValue('UID');
|
||||||
foreach( $lines AS $lno => $line ) {
|
if ( !isset($resources[$uid]) ) $resources[$uid] = array();
|
||||||
if ( $state == "" ) {
|
$resources[$uid][] = $comp;
|
||||||
if ( preg_match( '/^BEGIN:(VEVENT|VTIMEZONE|VTODO|VJOURNAL)$/', $line, $matches ) ) {
|
|
||||||
$current .= $line."\n";
|
/** Ensure we have the timezone component for this in our array as well */
|
||||||
$state = $matches[1];
|
$tzid = $comp->GetPParamValue('DTSTART', 'TZID');
|
||||||
dbg_error_log( "PUT", "CalendarLine[%04d] - %s: %s", $lno, $state, $line );
|
if ( !isset($tzid) || $tzid == "" ) $tzid = $comp->GetPParamValue('DUE','TZID');
|
||||||
|
if ( !isset($resources[$uid][$tzid]) && isset($tz_ids[$tzid]) ) {
|
||||||
|
$resources[$uid][$tzid] = $timezones[$tz_ids[$tzid]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$current .= $line."\n";
|
|
||||||
if ( preg_match( '/^UID:(.*)$/', $line, &$matches) ) {
|
|
||||||
$event_id = $matches[1];
|
|
||||||
dbg_error_log( "PUT", " Processing event with UID of '%s'", $event_id );
|
|
||||||
}
|
|
||||||
else if ( $line == "END:$state" ) {
|
|
||||||
switch ( $state ) {
|
|
||||||
case 'VTIMEZONE':
|
|
||||||
$timezones[$tzid] = $current;
|
|
||||||
dbg_error_log( "PUT", " Ended VTIMEZONE for TZID '%s' ", $tzid );
|
|
||||||
break;
|
|
||||||
case 'VEVENT':
|
|
||||||
case 'VTODO':
|
|
||||||
case 'VJOURNAL':
|
|
||||||
default:
|
|
||||||
if ( isset($event_ids[$event_id]) ) {
|
|
||||||
// All of the VEVENT (or whatever) with the same UID are concatenated
|
|
||||||
$events[$event_ids[$event_id]]['data'] .= $current;
|
|
||||||
}
|
|
||||||
else if ( isset($event_id) ) {
|
|
||||||
$event_ids[$event_id] = count($events);
|
|
||||||
$events[] = array( 'data' => $current, 'tzid' => $tzid );
|
|
||||||
}
|
|
||||||
unset($event_id);
|
|
||||||
dbg_error_log( "PUT", " Ended %s with TZID '%s' ", $state, $tzid );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$state = "";
|
|
||||||
$current = "";
|
|
||||||
$tzid = 'unknown';
|
|
||||||
}
|
|
||||||
else if ( preg_match( '/TZID[:=]([^:]+)(:|$)/', $line, $matches ) ) {
|
|
||||||
$tzid = $matches[1];
|
|
||||||
dbg_error_log( "PUT", " Found TZID of '%s' in '%s'", $tzid, $line );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dbg_error_log( "PUT", " Finished input after $lno lines" );
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM collection WHERE user_no = ? AND dav_name = ?;";
|
$sql = "SELECT * FROM collection WHERE user_no = ? AND dav_name = ?;";
|
||||||
$qry = new PgQuery( $sql, $user_no, $path );
|
$qry = new PgQuery( $sql, $user_no, $path );
|
||||||
@ -230,38 +199,42 @@ function import_collection( $ics_content, $user_no, $path, $caldav_context ) {
|
|||||||
}
|
}
|
||||||
$collection = $qry->Fetch();
|
$collection = $qry->Fetch();
|
||||||
|
|
||||||
$qry = new PgQuery("BEGIN; DELETE FROM calendar_item WHERE user_no=? AND dav_name ~ ?; DELETE FROM caldav_data WHERE user_no=? AND dav_name ~ ?;", $user_no, $path.'[^/]+$', $user_no, $path.'[^/]+$');
|
$qry = new PgQuery("BEGIN; DELETE FROM calendar_item WHERE user_no=? AND collection_id = ?; DELETE FROM caldav_data WHERE user_no=? AND collection_id = ?;", $user_no, $collection->collection_id, $user_no, $collection->collection_id);
|
||||||
if ( !$qry->Exec("PUT") ) rollback_on_error( $caldav_context, $user_no, $path );
|
if ( !$qry->Exec("PUT") ) rollback_on_error( $caldav_context, $user_no, $collection->collection_id );
|
||||||
|
|
||||||
foreach( $events AS $k => $event ) {
|
$last_tz_locn = '';
|
||||||
dbg_error_log( "PUT", "Putting event %d with data: %s", $k, $event['data'] );
|
foreach( $resources AS $uid => $resource ) {
|
||||||
$icalendar = iCalendar::iCalHeader() . $event['data'] . (isset($timezones[$event['tzid']])?$timezones[$event['tzid']]:"") . iCalendar::iCalFooter();
|
/** Construct the VCALENDAR data */
|
||||||
$ic = new iCalendar( array( 'icalendar' => $icalendar ) );
|
$vcal = new iCalComponent();
|
||||||
|
$vcal->VCalendar();
|
||||||
|
$vcal->SetComponents($resource);
|
||||||
|
$icalendar = $vcal->Render();
|
||||||
|
|
||||||
|
/** As ever, we mostly deal with the first resource component */
|
||||||
|
$first = $resource[0];
|
||||||
|
|
||||||
|
$sql = '';
|
||||||
$etag = md5($icalendar);
|
$etag = md5($icalendar);
|
||||||
$event_path = sprintf( "%s%d.ics", $path, $k);
|
$type = $first->GetType();
|
||||||
|
$resource_path = sprintf( "%s%s.ics", $path, $uid );
|
||||||
$qry = new PgQuery( "INSERT INTO caldav_data ( user_no, dav_name, dav_etag, caldav_data, caldav_type, logged_user, created, modified, collection_id ) VALUES( ?, ?, ?, ?, ?, ?, current_timestamp, current_timestamp, ? )",
|
$qry = new PgQuery( "INSERT INTO caldav_data ( user_no, dav_name, dav_etag, caldav_data, caldav_type, logged_user, created, modified, collection_id ) VALUES( ?, ?, ?, ?, ?, ?, current_timestamp, current_timestamp, ? )",
|
||||||
$user_no, $event_path, $etag, $icalendar, $ic->type, $session->user_no, $collection->collection_id );
|
$user_no, $resource_path, $etag, $icalendar, $type, $session->user_no, $collection->collection_id );
|
||||||
if ( !$qry->Exec("PUT") ) rollback_on_error( $caldav_context, $user_no, $path );
|
if ( !$qry->Exec("PUT") ) rollback_on_error( $caldav_context, $user_no, $path );
|
||||||
|
|
||||||
$sql = "";
|
$dtstart = $first->GetPValue('DTSTART');
|
||||||
if ( preg_match(':^(Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Brazil|Canada|Chile|Etc|Europe|Indian|Mexico|Mideast|Pacific|US)/[a-z]+$:i', $ic->tz_locn ) ) {
|
if ( (!isset($dtstart) || $dtstart == "") && $first->GetPValue('DUE') != "" ) {
|
||||||
// We only set the timezone if it looks reasonable enough for us
|
$dtstart = $first->GetPValue('DUE');
|
||||||
$sql = ( $ic->tz_locn == '' ? '' : "SET TIMEZONE TO ".qpg($ic->tz_locn).";" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$dtstart = $ic->Get('dtstart');
|
$dtend = $first->GetPValue('DTEND');
|
||||||
if ( (!isset($dtstart) || $dtstart == "") && $ic->Get('due') != "" ) {
|
|
||||||
$dtstart = $ic->Get('due'); // Dodgy fallback
|
|
||||||
}
|
|
||||||
|
|
||||||
$dtend = $ic->Get('dtend');
|
|
||||||
if ( (!isset($dtend) || "$dtend" == "") ) {
|
if ( (!isset($dtend) || "$dtend" == "") ) {
|
||||||
if ( $ic->Get('duration') != "" AND $dtstart != "" ) {
|
if ( $first->GetPValue('DURATION') != "" AND $dtstart != "" ) {
|
||||||
$duration = preg_replace( '#[PT]#', ' ', $ic->Get('duration') );
|
$duration = preg_replace( '#[PT]#', ' ', $first->GetPValue('DURATION') );
|
||||||
$dtend = '('.qpg($dtstart).'::timestamp with time zone + '.qpg($duration).'::interval)';
|
$dtend = '('.qpg($dtstart).'::timestamp with time zone + '.qpg($duration).'::interval)';
|
||||||
}
|
}
|
||||||
else {
|
elseif ( $first->GetType() == 'VEVENT' ) {
|
||||||
/**
|
/**
|
||||||
|
* From RFC2445 4.6.1:
|
||||||
* For cases where a "VEVENT" calendar component specifies a "DTSTART"
|
* For cases where a "VEVENT" calendar component specifies a "DTSTART"
|
||||||
* property with a DATE data type but no "DTEND" property, the events
|
* property with a DATE data type but no "DTEND" property, the events
|
||||||
* non-inclusive end is the end of the calendar date specified by the
|
* non-inclusive end is the end of the calendar date specified by the
|
||||||
@ -273,65 +246,77 @@ function import_collection( $ics_content, $user_no, $path, $caldav_context ) {
|
|||||||
* So we're looking for 'VALUE=DATE', to identify the duration, effectively.
|
* So we're looking for 'VALUE=DATE', to identify the duration, effectively.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$event = $ic->component->FirstNonTimezone();
|
$value_type = $first->GetPParamValue('DTSTART','VALUE');
|
||||||
if ( isset($event) && is_object($event) ) {
|
dbg_error_log("PUT","DTSTART without DTEND. DTSTART value type is %s", $value_type );
|
||||||
$dtstart_prop = $event->GetProperties('DTSTART');
|
if ( isset($value_type) && $value_type == 'DATE' )
|
||||||
if ( count($dtstart_prop) == 1 ) {
|
|
||||||
if ( $dtstart_prop[1]->GetParameterValue('VALUE') == 'DATE' )
|
|
||||||
$dtend = '('.qpg($dtstart)."::timestamp with time zone::date + '1 day'::interval)";
|
$dtend = '('.qpg($dtstart)."::timestamp with time zone::date + '1 day'::interval)";
|
||||||
else
|
else
|
||||||
$dtend = qpg($dtstart);
|
$dtend = qpg($dtstart);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if ( $dtend == "" ) $dtend = 'NULL';
|
if ( $dtend == "" ) $dtend = 'NULL';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dbg_error_log( "PUT", " DTEND: '%s', DTSTART: '%s', DURATION: '%s'", $dtend, $dtstart, $ic->Get('duration') );
|
dbg_error_log( "PUT", " DTEND: '%s', DTSTART: '%s', DURATION: '%s'", $dtend, $dtstart, $first->GetPValue('DURATION') );
|
||||||
$dtend = qpg($dtend);
|
$dtend = qpg($dtend);
|
||||||
}
|
}
|
||||||
|
|
||||||
$last_modified = $ic->Get("last-modified");
|
$last_modified = $first->GetPValue("LAST-MODIFIED");
|
||||||
if ( !isset($last_modified) || $last_modified == '' ) {
|
if ( !isset($last_modified) || $last_modified == '' ) $last_modified = gmdate( 'Ymd\THis\Z' );
|
||||||
$last_modified = gmdate( 'Ymd\THis\Z' );
|
|
||||||
}
|
|
||||||
|
|
||||||
$dtstamp = $ic->Get("dtstamp");
|
$dtstamp = $first->GetPValue("DTSTAMP");
|
||||||
if ( !isset($dtstamp) || $dtstamp == '' ) {
|
if ( !isset($dtstamp) || $dtstamp == '' ) $dtstamp = $last_modified;
|
||||||
$dtstamp = $last_modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
$class = $ic->Get("class");
|
/** RFC2445, 4.8.1.3: Default is PUBLIC, or also if overridden by the collection settings */
|
||||||
/* Check and see if we should over ride the class. */
|
$class = ($collection->public_events_only == 't' ? 'PUBLIC' : $first->GetPValue("CLASS") );
|
||||||
if ( public_events_only($user_no, $path) ) {
|
if ( !isset($class) || $class == '' ) $class = 'PUBLIC';
|
||||||
$class = 'PUBLIC';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It seems that some calendar clients don't set a class...
|
/** Calculate what timezone to set, first, if possible */
|
||||||
* RFC2445, 4.8.1.3:
|
$tzid = $first->GetPParamValue('DTSTART','TZID');
|
||||||
* Default is PUBLIC
|
if ( !isset($tzid) || $tzid == "" ) $tzid = $first->GetPParamValue('DUE','TZID');
|
||||||
*/
|
if ( isset($tzid) && $tzid != "" && isset($resource[$tzid]) ) {
|
||||||
if ( !isset($class) || $class == '' ) {
|
$tz = $resource[$tzid]; /** We know this, since we stuck it there earlier */
|
||||||
$class = 'PUBLIC';
|
$tz_locn = $tz->GetPValue('X-LIC-LOCATION');
|
||||||
|
dbg_error_log( "PUT", " Using TZID[%s] and location of [%s]", $tzid, $tz_locn );
|
||||||
|
if ( ! isset($tz_locn) || ! preg_match( $tz_regex, $tz_locn ) ) {
|
||||||
|
if ( preg_match( '#/([^/]+/[^/]+)$#', $tzid, $matches ) ) {
|
||||||
|
$tz_locn = $matches[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( isset($tz_locn) && ($tz_locn != $last_tz_locn) && preg_match( $tz_regex, $tz_locn ) ) {
|
||||||
|
dbg_error_log( "PUT", " Setting timezone to %s", $tz_locn );
|
||||||
|
$sql .= ( $tz_locn == '' ? '' : "SET TIMEZONE TO ".qpg($tz_locn).";" );
|
||||||
|
$last_tz_locn = $tz_locn;
|
||||||
|
}
|
||||||
|
$qry = new PgQuery("SELECT tz_locn FROM time_zone WHERE tz_id = ?", $tzid );
|
||||||
|
if ( $qry->Exec() && $qry->rows == 0 ) {
|
||||||
|
$qry = new PgQuery("INSERT INTO time_zone (tz_id, tz_locn, tz_spec) VALUES(?,?,?)", $tzid, $tz_locn, $tz->Render() );
|
||||||
|
$qry->Exec();
|
||||||
|
}
|
||||||
|
if ( !isset($tz_locn) || $tz_locn == "" ) {
|
||||||
|
$tz_locn = $tzid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$tzid = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= <<<EOSQL
|
$sql .= <<<EOSQL
|
||||||
INSERT INTO calendar_item (user_no, dav_name, dav_etag, uid, dtstamp, dtstart, dtend, summary, location, class, transp,
|
INSERT INTO calendar_item (user_no, dav_name, dav_etag, uid, dtstamp, dtstart, dtend, summary, location, class, transp,
|
||||||
description, rrule, tz_id, last_modified, url, priority, created, due, percent_complete, collection_id )
|
description, rrule, tz_id, last_modified, url, priority, created, due, percent_complete, status, collection_id )
|
||||||
VALUES ( ?, ?, ?, ?, ?, ?, $dtend, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
VALUES ( ?, ?, ?, ?, ?, ?, $dtend, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
||||||
EOSQL;
|
EOSQL;
|
||||||
|
|
||||||
$qry = new PgQuery( $sql, $user_no, $event_path, $etag, $ic->Get('uid'), $dtstamp,
|
$qry = new PgQuery( $sql, $user_no, $resource_path, $etag, $first->GetPValue('UID'), $dtstamp,
|
||||||
$ic->Get('dtstart'), $ic->Get('summary'), $ic->Get('location'),
|
$first->GetPValue('DTSTART'), $first->GetPValue('SUMMARY'), $first->GetPValue('LOCATION'),
|
||||||
$class, $ic->Get('transp'), $ic->Get('description'), $ic->Get('rrule'), $ic->Get('tz_id'),
|
$class, $first->GetPValue('TRANSP'), $first->GetPValue('DESCRIPTION'), $first->GetPValue('RRULE'), $tzid,
|
||||||
$last_modified, $ic->Get('url'), $ic->Get('priority'), $ic->Get('created'),
|
$last_modified, $first->GetPValue('URL'), $first->GetPValue('PRIORITY'), $first->GetPValue('CREATED'),
|
||||||
$ic->Get('due'), $ic->Get('percent-complete'), $collection->collection_id
|
$first->GetPValue('DUE'), $first->GetPValue('PERCENT-COMPLETE'), $first->GetPValue('STATUS'), $collection->collection_id
|
||||||
);
|
);
|
||||||
if ( !$qry->Exec("PUT") ) rollback_on_error( $caldav_context, $user_no, $path);
|
if ( !$qry->Exec("PUT") ) rollback_on_error( $caldav_context, $user_no, $path);
|
||||||
|
|
||||||
create_scheduling_requests( $ic );
|
create_scheduling_requests( $vcal );
|
||||||
}
|
}
|
||||||
|
|
||||||
$qry = new PgQuery("COMMIT;");
|
$qry = new PgQuery("COMMIT;");
|
||||||
@ -347,6 +332,8 @@ EOSQL;
|
|||||||
* @return string Either 'INSERT' or 'UPDATE': the type of action that the PUT resulted in
|
* @return string Either 'INSERT' or 'UPDATE': the type of action that the PUT resulted in
|
||||||
*/
|
*/
|
||||||
function putCalendarResource( &$request, $author, $caldav_context ) {
|
function putCalendarResource( &$request, $author, $caldav_context ) {
|
||||||
|
global $tz_regex;
|
||||||
|
|
||||||
$etag = md5($request->raw_post);
|
$etag = md5($request->raw_post);
|
||||||
$ic = new iCalComponent( $request->raw_post );
|
$ic = new iCalComponent( $request->raw_post );
|
||||||
|
|
||||||
@ -500,7 +487,6 @@ function putCalendarResource( &$request, $author, $caldav_context ) {
|
|||||||
$tzid = $first->GetPParamValue('DTSTART','TZID');
|
$tzid = $first->GetPParamValue('DTSTART','TZID');
|
||||||
if ( !isset($tzid) || $tzid == "" ) $tzid = $first->GetPParamValue('DUE','TZID');
|
if ( !isset($tzid) || $tzid == "" ) $tzid = $first->GetPParamValue('DUE','TZID');
|
||||||
$timezones = $ic->GetComponents('VTIMEZONE');
|
$timezones = $ic->GetComponents('VTIMEZONE');
|
||||||
$tz_regex = ':^(Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Brazil|Canada|Chile|Etc|Europe|Indian|Mexico|Mideast|Pacific|US)/[a-z]+$:i';
|
|
||||||
foreach( $timezones AS $k => $tz ) {
|
foreach( $timezones AS $k => $tz ) {
|
||||||
if ( $tz->GetPValue('TZID') == $tzid ) {
|
if ( $tz->GetPValue('TZID') == $tzid ) {
|
||||||
// This is the one
|
// This is the one
|
||||||
|
|||||||
@ -6,3 +6,170 @@ DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
|||||||
Content-Length: 0
|
Content-Length: 0
|
||||||
Content-Type: text/plain; charset="utf-8"
|
Content-Type: text/plain; charset="utf-8"
|
||||||
|
|
||||||
|
A1 CalDAV DATA: >BEGIN:VCALENDAR
|
||||||
|
PRODID:-//davical.org//NONSGML AWL Calendar//EN
|
||||||
|
VERSION:2.0
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
|
BEGIN:VEVENT
|
||||||
|
CREATED:20081023T054958Z
|
||||||
|
LAST-MODIFIED:20081023T055044Z
|
||||||
|
DTSTAMP:20081023T054958Z
|
||||||
|
UID:33169d69-2969-4a96-a3e1-2e312b7614e6
|
||||||
|
SUMMARY:Daily Action Meeting
|
||||||
|
RRULE:FREQ=DAILY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR
|
||||||
|
DTSTART;TZID=Pacific/Auckland:20081020T110000
|
||||||
|
DTEND;TZID=Pacific/Auckland:20081020T113000
|
||||||
|
X-MOZ-GENERATION:2
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Pacific/Auckland
|
||||||
|
X-LIC-LOCATION:Pacific/Auckland
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZOFFSETFROM:+1200
|
||||||
|
TZOFFSETTO:+1300
|
||||||
|
TZNAME:NZDT
|
||||||
|
DTSTART:19700927T020000
|
||||||
|
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=9
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZOFFSETFROM:+1300
|
||||||
|
TZOFFSETTO:+1200
|
||||||
|
TZNAME:NZST
|
||||||
|
DTSTART:19700405T030000
|
||||||
|
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=4
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
END:VCALENDAR
|
||||||
|
<
|
||||||
|
caldav_type: >VEVENT<
|
||||||
|
class: >PUBLIC<
|
||||||
|
description: >NULL<
|
||||||
|
dtend: >2008-10-20 11:30:00+13<
|
||||||
|
dtstamp: >2008-10-23 05:49:58<
|
||||||
|
dtstart: >2008-10-20 11:00:00+13<
|
||||||
|
due: >NULL<
|
||||||
|
location: >NULL<
|
||||||
|
logged_user: >11<
|
||||||
|
percent_complete: >NULL<
|
||||||
|
priority: >NULL<
|
||||||
|
rrule: >FREQ=DAILY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR<
|
||||||
|
status: >NULL<
|
||||||
|
summary: >Daily Action Meeting<
|
||||||
|
transp: >NULL<
|
||||||
|
tz_id: >Pacific/Auckland<
|
||||||
|
uid: >33169d69-2969-4a96-a3e1-2e312b7614e6<
|
||||||
|
url: >NULL<
|
||||||
|
user_no: >11<
|
||||||
|
|
||||||
|
A1 CalDAV DATA: >BEGIN:VCALENDAR
|
||||||
|
PRODID:-//davical.org//NONSGML AWL Calendar//EN
|
||||||
|
VERSION:2.0
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
|
BEGIN:VEVENT
|
||||||
|
CREATED:20081023T054934Z
|
||||||
|
LAST-MODIFIED:20081023T055059Z
|
||||||
|
DTSTAMP:20081023T054934Z
|
||||||
|
UID:047871e3-6b70-4178-9af8-0ceb50f7b092
|
||||||
|
SUMMARY:Weekly Project Meeting
|
||||||
|
RRULE:FREQ=WEEKLY;INTERVAL=1
|
||||||
|
DTSTART;TZID=Pacific/Auckland:20081020T090000
|
||||||
|
DTEND;TZID=Pacific/Auckland:20081020T100000
|
||||||
|
X-MOZ-GENERATION:2
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Pacific/Auckland
|
||||||
|
X-LIC-LOCATION:Pacific/Auckland
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZOFFSETFROM:+1200
|
||||||
|
TZOFFSETTO:+1300
|
||||||
|
TZNAME:NZDT
|
||||||
|
DTSTART:19700927T020000
|
||||||
|
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=9
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZOFFSETFROM:+1300
|
||||||
|
TZOFFSETTO:+1200
|
||||||
|
TZNAME:NZST
|
||||||
|
DTSTART:19700405T030000
|
||||||
|
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=4
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
END:VCALENDAR
|
||||||
|
<
|
||||||
|
caldav_type: >VEVENT<
|
||||||
|
class: >PUBLIC<
|
||||||
|
description: >NULL<
|
||||||
|
dtend: >2008-10-20 10:00:00+13<
|
||||||
|
dtstamp: >2008-10-23 05:49:34<
|
||||||
|
dtstart: >2008-10-20 09:00:00+13<
|
||||||
|
due: >NULL<
|
||||||
|
location: >NULL<
|
||||||
|
logged_user: >11<
|
||||||
|
percent_complete: >NULL<
|
||||||
|
priority: >NULL<
|
||||||
|
rrule: >FREQ=WEEKLY;INTERVAL=1<
|
||||||
|
status: >NULL<
|
||||||
|
summary: >Weekly Project Meeting<
|
||||||
|
transp: >NULL<
|
||||||
|
tz_id: >Pacific/Auckland<
|
||||||
|
uid: >047871e3-6b70-4178-9af8-0ceb50f7b092<
|
||||||
|
url: >NULL<
|
||||||
|
user_no: >11<
|
||||||
|
|
||||||
|
A1 CalDAV DATA: >BEGIN:VCALENDAR
|
||||||
|
PRODID:-//davical.org//NONSGML AWL Calendar//EN
|
||||||
|
VERSION:2.0
|
||||||
|
CALSCALE:GREGORIAN
|
||||||
|
BEGIN:VEVENT
|
||||||
|
CREATED:20081023T055115Z
|
||||||
|
LAST-MODIFIED:20081023T055139Z
|
||||||
|
DTSTAMP:20081023T055115Z
|
||||||
|
UID:9429a973-2b13-4b1a-be09-948d75425c45
|
||||||
|
SUMMARY:Weekly catch-up
|
||||||
|
RRULE:FREQ=WEEKLY;INTERVAL=1
|
||||||
|
DTSTART;TZID=Pacific/Auckland:20081024T140000
|
||||||
|
DTEND;TZID=Pacific/Auckland:20081024T150000
|
||||||
|
X-MOZ-GENERATION:2
|
||||||
|
END:VEVENT
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Pacific/Auckland
|
||||||
|
X-LIC-LOCATION:Pacific/Auckland
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
TZOFFSETFROM:+1200
|
||||||
|
TZOFFSETTO:+1300
|
||||||
|
TZNAME:NZDT
|
||||||
|
DTSTART:19700927T020000
|
||||||
|
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=9
|
||||||
|
END:DAYLIGHT
|
||||||
|
BEGIN:STANDARD
|
||||||
|
TZOFFSETFROM:+1300
|
||||||
|
TZOFFSETTO:+1200
|
||||||
|
TZNAME:NZST
|
||||||
|
DTSTART:19700405T030000
|
||||||
|
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=4
|
||||||
|
END:STANDARD
|
||||||
|
END:VTIMEZONE
|
||||||
|
END:VCALENDAR
|
||||||
|
<
|
||||||
|
caldav_type: >VEVENT<
|
||||||
|
class: >PUBLIC<
|
||||||
|
description: >NULL<
|
||||||
|
dtend: >2008-10-24 15:00:00+13<
|
||||||
|
dtstamp: >2008-10-23 05:51:15<
|
||||||
|
dtstart: >2008-10-24 14:00:00+13<
|
||||||
|
due: >NULL<
|
||||||
|
location: >NULL<
|
||||||
|
logged_user: >11<
|
||||||
|
percent_complete: >NULL<
|
||||||
|
priority: >NULL<
|
||||||
|
rrule: >FREQ=WEEKLY;INTERVAL=1<
|
||||||
|
status: >NULL<
|
||||||
|
summary: >Weekly catch-up<
|
||||||
|
transp: >NULL<
|
||||||
|
tz_id: >Pacific/Auckland<
|
||||||
|
uid: >9429a973-2b13-4b1a-be09-948d75425c45<
|
||||||
|
url: >NULL<
|
||||||
|
user_no: >11<
|
||||||
|
|
||||||
|
count: >3<
|
||||||
|
|
||||||
|
|||||||
@ -68,3 +68,20 @@ X-MOZ-GENERATION:2
|
|||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
ENDDATA
|
ENDDATA
|
||||||
|
|
||||||
|
QUERY
|
||||||
|
SELECT caldav_data.user_no, caldav_type, logged_user,
|
||||||
|
uid, dtstamp, dtstart, dtend, due, summary, location,
|
||||||
|
description, priority, class, transp, rrule, url,
|
||||||
|
percent_complete, tz_id, status,
|
||||||
|
caldav_data AS "A1 CalDAV DATA"
|
||||||
|
FROM caldav_data JOIN calendar_item USING(dav_name)
|
||||||
|
WHERE caldav_data.dav_name ~ '^/user2/home/'
|
||||||
|
ENDQUERY
|
||||||
|
|
||||||
|
QUERY
|
||||||
|
SELECT count(*)
|
||||||
|
FROM caldav_data JOIN calendar_item USING(dav_name)
|
||||||
|
WHERE caldav_data.dav_name ~ '^/user2/home/'
|
||||||
|
ENDQUERY
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
HTTP/1.1 207 Multi-Status
|
HTTP/1.1 207 Multi-Status
|
||||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||||
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
|
||||||
ETag: "0602e88fb9658b0904b6bb818c01f0ab"
|
ETag: "a47321191c9f17f910aab45a4127d331"
|
||||||
Content-Length: 2365
|
Content-Length: 2365
|
||||||
Content-Type: text/xml; charset="utf-8"
|
Content-Type: text/xml; charset="utf-8"
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ Content-Type: text/xml; charset="utf-8"
|
|||||||
<C:schedule-calendar/>
|
<C:schedule-calendar/>
|
||||||
</resourcetype>
|
</resourcetype>
|
||||||
<displayname>home</displayname>
|
<displayname>home</displayname>
|
||||||
<A:getctag>"edc7742ac609d320570f23f48f62461f"</A:getctag>
|
<A:getctag>"13249ced6c7527191a003f54f7e3cd25"</A:getctag>
|
||||||
</prop>
|
</prop>
|
||||||
<status>HTTP/1.1 200 OK</status>
|
<status>HTTP/1.1 200 OK</status>
|
||||||
</propstat>
|
</propstat>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user