From 3412e50b54e3daac8745234e21ab6e72be0ed165 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 04 Jun 2014 11:20:33 -0400
Subject: [PATCH] Fix attachment menu structure and aria-attributes

---
 program/include/rcmail.php |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index a812452..5a5d4cb 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -139,6 +139,8 @@
 
         if ($this->user && $this->user->ID)
             $task = !$task ? 'mail' : $task;
+        else if (php_sapi_name() == 'cli')
+            $task = 'cli';
         else
             $task = 'login';
 
@@ -1086,14 +1088,17 @@
         }
         else {
             foreach ($table_data as $row_data) {
-                $class = !empty($row_data['class']) ? $row_data['class'] : '';
+                $class = !empty($row_data['class']) ? $row_data['class'] : null;
+                if (!empty($attrib['rowclass']))
+                    $class = trim($class . ' ' . $attrib['rowclass']);
                 $rowid = 'rcmrow' . rcube_utils::html_identifier($row_data[$id_col]);
 
                 $table->add_row(array('id' => $rowid, 'class' => $class));
 
                 // format each col
                 foreach ($a_show_cols as $col) {
-                    $table->add($col, $this->Q(is_array($row_data[$col]) ? $row_data[$col][0] : $row_data[$col]));
+                    $val = is_array($row_data[$col]) ? $row_data[$col][0] : $row_data[$col];
+                    $table->add($col, empty($attrib['ishtml']) ? $this->Q($val) : $val);
                 }
             }
         }
@@ -1499,7 +1504,7 @@
             $html_name = $this->Q($foldername) . ($unread ? html::span('unreadcount', sprintf($attrib['unreadwrap'], $unread)) : '');
             $link_attrib = $folder['virtual'] ? array() : array(
                 'href' => $this->url(array('_mbox' => $folder['id'])),
-                'onclick' => sprintf("return %s.command('list','%s',this)", rcmail_output::JS_OBJECT_NAME, $js_name),
+                'onclick' => sprintf("return %s.command('list','%s',this,event)", rcmail_output::JS_OBJECT_NAME, $js_name),
                 'rel' => $folder['id'],
                 'title' => $title,
             );
@@ -1606,9 +1611,13 @@
      *
      * @return string Localized folder name in UTF-8 encoding
      */
-    public function localize_foldername($name, $with_path = true)
+    public function localize_foldername($name, $with_path = false)
     {
         $realnames = $this->config->get('show_real_foldernames');
+
+        if (!$realnames && ($folder_class = $this->folder_classname($name))) {
+            return $this->gettext($folder_class);
+        }
 
         // try to localize path of the folder
         if ($with_path && !$realnames) {
@@ -1618,7 +1627,7 @@
             $count     = count($path);
 
             if ($count > 1) {
-                for ($i = 0; $i < $count; $i++) {
+                for ($i = 1; $i < $count; $i++) {
                     $folder = implode($delimiter, array_slice($path, 0, -$i));
                     if ($folder_class = $this->folder_classname($folder)) {
                         $name = implode($delimiter, array_slice($path, $count - $i));
@@ -1626,10 +1635,6 @@
                     }
                 }
             }
-        }
-
-        if (!$realnames && ($folder_class = $this->folder_classname($name))) {
-            return $this->gettext($folder_class);
         }
 
         return rcube_charset::convert($name, 'UTF7-IMAP');
@@ -2028,8 +2033,9 @@
         $_uid  = $uids ?: rcube_utils::get_input_value('_uid', RCUBE_INPUT_GPC);
         $_mbox = $mbox ?: (string)rcube_utils::get_input_value('_mbox', RCUBE_INPUT_GPC);
 
-        if (is_array($uid)) {
-            return $uid;
+        // already a hash array
+        if (is_array($_uid) && !isset($_uid[0])) {
+            return $_uid;
         }
 
         $result = array();
@@ -2043,10 +2049,13 @@
             }
         }
         else {
+            if (is_string($_uid))
+                $_uid = explode(',', $_uid);
+
             // create a per-folder UIDs array
-            foreach (explode(',', $_uid) as $uid) {
+            foreach ((array)$_uid as $uid) {
                 list($uid, $mbox) = explode('-', $uid, 2);
-                if (empty($mbox))
+                if (!strlen($mbox))
                     $mbox = $_mbox;
                 if ($uid == '*')
                     $result[$mbox] = $uid;

--
Gitblit v1.9.1