Move caldav:calendar-timezone into the collection table.

This commit is contained in:
Andrew McMillan 2009-12-23 23:30:07 +13:00
parent 2f621b23d1
commit f2b20bc191
2 changed files with 32 additions and 2 deletions

View File

@ -277,8 +277,11 @@ class DAVResource
$base_sql = 'SELECT collection.*, path_privs(:session_principal::int8, collection.dav_name,:scan_depth::int), ';
$base_sql .= 'p.principal_id, p.type_id AS principal_type_id, ';
$base_sql .= 'p.displayname AS principal_displayname, p.default_privileges AS principal_default_privileges ';
$base_sql .= 'FROM collection LEFT JOIN principal p USING (user_no) WHERE ';
$base_sql .= 'p.displayname AS principal_displayname, p.default_privileges AS principal_default_privileges, ';
$base_sql .= 'time_zone.tz_spec ';
$base_sql .= 'FROM collection LEFT JOIN principal p USING (user_no) ';
$base_sql .= 'LEFT JOIN time_zone ON (collection.timezone=time_zone.tz_id) ';
$base_sql .= 'WHERE ';
$sql = $base_sql .'collection.dav_name = :raw_path ';
$params = array( ':raw_path' => $this->dav_name, ':session_principal' => $session->principal_id, ':scan_depth' => $c->permission_scan_depth );
if ( !preg_match( '#/$#', $this->dav_name ) ) {
@ -1021,6 +1024,16 @@ EOQRY;
$denied[] = $reply->Tag($tag);
break;
case 'urn:ietf:params:xml:ns:caldav:calendar-timezone':
if ( ! $this->_is_collection ) return false;
if ( !isset($this->collection->tz_spec) || $this->collection->tz_spec == '' ) return false;
$cal = new iCalComponent();
$cal->VCalendar();
$cal->AddComponent( new iCalComponent($this->collection->tz_spec) );
$reply->NSElement($prop, $tag, $cal->Render() );
break;
case 'urn:ietf:params:xml:ns:caldav:calendar-data':
if ( $this->_is_collection ) return false;
if ( !isset($this->resource) ) $this->FetchResource();

View File

@ -10,6 +10,8 @@
*/
dbg_error_log("PROPPATCH", "method handler");
require_once('iCalendar.php');
if ( ! $request->AllowedTo('write-properties') ) {
$request->DoResponse( 403 );
}
@ -95,6 +97,17 @@ foreach( $setprops AS $k => $setting ) {
}
break;
case 'urn:ietf:params:xml:ns:caldav:calendar-timezone':
$tzcomponent = $setting->GetPath('urn:ietf:params:xml:ns:caldav:calendar-timezone');
$tzstring = $tzcomponent[0]->GetContent();
$calendar = new iCalendar( array( 'icalendar' => $tzstring) );
$timezones = $calendar->component->GetComponents('VTIMEZONE');
if ( $timezones === false || count($timezones) == 0 ) break;
$tz = $timezones[0]; // Backward compatibility
$tzid = $tz->GetPValue('TZID');
$sql .= sprintf( 'UPDATE collection SET timezone = %s WHERE dav_name = %s;', qpg($tzid), qpg($request->path) );
break;
/**
* The following properties are read-only, so they will cause the request to fail
*/
@ -159,6 +172,10 @@ foreach( $rmprops AS $k => $setting ) {
}
break;
case 'urn:ietf:params:xml:ns:caldav:calendar-timezone':
$sql .= sprintf( "UPDATE collection SET timezone = NULL WHERE dav_name = %s;", qpg($request->path) );
break;
/**
* The following properties are read-only, so they will cause the request to fail
*/