From 52ea4512cadc8c815ff09c90577f951233829249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Thu, 11 Feb 2010 07:33:32 +0000 Subject: [PATCH] Improve find_event() again --- calendar/inc/class.calendar_boupdate.inc.php | 35 ++++++++++---------- calendar/inc/class.calendar_ical.inc.php | 2 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index fb91a471aa..3ff991124d 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -1421,7 +1421,8 @@ class calendar_boupdate extends calendar_bo * Try to find a matching db entry * * @param array $event the vCalendar data we try to find - * @param string filter='exact' exact -> check for identical matches + * @param string filter='exact' exact -> find the matching entry + * check -> check (consitency) for identical matches * relax -> be more tolerant * master -> try to find a releated series master * @return array calendar_ids of matching entries @@ -1470,7 +1471,7 @@ class calendar_boupdate extends calendar_bo } // Just a simple consistency check if ($filter == 'master' && $egwEvent['recur_type'] != MCAL_RECUR_NONE || - strpos($egwEvent['title'], $event['title']) === 0) + $filter == 'exact' || strpos($egwEvent['title'], $event['title']) === 0) { $retval = $egwEvent['id']; if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && @@ -1482,7 +1483,7 @@ class calendar_boupdate extends calendar_bo return $matchingEvents; } } - if ($filter == 'exact') return array(); + if ($filter == 'exact' || $filter == 'check') return array(); } unset($event['id']); @@ -1542,7 +1543,7 @@ class calendar_boupdate extends calendar_bo } } } - if ($filter == 'relax' || empty($event['uid'])) + if ($filter != 'master') { if (isset($event['whole_day']) && $event['whole_day']) { @@ -1565,19 +1566,17 @@ class calendar_boupdate extends calendar_bo } elseif (isset($event['start'])) { - if ($filter != 'master') + + if ($filter == 'relax') { - if ($filter == 'relax') - { - $query[] = ('cal_start>' . ($event['start'] - 3600)); - $query[] = ('cal_start<' . ($event['start'] + 3600)); - } - else - { - // we accept a tiny tolerance - $query[] = ('cal_start>' . ($event['start'] - 2)); - $query[] = ('cal_start<' . ($event['start'] + 2)); - } + $query[] = ('cal_start>' . ($event['start'] - 3600)); + $query[] = ('cal_start<' . ($event['start'] + 3600)); + } + else + { + // we accept a tiny tolerance + $query[] = ('cal_start>' . ($event['start'] - 2)); + $query[] = ('cal_start<' . ($event['start'] + 2)); } } $matchFields = array('priority', 'public', 'non_blocking', 'recurrence'); @@ -1586,7 +1585,7 @@ class calendar_boupdate extends calendar_bo if (!empty($event[$key])) $query['cal_'.$key] = $event[$key]; } } - else + if (!empty($event['uid'])) { $query['cal_uid'] = $event['uid']; if ($this->log) @@ -1628,7 +1627,7 @@ class calendar_boupdate extends calendar_bo '[FOUND]: ' . array2string($egwEvent)); } - if ($filter == 'exact' && !empty($event['uid'])) + if ($filter == 'chec' && !empty($event['uid'])) { $matchingEvents[] = $egwEvent['id']; // UID found continue; diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index 5ab0a284d0..7a62111d79 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -2618,7 +2618,7 @@ class calendar_ical extends calendar_boupdate // this function only supports searching a single event if (count($events) == 1) { - $filter = $relax ? 'relax' : 'exact'; + $filter = $relax ? 'relax' : 'check'; $event = array_shift($events); if ($this->so->isWholeDay($event)) $event['whole_day'] = true; if ($contentID) $event['id'] = $contentID;