summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/kolab_config/kolab_config.php2
-rw-r--r--plugins/kolab_tags/lib/kolab_tags_backend.php4
-rw-r--r--plugins/libkolab/lib/kolab_storage_config.php37
3 files changed, 38 insertions, 5 deletions
diff --git a/plugins/kolab_config/kolab_config.php b/plugins/kolab_config/kolab_config.php
index d3e6636..60fc4cf 100644
--- a/plugins/kolab_config/kolab_config.php
+++ b/plugins/kolab_config/kolab_config.php
@@ -152,7 +152,7 @@ class kolab_config extends rcube_plugin
$query = array(array('type','=',self::O_TYPE), array('tags','=',$lang));
- foreach ($this->config->get_objects($query, $default) as $object) {
+ foreach ($this->config->get_objects($query, $default, null, 100) as $object) {
if ($object['language'] == $lang || $object['language'] == 'XX') {
if (is_array($this->dicts[$lang]))
$this->dicts[$lang]['e'] = array_merge((array)$this->dicts[$lang]['e'], $object['e']);
diff --git a/plugins/kolab_tags/lib/kolab_tags_backend.php b/plugins/kolab_tags/lib/kolab_tags_backend.php
index 032215d..519f962 100644
--- a/plugins/kolab_tags/lib/kolab_tags_backend.php
+++ b/plugins/kolab_tags/lib/kolab_tags_backend.php
@@ -43,7 +43,9 @@ class kolab_tags_backend
$filter[] = array('type', '=', self::O_TYPE);
$cat_filter = array('category' => self::O_CATEGORY);
- return $config->get_objects($filter, $default, $cat_filter);
+ // for performance reasons assume there will be no more than 100 tags (per-folder)
+
+ return $config->get_objects($filter, $default, $cat_filter, 100);
}
/**
diff --git a/plugins/libkolab/lib/kolab_storage_config.php b/plugins/libkolab/lib/kolab_storage_config.php
index d253aba..f5b891d 100644
--- a/plugins/libkolab/lib/kolab_storage_config.php
+++ b/plugins/libkolab/lib/kolab_storage_config.php
@@ -94,10 +94,11 @@ class kolab_storage_config
* @param array $filter Search filter
* @param bool $default Enable to get objects only from default folder
* @param array $data_filter Additional object data filter
+ * @param int $limit Max. number of records (per-folder)
*
* @return array List of objects
*/
- public function get_objects($filter = array(), $default = false, $data_filter = array())
+ public function get_objects($filter = array(), $default = false, $data_filter = array(), $limit = 0)
{
$list = array();
@@ -107,6 +108,11 @@ class kolab_storage_config
continue;
}
+ // for better performance it's good to assume max. number of records
+ if ($limit) {
+ $folder->set_order_and_limit(null, $limit);
+ }
+
foreach ($folder->select($filter) as $object) {
foreach ($data_filter as $key => $val) {
if ($object[$key] != $val) {
@@ -122,6 +128,28 @@ class kolab_storage_config
}
/**
+ * Get configuration object
+ *
+ * @param string $uid Object UID
+ * @param bool $default Enable to get objects only from default folder
+ *
+ * @return array Object data
+ */
+ public function get_object($uid, $default = false)
+ {
+ foreach ($this->folders as $folder) {
+ // we only want to read from default folder
+ if ($default && !$folder->default) {
+ continue;
+ }
+
+ if ($object = $folder->get_object($uid)) {
+ return $object;
+ }
+ }
+ }
+
+ /**
* Create/update configuration object
*
* @param array $object Object data
@@ -151,8 +179,12 @@ class kolab_storage_config
*/
public function delete($uid)
{
+ if (!$this->enabled) {
+ return false;
+ }
+
// fetch the object to find folder
- $list = $this->get_objects(array(array('uid', '=', $uid)));
+ $list = $this->get_object($uid);
$object = $list[0];
if (!$object) {
@@ -313,5 +345,4 @@ class kolab_storage_config
);
}
}
-
}