diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index 0593427a1d..a2312929ba 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -67,6 +67,7 @@ class calendar_boupdate extends calendar_bo * @var boolean */ var $log = false; + var $logfile = '/tmp/log-calendar-boupdate'; /** * Cached timezone data @@ -1077,7 +1078,7 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - "($cal_id, $uid, $status, $recur_date)"); + "($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile); } $old_event = $this->read($cal_id, $recur_date, false, 'server'); if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0], @@ -1500,13 +1501,11 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - "($filter)[EVENT]:" . array2string($event)); + "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); } if ($filter == 'master') { - // No chance to find a master without [U]ID - if (emtpy($event['uid']) && empty($event['id'])) return $matchingEvents; $query[] = 'recur_type!='. MCAL_RECUR_NONE; $query['cal_recurrence'] = 0; } @@ -1518,14 +1517,14 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '(' . $event['id'] . ")[EventID]"); + '(' . $event['id'] . ")[EventID]\n",3,$this->logfile); } if (($egwEvent = $this->read($event['id'], 0, false, 'server'))) { if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '()[FOUND]:' . array2string($egwEvent)); + '()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile); } if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && (empty($event['uid']) || $event['uid'] == $egwEvent['uid'])) @@ -1558,6 +1557,9 @@ class calendar_boupdate extends calendar_bo } unset($event['id']); + // No chance to find a master without [U]ID + if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; + // only query calendars of users, we have READ-grants from $users = array(); foreach(array_keys($this->grants) as $user) @@ -1646,7 +1648,15 @@ class calendar_boupdate extends calendar_bo $query[] = ('cal_start<' . ($event['start'] + 2)); } } - $matchFields = array('priority', 'public', 'non_blocking', 'recurrence'); + if ($filter == 'relax') + { + $matchFields = array(); + } + else + { + $matchFields = array('priority', 'public', 'non_blocking'); + } + $matchFields[] = 'recurrence'; foreach ($matchFields as $key) { if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; @@ -1658,14 +1668,14 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '(' . $event['uid'] . ')[EventUID]'); + '(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile); } } if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '[QUERY]: ' . array2string($query)); + '[QUERY]: ' . array2string($query)."\n",3,$this->logfile); } if (!count($users) || !($foundEvents = $this->so->search(null, null, $users, 0, 'owner', $query))) @@ -1673,7 +1683,7 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '[NO MATCH]'); + "[NO MATCH]\n",3,$this->logfile); } return $matchingEvents; } @@ -1685,7 +1695,7 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '[FOUND]: ' . array2string($egwEvent)); + '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); } if (in_array($egwEvent['id'], $matchingEvents)) continue; @@ -1723,7 +1733,7 @@ class calendar_boupdate extends calendar_bo continue; } - if (!empty($event['uid']) && $filter == 'exact') break; + if (!empty($event['uid']) && $filter == 'exact' || $filter == 'master') break; // check times if ($filter != 'relax') @@ -1735,19 +1745,19 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '() egwEvent is not a whole-day event!'); + "() egwEvent is not a whole-day event!\n",3,$this->logfile); } continue; } } - elseif ($filter != 'master') + else { if (abs($event['end'] - $egwEvent['end']) >= 120) { if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '() egwEvent length does not match!'); + "() egwEvent length does not match!\n",3,$this->logfile); } continue; } @@ -1755,15 +1765,10 @@ class calendar_boupdate extends calendar_bo } // check for real match - $matchFields = array('title'); - switch ($filter) + $matchFields = array('title', 'description'); + if ($filter != 'relax') { - case 'master': - break; - case 'relax': - $matchFields[] = 'location'; - default: - $matchFields[] = 'description'; + $matchFields[] = 'location'; } foreach ($matchFields as $key) { @@ -1774,13 +1779,13 @@ class calendar_boupdate extends calendar_bo { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "() event[$key] differ: '" . $event[$key] . - "' <> '" . $egwEvent[$key]) . "'"; + "' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile); } continue 2; // next foundEvent } } - if ($filter != 'master' && is_array($event['category'])) + if (is_array($event['category'])) { // check categories $egwCategories = explode(',', $egwEvent['category']); @@ -1792,7 +1797,7 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - "() egwEvent category $cat_id is missing!"); + "() egwEvent category $cat_id is missing!\n",3,$this->logfile); } continue 2; } @@ -1803,13 +1808,14 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '() event has additional categories:' . array2string($newCategories)); + '() event has additional categories:' + . array2string($newCategories)."\n",3,$this->logfile); } continue; } } - if ($filter != 'relax' && $filter != 'master') + if ($filter != 'relax') { // check participants if (is_array($event['participants'])) @@ -1823,7 +1829,7 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - "() additional event['participants']: $attendee"); + "() additional event['participants']: $attendee\n",3,$this->logfile); } continue 2; } @@ -1840,78 +1846,74 @@ class calendar_boupdate extends calendar_bo { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. '() missing event[participants]: ' . - array2string($egwEvent['participants'])); + array2string($egwEvent['participants'])."\n",3,$this->logfile); } continue; } } } - if ($filter != 'master') + if ($event['recur_type'] == MCAL_RECUR_NONE) { - if ($event['recur_type'] == MCAL_RECUR_NONE) + if ($egwEvent['recur_type'] != MCAL_RECUR_NONE) { - if ($egwEvent['recur_type'] != MCAL_RECUR_NONE) - { - // We found a pseudo Exception - $pseudos[] = $egwEvent['id'] . ':' . $event['start']; - continue; - } + // We found a pseudo Exception + $pseudos[] = $egwEvent['id'] . ':' . $event['start']; + continue; } - elseif ($filter != 'relax') + } + elseif ($filter != 'relax') + { + // check exceptions + // $exceptions[$remote_ts] = $egw_ts + $exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['$tzid'], 0, 0, 'map'); + if (is_array($event['recur_exception'])) { - // check exceptions - // $exceptions[$remote_ts] = $egw_ts - $exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['$tzid'], 0, 0, 'map'); - if (is_array($event['recur_exception'])) + foreach ($event['recur_exception'] as $key => $day) { - foreach ($event['recur_exception'] as $key => $day) + if (isset($exceptions[$day])) { - if (isset($exceptions[$day])) - { - unset($exceptions[$day]); - } - else - { - if ($this->log) - { - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - "() additional event['recur_exception']: $day"); - } - continue 2; - } + unset($exceptions[$day]); } - if (!empty($exceptions)) + else { if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '() missing event[recur_exception]: ' . - array2string($event['recur_exception'])); - } - continue; - } - } - - // check recurrence information - foreach (array('recur_type', 'recur_interval', 'recur_enddate') as $key) - { - if (isset($event[$key]) - && $event[$key] != $egwEvent[$key]) - { - if ($this->log) - { - error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - "() events[$key] differ: " . $event[$key] . - ' <> ' . $egwEvent[$key]); + "() additional event['recur_exception']: $day\n",3,$this->logfile); } continue 2; } } + if (!empty($exceptions)) + { + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. + '() missing event[recur_exception]: ' . + array2string($event['recur_exception'])); + } + continue; + } + } + + // check recurrence information + foreach (array('recur_type', 'recur_interval', 'recur_enddate') as $key) + { + if (isset($event[$key]) + && $event[$key] != $egwEvent[$key]) + { + if ($this->log) + { + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. + "() events[$key] differ: " . $event[$key] . + ' <> ' . $egwEvent[$key]."\n",3,$this->logfile); + } + continue 2; + } } } $matchingEvents[] = $egwEvent['id']; // exact match - if ($filter = 'master') break; } // append pseudos as last entries $matchingEvents = array_merge($matchingEvents, $pseudos); @@ -1919,7 +1921,7 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '[MATCHES]:' . array2string($matchingEvents)); + '[MATCHES]:' . array2string($matchingEvents)."\n",3,$this->logfile); } return $matchingEvents; } @@ -1992,7 +1994,7 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - "()[MASTER]: $eventID"); + "()[MASTER]: $eventID\n",3,$this->logfile); } if (($master_event = $this->read($eventID, 0, false, 'server'))) { @@ -2029,7 +2031,8 @@ class calendar_boupdate extends calendar_bo if ($this->log) { error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. - '() try occurrence ' . $egw_rrule->current() . " ($occurrence)"); + '() try occurrence ' . $egw_rrule->current() + . " ($occurrence)\n",3,$this->logfile); } if ($event['start'] == $occurrence) {