summaryrefslogtreecommitdiff
path: root/program/include/rcmail.php
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-03-02 14:35:53 +0000
committeralecpl <alec@alec.pl>2010-03-02 14:35:53 +0000
commit3704b78841ba05c31a2acaeabdffb9c471bb6610 (patch)
tree34dd713257589d0fc39285945e046c8c07722afd /program/include/rcmail.php
parent47ad83f337c9eeb4bc53afb85a71cf90a8a34106 (diff)
- Added function to get addressbooks list rcmail::get_address_sources() (#1486248)
Diffstat (limited to 'program/include/rcmail.php')
-rw-r--r--program/include/rcmail.php51
1 files changed, 50 insertions, 1 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 04c7151dc..81f61379b 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -244,6 +244,7 @@ class rcmail
/**
* Return instance of the internal address book class
*
+ * @param string Address book identifier
* @param boolean True if the address book needs to be writeable
* @return object rcube_contacts Address book object
*/
@@ -274,12 +275,60 @@ class rcmail
}
}
}
- else {
+ else { // $id == 'sql'
$contacts = new rcube_contacts($this->db, $this->user->ID);
}
return $contacts;
}
+
+
+ /**
+ * Return address books list
+ *
+ * @param boolean True if the address book needs to be writeable
+ * @return array Address books array
+ */
+ public function get_address_sources($writeable = false)
+ {
+ $abook_type = strtolower($this->config->get('address_book_type'));
+ $ldap_config = (array)$this->config->get('ldap_public');
+ $autocomplete = (array)$this->config->get('autocomplete_addressbooks');
+ $list = array();
+
+ // We are using the DB address book
+ if ($abook_type != 'ldap') {
+ $list['0'] = array(
+ 'id' => 0,
+ 'name' => rcube_label('personaladrbook'),
+ 'readonly' => false,
+ 'autocomplete' => in_array('sql', $autocomplete)
+ );
+ }
+
+ if (is_array($ldap_config)) {
+ foreach ($ldap_config as $id => $prop)
+ $list[$id] = array(
+ 'id' => $id,
+ 'name' => $prop['name'],
+ 'readonly' => !$prop['writable'],
+ 'autocomplete' => in_array('sql', $autocomplete)
+ );
+ }
+
+ $plugin = $this->plugins->exec_hook('address_sources', array('sources' => $list));
+ $list = $plugin['sources'];
+
+ if ($writeable && !empty($list)) {
+ foreach ($list as $idx => $item) {
+ if ($item['readonly']) {
+ unset($list[$idx]);
+ }
+ }
+ }
+
+ return $list;
+ }
/**