From b2992dd2283c3d0ac95f3293497dfaed0493f607 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Wed, 07 May 2014 11:34:28 -0400
Subject: [PATCH] Further accessibility improvements regarding keyboard navigation and document structure

---
 program/steps/mail/func.inc |   92 ++++++++++++++++++----------------------------
 1 files changed, 36 insertions(+), 56 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 7c9b491..811e878 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -24,16 +24,15 @@
 $RCMAIL->storage_init();
 
 // set imap properties and session vars
-if (strlen(trim($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true)))) {
-    $RCMAIL->storage->set_folder(($_SESSION['mbox'] = $mbox));
+if (!strlen($mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true))) {
+    $mbox = strlen($_SESSION['mbox']) ? $_SESSION['mbox'] : 'INBOX';
 }
-else if ($RCMAIL->storage) {
-    $_SESSION['mbox'] = $RCMAIL->storage->get_folder();
+if (!($page = intval($_GET['_page']))) {
+    $page = $_SESSION['page'] ? $_SESSION['page'] : 1;
 }
 
-if (!empty($_GET['_page'])) {
-    $RCMAIL->storage->set_page(($_SESSION['page'] = intval($_GET['_page'])));
-}
+$RCMAIL->storage->set_folder($_SESSION['mbox'] = $mbox);
+$RCMAIL->storage->set_page($_SESSION['page'] = $page);
 
 $a_threading        = $RCMAIL->config->get('message_threading', array());
 $message_sort_col   = $RCMAIL->config->get('message_sort_col');
@@ -69,8 +68,8 @@
 }
 
 // remove mbox part from _uid
-if (($_uid  = get_input_value('_uid', RCUBE_INPUT_GPC)) && preg_match('/^\d+-[^,]+$/', $_uid)) {
-  list($_uid, $mbox) = explode('-', $_uid);
+if (($_uid  = rcube_utils::get_input_value('_uid', RCUBE_INPUT_GPC)) && !is_array($_uid) && preg_match('/^\d+-.+/', $_uid)) {
+  list($_uid, $mbox) = explode('-', $_uid, 2);
   if (isset($_GET['_uid']))  $_GET['_uid']  = $_uid;
   if (isset($_POST['_uid'])) $_POST['_uid'] = $_uid;
   $_REQUEST['_uid'] = $_uid;
@@ -84,6 +83,9 @@
   }
 }
 
+if (!empty($_SESSION['browser_caps']) && !$OUTPUT->ajax_call) {
+    $OUTPUT->set_env('browser_capabilities', $_SESSION['browser_caps']);
+}
 
 // set main env variables, labels and page title
 if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
@@ -137,17 +139,13 @@
     $RCMAIL->set_env_config(array('delete_junk', 'flag_for_deletion', 'read_when_deleted',
         'skip_deleted', 'display_next', 'message_extwin', 'compose_extwin', 'forward_attachment'));
 
-    if (!empty($_SESSION['browser_caps'])) {
-        $OUTPUT->set_env('browser_capabilities', $_SESSION['browser_caps']);
-    }
-
     if (!$OUTPUT->ajax_call) {
         $OUTPUT->add_label('checkingmail', 'deletemessage', 'movemessagetotrash',
             'movingmessage', 'copyingmessage', 'deletingmessage', 'markingmessage',
-            'copy', 'move', 'quota', 'replyall', 'replylist');
+            'copy', 'move', 'quota', 'replyall', 'replylist', 'stillsearching');
     }
 
-    $pagetitle = $RCMAIL->localize_foldername($RCMAIL->storage->mod_folder($mbox_name), true);
+    $pagetitle = $RCMAIL->localize_foldername($mbox_name, true);
     $pagetitle = str_replace($delimiter, " \xC2\xBB ", $pagetitle);
 
     $OUTPUT->set_pagetitle($pagetitle);
@@ -185,35 +183,6 @@
     'group-expand'       => 'autocomplete.inc',
 ));
 
-
-/**
- * Returns message UID(s) and IMAP folder(s) from GET/POST data
- *
- * @return array List of message UIDs per folder
- */
-function rcmail_get_uids()
-{
-    // message UID (or comma-separated list of IDs) is provided in
-    // the form of <ID>-<MBOX>[,<ID>-<MBOX>]*
-
-    $_uid  = get_input_value('_uid', RCUBE_INPUT_GPC);
-    $_mbox = (string)get_input_value('_mbox', RCUBE_INPUT_GPC);
-
-    if (is_array($uid)) {
-        return $uid;
-    }
-
-    // create a per-folder UIDs array
-    $result = array();
-    foreach (explode(',', $_uid) as $uid) {
-        list($uid, $mbox) = explode('-', $uid, 2);
-        if (empty($mbox))
-            $mbox = $_mbox;
-        $result[$mbox][] = $uid;
-    }
-
-    return $result;
-}
 
 /**
  * Returns default search mods
@@ -418,9 +387,11 @@
 
     $OUTPUT->command('set_message_coltypes', $a_show_cols, $thead, $smart_col);
 
-    if ($multifolder) {
+    if ($multifolder && $_SESSION['search_scope'] == 'all') {
         $OUTPUT->command('select_folder', '');
     }
+
+    $OUTPUT->set_env('multifolder_listing', $multifolder);
 
     if (empty($a_headers)) {
         return;
@@ -536,14 +507,19 @@
         $a_sort_cols = array('subject', 'date', 'from', 'to', 'fromto', 'size', 'cc');
 
     if (!empty($attrib['optionsmenuicon'])) {
-        $onclick = 'return ' . rcmail_output::JS_OBJECT_NAME . ".command('menu-open', 'messagelistmenu')";
-        if ($attrib['optionsmenuicon'] === true || $attrib['optionsmenuicon'] == 'true')
-            $list_menu = html::div(array('onclick' => $onclick, 'class' => 'listmenu',
-                'id' => 'listmenulink', 'title' => $RCMAIL->gettext('listoptions')));
-        else
-            $list_menu = html::a(array('href' => '#', 'onclick' => $onclick),
-                html::img(array('src' => $skin_path . $attrib['optionsmenuicon'],
-                    'id' => 'listmenulink', 'title' => $RCMAIL->gettext('listoptions'))));
+        $onclick = 'return ' . rcmail_output::JS_OBJECT_NAME . ".command('menu-open', 'messagelistmenu', null, event)";
+        $inner   = 'v';
+        if (is_string($attrib['optionsmenuicon']) && $attrib['optionsmenuicon'] != 'true') {
+            $inner = html::img(array('src' => $skin_path . $attrib['optionsmenuicon'], 'alt' => $RCMAIL->gettext('listoptions')));
+        }
+        $list_menu = html::a(array(
+            'href' => '#list-options',
+            'onclick' => $onclick,
+            'class' => 'listmenu',
+            'id' => 'listmenulink',
+            'title' => $RCMAIL->gettext('listoptions'),
+            'tabindex' => '0',
+        ), $inner);
     }
     else {
         $list_menu = '';
@@ -1770,7 +1746,8 @@
 {
     $parts = array();
     foreach ($p as $key => $val) {
-        $parts[] = $key . '=' . ($key == 'folder' ? base64_encode($val) : $val);
+        $encode = $key == 'folder' || strpos($val, ';') !== false;
+        $parts[] = $key . '=' . ($encode ? 'B::' . base64_encode($val) : $val);
     }
 
     return join('; ', $parts);
@@ -1782,7 +1759,10 @@
 
     foreach (preg_split('/;\s+/', $str) as $part) {
         list($key, $val) = explode('=', $part, 2);
-        if ($key == 'folder') {
+        if (strpos($val, 'B::') === 0) {
+            $val = base64_decode(substr($val, 3));
+        }
+        else if ($key == 'folder') {
             $val = base64_decode($val);
         }
 
@@ -2061,7 +2041,7 @@
     $ctypes = array('application/', 'multipart/m', 'multipart/signed', 'multipart/report');
 
     // Build search string of "with attachment" filter
-    $attachment = str_repeat(' OR', count($ctypes)-1);
+    $attachment = trim(str_repeat(' OR', count($ctypes)-1));
     foreach ($ctypes as $type) {
         $attachment .= ' HEADER Content-Type ' . rcube_imap_generic::escape($type);
     }

--
Gitblit v1.9.1