From 07e09c71d814f3601b63e1b6dc866e469c2af9df Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 26 Nov 2010 21:32:10 +0000 Subject: [PATCH] move etag to calendar_bo --- calendar/inc/class.calendar_bo.inc.php | 49 ++++++++++++++++++++ calendar/inc/class.calendar_groupdav.inc.php | 36 +------------- 2 files changed, 50 insertions(+), 35 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index f8f590696e..f63b2d95c7 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -1850,4 +1850,53 @@ class calendar_bo return !$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59; } + + /** + * Get the etag for an entry, reimplemented to include the participants and stati in the etag + * + * @param array|int $event array with event or cal_id + * @param boolean $client_share_uid_excpetions Does client understand exceptions to be included in VCALENDAR component of series master sharing its UID + * @return string|boolean string with etag or false + */ + function get_etag($entry,$client_share_uid_excpetions=true) + { + if (!is_array($entry)) + { + if (!$this->check_perms(EGW_ACL_FREEBUSY, $entry, 0, 'server')) return false; + $entry = $this->read($entry, null, true, 'server'); + } + $etag = $entry['id'].':'.$entry['etag']; + + // use new MAX(modification date) of egw_cal_user table (deals with virtual exceptions too) + if (isset($entry['max_user_modified'])) + { + $modified = max($entry['max_user_modified'], $entry['modified']); + } + else + { + $modified = max($this->so->max_user_modified($entry['id']), $entry['modified']); + } + $etag .= ':' . $modified; + // include exception etags into our own etag, if exceptions are included + if ($client_shared_uid_exceptions && !empty($entry['uid']) && + $entry['recur_type'] != MCAL_RECUR_NONE && $entry['recur_exception']) + { + $events =& $this->search(array( + 'query' => array('cal_uid' => $entry['uid']), + 'filter' => 'owner', // return all possible entries + 'daywise' => false, + 'enum_recuring' => false, + 'date_format' => 'server', + )); + foreach($events as $k => &$recurrence) + { + if ($recurrence['reference'] && $recurrence['id'] != $entry['id']) // ignore series master + { + $etag .= ':'.substr($this->get_etag($recurrence),4,-4); + } + } + } + //error_log(__METHOD__ . "($entry[id] ($entry[etag]): $entry[title] --> etag=$etag"); + return $etag; + } } diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index b55411672d..1c10d586bd 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -833,42 +833,8 @@ error_log(__METHOD__."($path,,".array2string($start).") filter=".array2string($f */ function get_etag($entry) { - if (!is_array($entry)) - { - if (!$this->bo->check_perms(EGW_ACL_FREEBUSY, $entry, 0, 'server')) return false; - $entry = $this->read($entry, null, true, 'server'); - } - $etag = $entry['id'].':'.$entry['etag']; + $etag = $this->bo->get_etag($entry,$this->client_shared_uid_exceptions); - // use new MAX(modification date) of egw_cal_user table (deals with virtual exceptions too) - if (isset($entry['max_user_modified'])) - { - $modified = max($entry['max_user_modified'], $entry['modified']); - } - else - { - $modified = max($this->bo->so->max_user_modified($entry['id']), $entry['modified']); - } - $etag .= ':' . $modified; - // include exception etags into our own etag, if exceptions are included - if ($this->client_shared_uid_exceptions && !empty($entry['uid']) && - $entry['recur_type'] != MCAL_RECUR_NONE && $entry['recur_exception']) - { - $events =& $this->bo->search(array( - 'query' => array('cal_uid' => $entry['uid']), - 'filter' => 'owner', // return all possible entries - 'daywise' => false, - 'enum_recuring' => false, - 'date_format' => 'server', - )); - foreach($events as $k => &$recurrence) - { - if ($recurrence['reference'] && $recurrence['id'] != $entry['id']) // ignore series master - { - $etag .= ':'.substr($this->get_etag($recurrence),4,-4); - } - } - } //error_log(__METHOD__ . "($entry[id] ($entry[etag]): $entry[title] --> etag=$etag"); return 'EGw-'.$etag.'-wGE'; }