diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 70ae27d8b8..c0a02124f9 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -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'; } /** diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index f534b2f1d1..2ce33651ef 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -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'; } /** diff --git a/infolog/inc/class.infolog_groupdav.inc.php b/infolog/inc/class.infolog_groupdav.inc.php index b50c135568..7f2b792af7 100644 --- a/infolog/inc/class.infolog_groupdav.inc.php +++ b/infolog/inc/class.infolog_groupdav.inc.php @@ -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); diff --git a/phpgwapi/inc/class.contenthistory.inc.php b/phpgwapi/inc/class.contenthistory.inc.php index 2c0ad1f5f7..36c49c2a5f 100644 --- a/phpgwapi/inc/class.contenthistory.inc.php +++ b/phpgwapi/inc/class.contenthistory.inc.php @@ -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; + } + }