diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 4b1114df5d..4bb124b7df 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -22,7 +22,7 @@ class addressbook_groupdav extends groupdav_handler /** * bo class of the application * - * @var addressbook_vcal + * @var addressbook_bo */ var $bo; @@ -307,6 +307,24 @@ class addressbook_groupdav extends groupdav_handler return true; } + /** + * Query ctag for addressbook + * + * @return string + */ + public function getctag($path,$user) + { + $filter = array(); + // show addressbook of a single user? + if ($user && $path != '/addressbook/') $filter['contact_owner'] = $user; + // should we hide the accounts addressbook + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null; + + $result = $this->bo->search(array(),'MAX(contact_modified) AS contact_modified','','','','','',$filter); + + return date('Y-m-d H:i:s',$result[0]['modified']); + } + /** * Get the handler and set the supported fields * diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index b10d050de4..703823bf14 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -48,6 +48,10 @@ class groupdav extends HTTP_WebDAV_Server * CardDAV namespace */ const CARDDAV = 'urn:ietf:params:xml:ns:carddav'; + /** + * Calendarserver namespace (eg. for ctag) + */ + const CALENDARSERVER = 'http://calendarserver.org/ns/'; /** * Realm and powered by string */ @@ -229,7 +233,7 @@ class groupdav extends HTTP_WebDAV_Server { if ($method != 'REPORT' && !$id) // no self URL for REPORT requests (only PROPFIND) or propfinds on an id { - $files['files'][] = array( + $files['files'][0] = array( 'path' => '/'.$app.'/', // KAddressbook doubles the folder, if the self URL contains the GroupDAV/CalDAV resourcetypes 'props' => $this->_properties($app,$app=='addressbook'&&strpos($_SERVER['HTTP_USER_AGENT'],'KHTML') !== false), @@ -237,6 +241,12 @@ class groupdav extends HTTP_WebDAV_Server } if (!$options['depth'] && !$id) { + // add ctag if handler implements it (only for depth 0) + if (method_exists($handler,'getctag')) + { + $files['files'][0]['props'][] = HTTP_WebDAV_Server::mkprop( + groupdav::CALENDARSERVER,'getctag',$handler->getctag($options['path'],$user)); + } return true; // depth 0 --> show only the self url } return $handler->propfind($options['path'],$options,$files,$user,$id);