From 0950ff12dcfe5692867abc28bdbdfe5b1839391b Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Tue, 28 Jan 2014 15:51:09 +0100 Subject: [PATCH] Tag contacts that have a birthday date set and allow to directly select them --- .../lib/rcube_kolab_contacts.php | 5 +++++ plugins/libkolab/lib/kolab_format_contact.php | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php index bc209704..3fc85275 100644 --- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php +++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php @@ -400,6 +400,11 @@ class rcube_kolab_contacts extends rcube_addressbook // NOTE: this is only some rough pre-filtering but probably includes false positives $squery = $this->_search_query($fields, $value, $mode); + // add magic selector to select contacts with birthday dates only + if (in_array('birthday', $required)) { + $squery[] = array('tags', '=', 'x-has-birthday'); + } + // get all/matching records $this->_fetch_contacts($squery); diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php index a96312a5..63efe9ae 100644 --- a/plugins/libkolab/lib/kolab_format_contact.php +++ b/plugins/libkolab/lib/kolab_format_contact.php @@ -407,6 +407,22 @@ class kolab_format_contact extends kolab_format return array_unique(rcube_utils::normalize_string($data, true)); } + /** + * Callback for kolab_storage_cache to get object specific tags to cache + * + * @return array List of tags to save in cache + */ + public function get_tags() + { + $tags = array(); + + if (!empty($this->data['birthday'])) { + $tags[] = 'x-has-birthday'; + } + + return $tags; + } + /** * Helper method to copy contents of an Address vector to the contact data object */