diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-08-26 10:28:34 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-08-26 10:29:23 +0200 |
commit | 4fbbd81b9b2230df3b06b773b829f0e3991664f3 (patch) | |
tree | 39f026723e777c44a8462cb0adf807714c958986 /program | |
parent | 652577d1fe8d77bf427c80a36f57c8dfe4db44af (diff) |
Fix bugs when invoking contact creation form when read-only addressbook is selected (#1489296)
Diffstat (limited to 'program')
-rw-r--r-- | program/include/rcmail.php | 17 | ||||
-rw-r--r-- | program/steps/addressbook/edit.inc | 14 |
2 files changed, 23 insertions, 8 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 4cfaca13c..c9350bdd9 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -257,6 +257,23 @@ class rcmail extends rcube /** + * Return identifier of the address book object + * + * @param rcube_addressbook Addressbook source object + * + * @return string Source identifier + */ + public function get_address_book_id($object) + { + foreach ($this->address_books as $index => $book) { + if ($book === $object) { + return $index; + } + } + } + + + /** * Return address books list * * @param boolean True if the address book needs to be writeable diff --git a/program/steps/addressbook/edit.inc b/program/steps/addressbook/edit.inc index d175c05d9..7ddd3e516 100644 --- a/program/steps/addressbook/edit.inc +++ b/program/steps/addressbook/edit.inc @@ -43,16 +43,14 @@ if ($RCMAIL->action == 'edit') { else { $source = get_input_value('_source', RCUBE_INPUT_GPC); - if (!strlen($source)) { - // Give priority to configured default - $source = $RCMAIL->config->get('default_addressbook'); + if (strlen($source)) { + $CONTACTS = $RCMAIL->get_address_book($source, true); } - $CONTACTS = $RCMAIL->get_address_book($source, true); - - // find writable addressbook - if (!$CONTACTS || $CONTACTS->readonly) - $source = $RCMAIL->get_address_book(-1, true); + if (!$CONTACTS || $CONTACTS->readonly) { + $CONTACTS = $RCMAIL->get_address_book(-1, true); + $source = $RCMAIL->get_address_book_id($CONTACTS); + } // Initialize addressbook $CONTACTS = rcmail_contact_source($source, true); |