From 6f1c2eacaca223d728a80f89e015177bfd75c04f Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 31 Jan 2012 20:06:27 +0000 Subject: [PATCH] extend ctag to lists --- .../inc/class.addressbook_groupdav.inc.php | 2 +- addressbook/inc/class.addressbook_so.inc.php | 13 +++++++++++++ addressbook/inc/class.addressbook_sql.inc.php | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 757d5d2dd0..0b66a4a478 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -623,7 +623,7 @@ class addressbook_groupdav extends groupdav_handler // not showing addressbook of a single user? if (!$user || $path == '/addressbook/') $user = null; - return $this->bo->get_ctag($user); + return max($this->bo->get_ctag($user),$this->bo->lists_ctag($user)); } /** diff --git a/addressbook/inc/class.addressbook_so.inc.php b/addressbook/inc/class.addressbook_so.inc.php index 492be93071..0db0473d04 100755 --- a/addressbook/inc/class.addressbook_so.inc.php +++ b/addressbook/inc/class.addressbook_so.inc.php @@ -1057,4 +1057,17 @@ class addressbook_so return method_exists($backend,'read_list'); } + + /** + * Get ctag (max list_modified as timestamp) for lists + * + * @param int|array $owner=null null for all lists user has access too + * @return int + */ + function lists_ctag($owner=null) + { + if (!method_exists($this->somain,'read_list')) return 0; + + return $this->somain->lists_ctag($owner); + } } diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index 37d1f8cb16..0de409fdad 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -646,6 +646,24 @@ class addressbook_sql extends so_sql_cf return $this->db->affected_rows(); } + /** + * Get ctag (max list_modified as timestamp) for lists + * + * @param int|array $owner=null null for all lists user has access too + * @return int + */ + function lists_ctag($owner=null) + { + if (is_null($owner)) $owner = array_keys($this->grants); + + if (!($modified = $this->db->select($this->lists_table,'MAX(list_modified)',array('list_owner'=>$owner), + __LINE__,__FILE__)->fetchColumn())) + { + return 0; + } + return $this->db->from_timestamp($modified); + } + /** * Reads a contact, reimplemented to use the uid, if a non-numeric key is given *