summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-11-26 11:25:14 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-11-26 11:25:14 (GMT)
commit176585664f7812ac2d18c0f5fa1f9195b2d2fb04 (patch)
tree362e35d566cb46bf2c182ab73adbc64b06a4c268
parent0f32fa4456f230600ed86f0b9f75b4babac3eb52 (diff)
downloadroundcubemail-plugins-kolab-176585664f7812ac2d18c0f5fa1f9195b2d2fb04.tar.gz
Improve performance of get_address_book() (#3968)
-rw-r--r--plugins/kolab_addressbook/kolab_addressbook.php36
1 files changed, 18 insertions, 18 deletions
diff --git a/plugins/kolab_addressbook/kolab_addressbook.php b/plugins/kolab_addressbook/kolab_addressbook.php
index a78f7ca..912d34c 100644
--- a/plugins/kolab_addressbook/kolab_addressbook.php
+++ b/plugins/kolab_addressbook/kolab_addressbook.php
@@ -36,10 +36,10 @@ class kolab_addressbook extends rcube_plugin
private $rc;
private $ui;
- const GLOBAL_FIRST = 0;
+ const GLOBAL_FIRST = 0;
const PERSONAL_FIRST = 1;
- const GLOBAL_ONLY = 2;
- const PERSONAL_ONLY = 3;
+ const GLOBAL_ONLY = 2;
+ const PERSONAL_ONLY = 3;
/**
* Startup method of a Roundcube plugin
@@ -371,22 +371,22 @@ class kolab_addressbook extends rcube_plugin
public function get_address_book($p)
{
if ($p['id']) {
- $this->_list_sources();
- if ($this->sources[$p['id']]) {
- $p['instance'] = $this->sources[$p['id']];
+ $id = kolab_storage::id_decode($p['id']);
+
+ // check for falsely base64 decoded identifier
+ if (preg_match('![^A-Za-z0-9=/+&._ -]!', $id)) {
+ $id = $p['id'];
}
- else {
- $id = kolab_storage::id_decode($p['id']);
- if (preg_match('![^A-Za-z0-9=/+&._ -]!', $id)) // check for falsely base64 decoded identifier
- $id = $p['id'];
- $folder = kolab_storage::get_folder($id);
- if ($folder->type != 'contact' && $id != $p['id']) { // try with unencoded (old-style) identifier
- $folder = kolab_storage::get_folder($p['id']);
- }
- if ($folder->type) {
- $this->sources[$p['id']] = new rcube_kolab_contacts($folder->name);
- $p['instance'] = $this->sources[$p['id']];
- }
+
+ $folder = kolab_storage::get_folder($id);
+
+ // try with unencoded (old-style) identifier
+ if (!$folder || ($folder->type != 'contact' && $id != $p['id'])) {
+ $folder = kolab_storage::get_folder($p['id']);
+ }
+
+ if ($folder && $folder->type == 'contact') {
+ $p['instance'] = new rcube_kolab_contacts($folder->name);
}
}