From 62350ba021d479e459cbbf7957841fbb440b9846 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 26 Aug 2013 04:28:34 -0400
Subject: [PATCH] Fix bugs when invoking contact creation form when read-only addressbook is selected (#1489296)
---
CHANGELOG | 1 +
program/steps/addressbook/edit.inc | 14 ++++++--------
program/include/rcmail.php | 17 +++++++++++++++++
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 3f09560..88d5a4f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Fix bugs when invoking contact creation form when read-only addressbook is selected (#1489296)
- Fix identity selection on reply (#1489291)
- Fix so additional headers are added to all messages sent (#1489284)
- Fix display issue after moving folder in Folder Manager (#1489293)
diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 800edda..62f6b6c 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -263,6 +263,23 @@
/**
+ * 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 d175c05..7ddd3e5 100644
--- a/program/steps/addressbook/edit.inc
+++ b/program/steps/addressbook/edit.inc
@@ -43,16 +43,14 @@
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);
--
Gitblit v1.9.1