Fix (pseudo) exception handling in CalDAV

This commit is contained in:
Jörg Lehrke 2010-02-26 12:37:07 +00:00
parent 72e55f9753
commit c816b4188e
3 changed files with 63 additions and 57 deletions

View File

@ -1104,6 +1104,37 @@ class calendar_boupdate extends calendar_bo
return $Ok; return $Ok;
} }
/**
* update the status of all participant for a given recurrence or for all recurrences since now (includes recur_date=0)
*
* @param array $new_event event-array with the new stati
* @param array $old_event event-array with the old stati
* @param int $recur_date=0 date to change, or 0 = all since now
*/
function update_status($new_event, $old_event , $recur_date=0)
{
if (!isset($new_event['participants'])) return;
// check the old list against the new list
foreach ($old_event['participants'] as $userid => $status)
{
if (!isset($new_event['participants'][$userid])){
// Attendee will be deleted this way
$new_event['participants'][$userid] = 'G';
}
elseif ($new_event['participants'][$userid] == $status)
{
// Same status -- nothing to do.
unset($new_event['participants'][$userid]);
}
}
// write the changes
foreach ($new_event['participants'] as $userid => $status)
{
$this->set_status($old_event, $userid, $status, $recur_date, true, false);
}
}
/** /**
* deletes an event * deletes an event
* *

View File

@ -476,7 +476,7 @@ class calendar_groupdav extends groupdav_handler
*/ */
static function fix_series(array &$events) static function fix_series(array &$events)
{ {
foreach($events as $n => $event) error_log(__METHOD__." $n before: ".array2string($event)); //foreach($events as $n => $event) error_log(__METHOD__." $n before: ".array2string($event));
//$master =& $events[0]; //$master =& $events[0];
$bo = new calendar_boupdate(); $bo = new calendar_boupdate();
@ -527,16 +527,16 @@ class calendar_groupdav extends groupdav_handler
{ {
if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence
{ {
error_log(__METHOD__.'() deleting #'.$org_recurrence['id']); //error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
$bo->delete($org_recurrence['id']); // might fail because of permissions $bo->delete($org_recurrence['id']); // might fail because of permissions
} }
else // virtual recurrence else // virtual recurrence
{ {
error_log(__METHOD__.'() ToDO: delete virtual exception '.$org_recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$org_recurrence['recurrence'])); //error_log(__METHOD__.'() ToDO: delete virtual exception '.$org_recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$org_recurrence['recurrence']));
// todo: reset status and participants to master default $bo->update_status($master, $org_recurrence, $org_recurrence['recurrence']);
} }
} }
foreach($events as $n => $event) error_log(__METHOD__." $n after: ".array2string($event)); //foreach($events as $n => $event) error_log(__METHOD__." $n after: ".array2string($event));
} }
/** /**

View File

@ -126,7 +126,11 @@ class calendar_ical extends calendar_boupdate
/** /**
* user preference: Use this timezone for import from and export to device * user preference: Use this timezone for import from and export to device
* *
* @var string * @var mixed
* === false => use event's TZ
* === null => export in UTC
* string => device TZ
*
*/ */
var $tzid = null; var $tzid = null;
@ -1700,15 +1704,21 @@ class calendar_ical extends calendar_boupdate
switch ($deviceInfo['tzid']) switch ($deviceInfo['tzid'])
{ {
case 1: case 1:
$this->tzid = false; $this->tzid = false; // use event's TZ
break; break;
case 2: case 2:
$this->tzid = null; $this->tzid = null; // use UTC for export
break; break;
default: default:
$this->tzid = $deviceInfo['tzid']; $this->tzid = $deviceInfo['tzid'];
} }
} }
elseif (strpos($this->productName, 'palmos') !== false)
{
// for palmos we have to use user-time and NO timezone
$this->tzid = false;
}
if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner'])) if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner']))
{ {
$owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner']; $owner = $GLOBALS['egw_info']['user']['preferences']['syncml']['calendar_owner'];
@ -1733,20 +1743,6 @@ class calendar_ical extends calendar_boupdate
} }
} }
if ($this->log)
{
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
'(' . $this->productManufacturer .
', '. $this->productName .', ' .
($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .
")\n" , 3, $this->logfile);
}
//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
// . $this->productName .', ' .
// ($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .')',
// __FILE__, __LINE__, PEAR_LOG_DEBUG);
$defaultFields['minimal'] = array( $defaultFields['minimal'] = array(
'public' => 'public', 'public' => 'public',
'description' => 'description', 'description' => 'description',
@ -1910,10 +1906,12 @@ class calendar_ical extends calendar_boupdate
break; break;
case 'file': // used outside of SyncML, eg. by the calendar itself ==> all possible fields case 'file': // used outside of SyncML, eg. by the calendar itself ==> all possible fields
$this->tzid = false; // use event's TZ
$this->supportedFields = $defaultFields['full']; $this->supportedFields = $defaultFields['full'];
break; break;
case 'groupdav': // all GroupDAV access goes through here case 'groupdav': // all GroupDAV access goes through here
$this->tzid = false; // use event's TZ
switch ($this->productName) switch ($this->productName)
{ {
default: default:
@ -1929,13 +1927,21 @@ class calendar_ical extends calendar_boupdate
default: default:
error_log("Unknown calendar SyncML client: manufacturer='$this->productManufacturer' product='$this->productName'"); error_log("Unknown calendar SyncML client: manufacturer='$this->productManufacturer' product='$this->productName'");
$this->supportedFields = $defaultFields['synthesis']; $this->supportedFields = $defaultFields['synthesis'];
break;
} }
// for palmos we have to use user-time and NO timezone
if (strpos($this->productName, 'palmos') !== false) if ($this->log)
{ {
$this->tzid = false; error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
'(' . $this->productManufacturer .
', '. $this->productName .', ' .
($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .
")\n" , 3, $this->logfile);
} }
//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
// . $this->productName .', ' .
// ($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .')',
// __FILE__, __LINE__, PEAR_LOG_DEBUG);
} }
function icaltoegw($_vcalData) function icaltoegw($_vcalData)
@ -2784,35 +2790,4 @@ class calendar_ical extends calendar_boupdate
return $vcal->exportvCalendar(); return $vcal->exportvCalendar();
} }
/**
* update the status of all participant for a given recurrence or for all recurrences since now (includes recur_date=0)
*
* @param array $new_event event-array with the new stati
* @param array $old_event event-array with the old stati
* @param int $recur_date=0 date to change, or 0 = all since now
*/
function update_status($new_event, $old_event , $recur_date=0)
{
if (!isset($new_event['participants'])) return;
// check the old list against the new list
foreach ($old_event['participants'] as $userid => $status)
{
if (!isset($new_event['participants'][$userid])){
// Attendee will be deleted this way
$new_event['participants'][$userid] = 'G';
}
elseif ($new_event['participants'][$userid] == $status)
{
// Same status -- nothing to do.
unset($new_event['participants'][$userid]);
}
}
// write the changes
foreach ($new_event['participants'] as $userid => $status)
{
$this->set_status($old_event, $userid, $status, $recur_date, true, false);
}
}
} }