- Fix get_address_book() to call get_address_sources() internally when looking for default source

release-0.6
alecpl 13 years ago
parent dfb0513512
commit 7f7ed2d9df

@ -378,6 +378,7 @@ class rcmail
* *
* @param string Address book identifier * @param string Address book identifier
* @param boolean True if the address book needs to be writeable * @param boolean True if the address book needs to be writeable
*
* @return rcube_contacts Address book object * @return rcube_contacts Address book object
*/ */
public function get_address_book($id, $writeable = false) public function get_address_book($id, $writeable = false)
@ -407,18 +408,13 @@ class rcmail
if ($plugin['instance'] instanceof rcube_addressbook) { if ($plugin['instance'] instanceof rcube_addressbook) {
$contacts = $plugin['instance']; $contacts = $plugin['instance'];
} }
// get first source from the list
else if (!$id) { else if (!$id) {
if ($abook_type == 'ldap') { $source = reset($this->get_address_sources($writeable));
// Use the first writable LDAP address book. if (!empty($source)) {
foreach ($ldap_config as $id => $prop) { $contacts = $this->get_address_book($source['id']);
if (!$writeable || $prop['writable']) { if ($contacts)
$contacts = new rcube_ldap($prop, $this->config->get('ldap_debug'), $this->config->mail_domain($_SESSION['imap_host'])); $id = $source['id'];
break;
}
}
}
else { // $id == 'sql'
$contacts = new rcube_contacts($this->db, $this->user->ID);
} }
} }
} }

Loading…
Cancel
Save