summaryrefslogtreecommitdiff
path: root/program/include/rcmail.php
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2011-06-03 12:34:48 +0000
committeralecpl <alec@alec.pl>2011-06-03 12:34:48 +0000
commitb896b18f87064f523dca82c3fcaa5465ec8328ad (patch)
tree4608edfbf9029a2bf26fa604fef4688f0104f1a2 /program/include/rcmail.php
parenta5be870d6c7ca8913e0e3accaf6d4cf188a3c3cd (diff)
- Call addressbook_get hook only if build-in addressbook doesn't match wanted ID (for better performance), other improvements
Diffstat (limited to 'program/include/rcmail.php')
-rw-r--r--program/include/rcmail.php38
1 files changed, 20 insertions, 18 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index e93d546d6..4fc1262b3 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -381,18 +381,12 @@ class rcmail
*/
public function get_address_book($id, $writeable = false)
{
- $contacts = null;
+ $contacts = null;
$ldap_config = (array)$this->config->get('ldap_public');
- $abook_type = strtolower($this->config->get('address_book_type'));
-
- $plugin = $this->plugins->exec_hook('addressbook_get', array('id' => $id, 'writeable' => $writeable));
+ $abook_type = strtolower($this->config->get('address_book_type'));
- // plugin returned instance of a rcube_addressbook
- if ($plugin['instance'] instanceof rcube_addressbook) {
- $contacts = $plugin['instance'];
- }
// use existing instance
- else if (isset($this->address_books[$id]) && is_a($this->address_books[$id], 'rcube_addressbook') && (!$writeable || !$this->address_books[$id]->readonly)) {
+ if (isset($this->address_books[$id]) && is_a($this->address_books[$id], 'rcube_addressbook') && (!$writeable || !$this->address_books[$id]->readonly)) {
$contacts = $this->address_books[$id];
}
else if ($id && $ldap_config[$id]) {
@@ -401,17 +395,25 @@ class rcmail
else if ($id === '0') {
$contacts = new rcube_contacts($this->db, $this->user->ID);
}
- else if ($abook_type == 'ldap') {
- // Use the first writable LDAP address book.
- foreach ($ldap_config as $id => $prop) {
- if (!$writeable || $prop['writable']) {
- $contacts = new rcube_ldap($prop, $this->config->get('ldap_debug'), $this->config->mail_domain($_SESSION['imap_host']));
- break;
+ else {
+ $plugin = $this->plugins->exec_hook('addressbook_get', array('id' => $id, 'writeable' => $writeable));
+
+ // plugin returned instance of a rcube_addressbook
+ if ($plugin['instance'] instanceof rcube_addressbook) {
+ $contacts = $plugin['instance'];
+ }
+ else if ($abook_type == 'ldap') {
+ // Use the first writable LDAP address book.
+ foreach ($ldap_config as $id => $prop) {
+ if (!$writeable || $prop['writable']) {
+ $contacts = new rcube_ldap($prop, $this->config->get('ldap_debug'), $this->config->mail_domain($_SESSION['imap_host']));
+ break;
+ }
}
}
- }
- else { // $id == 'sql'
- $contacts = new rcube_contacts($this->db, $this->user->ID);
+ else { // $id == 'sql'
+ $contacts = new rcube_contacts($this->db, $this->user->ID);
+ }
}
// add to the 'books' array for shutdown function