summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2014-08-26 10:03:11 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2014-08-26 10:03:11 (GMT)
commit54b6eb66decf1828c8217db6e2b90bcf16c49eb9 (patch)
tree6db29e61636826a01ec5ec737a8c122b5429cf20
parent43d3f854482b257fdbf364e59dacdc4609b92557 (diff)
downloadroundcubemail-plugins-kolab-54b6eb66decf1828c8217db6e2b90bcf16c49eb9.tar.gz
Post-filter all tag objects (in case caching is disabled); improve kolab_storage_cache for the case caching is off
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache.php6
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache_configuration.php22
-rw-r--r--plugins/libkolab/lib/kolab_storage_config.php15
3 files changed, 36 insertions, 7 deletions
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index d56f04d..eec058d 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -265,8 +265,10 @@ class kolab_storage_cache
// fetch from IMAP if not present in cache
if (empty($this->objects[$msguid])) {
- $result = $this->_fetch(array($msguid), $type, $foldername);
- $this->objects = array($msguid => $result[0]); // store only this object in memory (#2827)
+ if ($object = $this->folder->read_object($msguid, $type ?: '*', $foldername)) {
+ $this->objects = array($msguid => $object);
+ $this->set($msguid, $object);
+ }
}
}
diff --git a/plugins/libkolab/lib/kolab_storage_cache_configuration.php b/plugins/libkolab/lib/kolab_storage_cache_configuration.php
index ec015dd..c3c7ac4 100644
--- a/plugins/libkolab/lib/kolab_storage_cache_configuration.php
+++ b/plugins/libkolab/lib/kolab_storage_cache_configuration.php
@@ -39,6 +39,28 @@ class kolab_storage_cache_configuration extends kolab_storage_cache
}
/**
+ * Select Kolab objects filtered by the given query
+ *
+ * @param array Pseudo-SQL query as list of filter parameter triplets
+ * @param boolean Set true to only return UIDs instead of complete objects
+ * @return array List of Kolab data objects (each represented as hash array) or UIDs
+ */
+ public function select($query = array(), $uids = false)
+ {
+ // modify query for IMAP search: query param 'type' is actually a subtype
+ if (!$this->ready) {
+ foreach ($query as $i => $tuple) {
+ if ($tuple[0] == 'type') {
+ $tuple[2] = 'configuration.' . $tuple[2];
+ $query[$i] = $tuple;
+ }
+ }
+ }
+
+ return parent::select($query, $uids);
+ }
+
+ /**
* Helper method to compose a valid SQL query from pseudo filter triplets
*/
protected function _sql_where($query)
diff --git a/plugins/libkolab/lib/kolab_storage_config.php b/plugins/libkolab/lib/kolab_storage_config.php
index 9bc5d50..8a0fab5 100644
--- a/plugins/libkolab/lib/kolab_storage_config.php
+++ b/plugins/libkolab/lib/kolab_storage_config.php
@@ -125,6 +125,7 @@ class kolab_storage_config
}
foreach ($folder->select($filter) as $object) {
+ unset($object['_formatobj']);
$list[] = $object;
}
}
@@ -626,20 +627,24 @@ class kolab_storage_config
// use faster method
if ($uid && $uid != '*') {
$filter[] = array('member', '=', $uid);
- return $this->get_objects($filter, $default);
+ $tags = $this->get_objects($filter, $default);
}
-
- $this->tags = $this->get_objects($filter, $default);
+ else {
+ $this->tags = $tags = $this->get_objects($filter, $default);
+ }
+ }
+ else {
+ $tags = $this->tags;
}
if ($uid === '*') {
- return $this->tags;
+ return $tags;
}
$result = array();
$search = self::build_member_url($uid);
- foreach ($this->tags as $tag) {
+ foreach ($tags as $tag) {
if (in_array($search, (array) $tag['members'])) {
$result[] = $tag;
}