forked from extern/egroupware
Improved find_event() for propper pseudo recurrence exception handling during Slow Syncs
This commit is contained in:
parent
d9531fb421
commit
327bd79662
@ -1120,26 +1120,52 @@ class calendar_boupdate extends calendar_bo
|
||||
*/
|
||||
function find_event($event, $relax=false)
|
||||
{
|
||||
$query = array(
|
||||
'cal_start='.$event['start'],
|
||||
'cal_end='.$event['end'],
|
||||
);
|
||||
|
||||
foreach (array('title', 'location',
|
||||
'public', 'non_blocking', 'category') as $key)
|
||||
{
|
||||
if (!empty($event[$key])) $query['cal_'.$key] = $event[$key];
|
||||
}
|
||||
|
||||
if ($event['uid'] && ($uidmatch = $this->read($event['uid'])))
|
||||
{
|
||||
if ($event['recurrence']
|
||||
&& ($egw_event = $this->read($uidmatch['id'], $event['recurrence'])))
|
||||
if ($event['recurrence'])
|
||||
{
|
||||
// Do we work with a "status only" exception here?
|
||||
// Let's try to find a real exception first
|
||||
$query['cal_uid'] = $event['uid'];
|
||||
$query['cal_recurrence'] = $event['recurrence'];
|
||||
|
||||
if($foundEvents = parent::search(array(
|
||||
'query' => $query,
|
||||
)))
|
||||
{
|
||||
if(is_array($foundEvents))
|
||||
{
|
||||
$event = array_shift($foundEvents);
|
||||
return $event['id'];
|
||||
}
|
||||
}
|
||||
// Let's try the "status only" (pseudo) exceptions now
|
||||
if (($egw_event = $this->read($uidmatch['id'], $event['recurrence'])))
|
||||
{
|
||||
// Do we work with a pseudo exception here?
|
||||
$match = true;
|
||||
foreach (array('start', 'end', 'title', 'description', 'priority',
|
||||
'location','public','non_blocking') as $name)
|
||||
'location', 'public', 'non_blocking') as $key)
|
||||
{
|
||||
if (isset($event[$name])
|
||||
&& $event[$name] != $egw_event[$name])
|
||||
if (isset($event[$key])
|
||||
&& $event[$key] != $egw_event[$key])
|
||||
{
|
||||
$match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($match)
|
||||
if ($match && is_array($event['participants']))
|
||||
{
|
||||
//return ($uidmatch['id'] . ':' . $event['reference']);
|
||||
foreach ($event['participants'] as $attendee => $status)
|
||||
{
|
||||
if (!isset($egw_event['participants'][$attendee])
|
||||
@ -1157,7 +1183,8 @@ class calendar_boupdate extends calendar_bo
|
||||
}
|
||||
if ($match) return ($uidmatch['id'] . ':' . $event['recurrence']);
|
||||
|
||||
return false; // We need to create a new "status only" exception
|
||||
return false; // We need to create a new pseudo exception
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1177,19 +1204,7 @@ class calendar_boupdate extends calendar_bo
|
||||
}
|
||||
unset($event['id']);
|
||||
|
||||
$query = array(
|
||||
'cal_start='.$event['start'],
|
||||
'cal_end='.$event['end'],
|
||||
);
|
||||
|
||||
#foreach(array('title','location','priority','public','non_blocking','category') as $name) {
|
||||
foreach (array('title','location','public','non_blocking','category') as $name)
|
||||
{
|
||||
if (!empty($event[$name])) $query['cal_'.$name] = $event[$name];
|
||||
}
|
||||
|
||||
if($foundEvents = parent::search(array(
|
||||
//'user' => $this->user,
|
||||
'query' => $query,
|
||||
)))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user