Fix CTag issues for GroupDAV

This commit is contained in:
Jörg Lehrke 2010-06-29 13:52:56 +00:00
parent 6558a861a1
commit 09bc2c09cd
4 changed files with 45 additions and 30 deletions

View File

@ -392,9 +392,17 @@ class addressbook_groupdav extends groupdav_handler
if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null;
$result = $this->bo->search(array(),'MAX(contact_modified) AS contact_modified','','','',false,'AND',false,$filter);
$ctag = 'EGw-'.$result[0]['contact_modified'].'-wGE';
return $ctag;
if (empty($result))
{
$ctag = $result[0]['contact_modified'];
}
else
{
$ctag = time();
}
return 'EGw-'.$ctag.'-wGE';
}
/**

View File

@ -758,34 +758,11 @@ error_log(__METHOD__."($path,,".array2string($start).") filter=".array2string($f
*/
public function getctag($path,$user)
{
if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user]");
$ctag = $GLOBALS['egw']->contenthistory->getLastChange('calendar');
if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
$filter = array(
'users' => $user,
'start' => time()-100*24*3600, // default one month back -30 breaks all sync recurrences
'end' => time()+365*24*3600, // default one year into the future +365
'enum_recuring' => false,
'daywise' => false,
'date_format' => 'server',
'order' => 'cal_modified DESC,cal_etag DESC',
'offset' => 0,
'num_rows' => 1,
);
if (strpos($path, '/calendar') === 0)
{
$filter['filter'] = 'owner';
}
else
{
$filter['filter'] = 'default'; // not rejected
}
$result =& $this->bo->search($filter);
$entry = array_shift($result);
return $this->get_etag($entry);
return 'EGw-'.$ctag.'-wGE';
}
/**

View File

@ -512,6 +512,8 @@ class infolog_groupdav extends groupdav_handler
);
$result =& $this->bo->search($query);
if (empty($result)) return 'EGw-'.time().'-wGE';
$entry = array_shift($result);

View File

@ -170,4 +170,32 @@ class contenthistory
}
return true;
}
/**
* get the timestamp of last change for appname
*
* find which content changed since $_ts for application $_appName
*
* @param string$_appName the appname example: infolog_notes
*
* @return timestamp of last change for this application
*/
function getLastChange($_appName)
{
$max = 0;
$where = array('sync_appname' => $_appName);
foreach (array('modified','deleted','added') as $action)
{
if (($ts = $this->db->select(self::TABLE,'MAX(sync_'.$action.')',$where,__LINE__,__FILE__)->fetchColumn()))
{
$ts = $this->db->from_timestamp($ts);
if ($ts > $max) $max = $ts;
}
}
return $max;
}
}