diff --git a/plugins/libkolab/lib/kolab_storage_cache_configuration.php b/plugins/libkolab/lib/kolab_storage_cache_configuration.php index c3c7ac4f..a5ac396d 100644 --- a/plugins/libkolab/lib/kolab_storage_cache_configuration.php +++ b/plugins/libkolab/lib/kolab_storage_cache_configuration.php @@ -32,20 +32,37 @@ class kolab_storage_cache_configuration extends kolab_storage_cache */ protected function _serialize($object) { + $this->set_data_props($object['type']); + $sql_data = parent::_serialize($object); $sql_data['type'] = $object['type']; return $sql_data; } + /** + * Helper method to convert database record to the given Kolab object + * + * @override + */ + protected function _unserialize($sql_arr) + { + $this->set_data_props($sql_arr['type']); + + return parent::_unserialize($sql_arr); + } + /** * Select Kolab objects filtered by the given query * - * @param array Pseudo-SQL query as list of filter parameter triplets + * @param array Pseudo-SQL query as list of filter parameter triplets * @param boolean Set true to only return UIDs instead of complete objects + * @param boolean Use fast mode to fetch only minimal set of information + * (no xml fetching and parsing, etc.) + * * @return array List of Kolab data objects (each represented as hash array) or UIDs */ - public function select($query = array(), $uids = false) + public function select($query = array(), $uids = false, $fast = false) { // modify query for IMAP search: query param 'type' is actually a subtype if (!$this->ready) { @@ -57,7 +74,7 @@ class kolab_storage_cache_configuration extends kolab_storage_cache } } - return parent::select($query, $uids); + return parent::select($query, $uids, $fast); } /** @@ -85,4 +102,35 @@ class kolab_storage_cache_configuration extends kolab_storage_cache return parent::_sql_where($query); } + + /** + * Set $data_props property depending on object type + */ + protected function set_data_props($type) + { + switch ($type) { + case 'dictionary': + $this->data_props = array('language', 'e'); + break; + + case 'file_driver': + $this->data_props = array('driver', 'title', 'enabled', 'host', 'port', 'username', 'password'); + break; + + case 'relation': + // Note: Because relations are heavily used, for performance reasons + // we store all properties for them + $this->data_props = array('name', 'category', 'color', 'parent', 'iconName', 'priority', 'members'); + break; + + case 'snippet': + $this->data_props = array('name'); + break; + + case 'category': + default: + // TODO: implement this + $this->data_props = array(); + } + } } diff --git a/plugins/libkolab/lib/kolab_storage_cache_contact.php b/plugins/libkolab/lib/kolab_storage_cache_contact.php index 6f3a0c9a..a8a475a5 100644 --- a/plugins/libkolab/lib/kolab_storage_cache_contact.php +++ b/plugins/libkolab/lib/kolab_storage_cache_contact.php @@ -70,4 +70,4 @@ class kolab_storage_cache_contact extends kolab_storage_cache return $sql_data; } -} \ No newline at end of file +} diff --git a/plugins/libkolab/lib/kolab_storage_cache_note.php b/plugins/libkolab/lib/kolab_storage_cache_note.php index 7f5ebc8e..3211da57 100644 --- a/plugins/libkolab/lib/kolab_storage_cache_note.php +++ b/plugins/libkolab/lib/kolab_storage_cache_note.php @@ -24,4 +24,4 @@ class kolab_storage_cache_note extends kolab_storage_cache { protected $data_props = array('title'); -} \ No newline at end of file +} diff --git a/plugins/libkolab/lib/kolab_storage_config.php b/plugins/libkolab/lib/kolab_storage_config.php index fb442ece..b29e7a90 100644 --- a/plugins/libkolab/lib/kolab_storage_config.php +++ b/plugins/libkolab/lib/kolab_storage_config.php @@ -131,7 +131,7 @@ class kolab_storage_config $folder->set_order_and_limit(null, $limit); } - foreach ($folder->select($filter) as $object) { + foreach ($folder->select($filter, true) as $object) { unset($object['_formatobj']); $list[] = $object; }