mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-14 09:58:16 +01:00
moved ctag to calendar_bo, to use it in CalDAV and ActiveSync, thought it needs to be reworked, as it is to expensive performance-wise
This commit is contained in:
parent
96d44948f7
commit
9981730b29
@ -308,10 +308,32 @@ list(,,$etag) = explode(':',$etag);
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo implement using ctag
|
* Return a changes array
|
||||||
|
*
|
||||||
|
* if changes occurr default diff engine computes the actual changes
|
||||||
|
*
|
||||||
|
* @param string $folderid
|
||||||
|
* @param string &$syncstate on call old syncstate, on return new syncstate
|
||||||
|
* @return array|boolean false if $folderid not found, array() if no changes or array(array("type" => "fakeChange"))
|
||||||
*/
|
*/
|
||||||
function AlterPingChanges($folderid, &$syncstate)
|
function AlterPingChanges($folderid, &$syncstate)
|
||||||
{
|
{
|
||||||
return false;
|
$this->backend->splitID($folderid, $type, $owner);
|
||||||
|
|
||||||
|
if ($type != 'calendar') return false;
|
||||||
|
|
||||||
|
if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
|
||||||
|
$ctag = $this->calendar->get_ctag($owner);
|
||||||
|
|
||||||
|
$changes = array(); // no change
|
||||||
|
$syncstate_was = $syncstate;
|
||||||
|
|
||||||
|
if ($ctag !== $syncstate)
|
||||||
|
{
|
||||||
|
$syncstate = $ctag;
|
||||||
|
$changes = array(array('type' => 'fakeChange'));
|
||||||
|
}
|
||||||
|
//error_log(__METHOD__."('$folderid','$syncstate_was') syncstate='$syncstate' returning ".array2string($changes));
|
||||||
|
return $changes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1908,4 +1908,40 @@ class calendar_bo
|
|||||||
//error_log(__METHOD__ . "($entry[id] ($entry[etag]): $entry[title] --> etag=$etag");
|
//error_log(__METHOD__ . "($entry[id] ($entry[etag]): $entry[title] --> etag=$etag");
|
||||||
return $etag;
|
return $etag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query ctag for calendar
|
||||||
|
*
|
||||||
|
* @param $user
|
||||||
|
* @param $filter='owner'
|
||||||
|
* @return string
|
||||||
|
* @todo use MAX(modified) to query everything in one sql query, currently we do one query per event (more then the search)
|
||||||
|
*/
|
||||||
|
public function get_ctag($user,$filter='owner')
|
||||||
|
{
|
||||||
|
$filter = array(
|
||||||
|
'users' => $user,
|
||||||
|
'start' => $this->bo->now - 100*24*3600, // default one month back -30 breaks all sync recurrences
|
||||||
|
'end' => $this->bo->now + 365*24*3600, // default one year into the future +365
|
||||||
|
'enum_recuring' => false,
|
||||||
|
'daywise' => false,
|
||||||
|
'date_format' => 'server',
|
||||||
|
'cols' => array('egw_cal.cal_id', 'cal_start', 'cal_modified'),
|
||||||
|
'filter' => $filter,
|
||||||
|
);
|
||||||
|
|
||||||
|
$ctag = 0;
|
||||||
|
if (($events =& $this->bo->search($filter)))
|
||||||
|
{
|
||||||
|
foreach ($events as $event)
|
||||||
|
{
|
||||||
|
$modified = max($this->bo->so->max_user_modified($event['cal_id']), $event['cal_modified']);
|
||||||
|
if ($ctag < $modified) $ctag = $modified;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
|
||||||
|
|
||||||
|
return $ctag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -790,35 +790,7 @@ error_log(__METHOD__."($path,,".array2string($start).") filter=".array2string($f
|
|||||||
*/
|
*/
|
||||||
public function getctag($path,$user)
|
public function getctag($path,$user)
|
||||||
{
|
{
|
||||||
$filter = array(
|
$ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
|
||||||
'users' => $user,
|
|
||||||
'start' => $this->bo->now - 100*24*3600, // default one month back -30 breaks all sync recurrences
|
|
||||||
'end' => $this->bo->now + 365*24*3600, // default one year into the future +365
|
|
||||||
'enum_recuring' => false,
|
|
||||||
'daywise' => false,
|
|
||||||
'date_format' => 'server',
|
|
||||||
'cols' => array('egw_cal.cal_id', 'cal_start', 'cal_modified'),
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($path == '/calendar/')
|
|
||||||
{
|
|
||||||
$filter['filter'] = 'owner';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$filter['filter'] = 'default'; // not rejected
|
|
||||||
}
|
|
||||||
|
|
||||||
$ctag = 0;
|
|
||||||
|
|
||||||
if (($events =& $this->bo->search($filter)))
|
|
||||||
{
|
|
||||||
foreach ($events as $event)
|
|
||||||
{
|
|
||||||
$modified = max($this->bo->so->max_user_modified($event['cal_id']), $event['cal_modified']);
|
|
||||||
if ($ctag < $modified) $ctag = $modified;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
|
if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user