[Svn] r4852 - trunk/roundcubemail/program/steps/addressbook

trac at roundcube.net trac at roundcube.net
Wed Jun 15 13:04:06 CEST 2011


Author: alec
Date: 2011-06-15 06:04:06 -0500 (Wed, 15 Jun 2011)
New Revision: 4852

Modified:
   trunk/roundcubemail/program/steps/addressbook/func.inc
Log:
- Fixed initial directory selection


Modified: trunk/roundcubemail/program/steps/addressbook/func.inc
===================================================================
--- trunk/roundcubemail/program/steps/addressbook/func.inc	2011-06-15 00:09:23 UTC (rev 4851)
+++ trunk/roundcubemail/program/steps/addressbook/func.inc	2011-06-15 11:04:06 UTC (rev 4852)
@@ -62,8 +62,11 @@
     // 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
-    $source = $js_list[key($js_list)]['id'];
+    if (!strlen($source) || !isset($js_list[$source]))
+        $source = $js_list[key($js_list)]['id'];
 
     // find writeable source
     foreach ($js_list as $s) {
@@ -155,18 +158,22 @@
     $out = '';
     $local_id = '0';
     $jsdata = array();
-    $current = get_input_value('_source', RCUBE_INPUT_GPC);
+
     $line_templ = html::tag('li', array(
         'id' => 'rcmli%s', 'class' => 'addressbook %s'),
         html::a(array('href' => '%s',
             'rel' => '%s',
             'onclick' => "return ".JS_OBJECT_NAME.".command('list','%s',this)"), '%s'));
 
-    // currently selected is the first address source in the list
-    if (!isset($current))
-        $current = strval(key((array)$OUTPUT->env['address_sources']));
+    $sources = (array) $OUTPUT->env['address_sources'];
+    reset($sources);
 
-    foreach ((array)$OUTPUT->env['address_sources'] as $j => $source) {
+    // currently selected source
+    $current = get_input_value('_source', RCUBE_INPUT_GPC);
+    if (!strlen($current) || !isset($sources[$source]))
+        $current = strval(key($sources));
+
+    foreach ($sources as $j => $source) {
         $id = strval($source['id'] ? $source['id'] : $j);
         $js_id = JQ($id);
         $out .= sprintf($line_templ,

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list