From 37557b5f086d64348a42dccaf922e541b87c2d13 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Mon, 19 Nov 2012 05:08:32 -0500
Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail

---
 CHANGELOG                             |    1 +
 program/steps/addressbook/func.inc    |   18 ++++++++++--------
 program/steps/settings/func.inc       |    2 +-
 program/localization/en_US/labels.inc |    2 +-
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 065bdbc..2f313d6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 CHANGELOG Roundcube Webmail
 ===========================
 
+- Select default_addressbook on the list in Address Book (#1488280)
 - Fix so mobile phone has TYPE=CELL in exported vCard (#1488812)
 - Support contacts import from CSV file (#1486399)
 - Improved keep-alive action. Now the interval is based on session_lifetime (#1488507)
diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index cb3cdf1..c8cbf18 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -453,7 +453,7 @@
 $labels['reqmdn'] = 'Always request a return receipt';
 $labels['reqdsn'] = 'Always request a delivery status notification';
 $labels['replysamefolder'] = 'Place replies in the folder of the message being replied to';
-$labels['defaultaddressbook'] = 'Add new contacts to the selected addressbook';
+$labels['defaultabook'] = 'Default address book';
 $labels['autocompletesingle'] = 'Skip alternative email addresses in autocompletion';
 $labels['listnamedisplay'] = 'List contacts as';
 $labels['spellcheckbeforesend'] = 'Check spelling before sending a message';
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index cefe49e..e42e26e 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -63,12 +63,6 @@
     // add list of address sources to client env
     $js_list = $RCMAIL->get_address_sources();
 
-    $source = get_input_value('_source', RCUBE_INPUT_GPC);
-
-    // use first directory by default
-    if (!strlen($source) || !isset($js_list[$source]))
-        $source = $js_list[key($js_list)]['id'];
-
     // count all/writeable sources
     $writeable = 0;
     $count = 0;
@@ -93,8 +87,16 @@
     $_SESSION['addressbooks_count'] = $count;
     $_SESSION['addressbooks_count_writeable'] = $writeable;
 
-    if (!strlen($source))
-      $source = strval(key($js_list));
+    // select address book
+    $source = get_input_value('_source', RCUBE_INPUT_GPC);
+
+    // use first directory by default
+    if (!strlen($source) || !isset($js_list[$source])) {
+        $source = $RCMAIL->config->get('default_addressbook');
+        if (!strlen($source) || !isset($js_list[$source])) {
+            $source = strval(key($js_list));
+        }
+    }
 
     $CONTACTS = rcmail_contact_source($source, true);
 }
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index 876e027..2c19d88 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -705,7 +705,7 @@
       }
 
       $blocks['main']['options']['default_addressbook'] = array(
-        'title' => html::label($field_id, Q(rcube_label('defaultaddressbook'))),
+        'title' => html::label($field_id, Q(rcube_label('defaultabook'))),
         'content' => $select_abook->show($config['default_addressbook']),
       );
     }

--
Gitblit v1.9.1