move etag to calendar_bo

This commit is contained in:
Ralf Becker 2010-11-26 21:32:10 +00:00
parent 8df8817318
commit 07e09c71d8
2 changed files with 50 additions and 35 deletions

View File

@ -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;
}
}

View File

@ -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';
}