plugins/kolab_addressbook
Aleksander Machniak
machniak at kolabsys.com
Wed Nov 26 12:27:32 CET 2014
plugins/kolab_addressbook/kolab_addressbook.php | 36 ++++++++++++------------
1 file changed, 18 insertions(+), 18 deletions(-)
New commits:
commit 176585664f7812ac2d18c0f5fa1f9195b2d2fb04
Author: Aleksander Machniak <machniak at kolabsys.com>
Date: Wed Nov 26 06:25:14 2014 -0500
Improve performance of get_address_book() (#3968)
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);
}
}
More information about the commits
mailing list