From b6100d9ed21f355b6b492d30aa3426a87be96298 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Thu, 16 Jan 2014 05:41:09 -0500
Subject: [PATCH] Merge branch 'dev-multi-folder-search' of github.com:roundcube/roundcubemail into dev-multi-folder-search after rebasing to master

---
 program/steps/mail/func.inc |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 0211fab..3848ec5 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -68,6 +68,21 @@
     $OUTPUT->set_env('search_text', $_SESSION['last_text_search']);
 }
 
+// remove mbox part from _uid
+if (($_uid  = get_input_value('_uid', RCUBE_INPUT_GPC)) && preg_match('/^\d+-[^,]+$/', $_uid)) {
+  list($_uid, $mbox) = explode('-', $_uid);
+  if (isset($_GET['_uid']))  $_GET['_uid']  = $_uid;
+  if (isset($_POST['_uid'])) $_POST['_uid'] = $_uid;
+  $_REQUEST['_uid'] = $_uid;
+  unset($_uid);
+
+  if (empty($_REQUEST['_mbox']) && !empty($mbox)) {
+    $_GET['_mbox']  = $mbox;
+    $_POST['_mbox'] = $mbox;
+  }
+}
+
+
 // set main env variables, labels and page title
 if (empty($RCMAIL->action) || $RCMAIL->action == 'list') {
     // connect to storage server and trigger error on failure
@@ -166,6 +181,34 @@
 ));
 
 
+/**
+ * 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
@@ -398,6 +441,8 @@
                 $cont = show_bytes($header->$col);
             else if ($col == 'date')
                 $cont = $RCMAIL->format_date($header->date);
+            else if ($col == 'folder')
+                $cont = rcube::Q(rcube_charset::convert($header->folder, 'UTF7-IMAP'));
             else
                 $cont = rcube::Q($header->$col);
 
@@ -421,7 +466,7 @@
             $a_msg_flags['prio'] = (int) $header->priority;
 
         $a_msg_flags['ctype'] = rcube::Q($header->ctype);
-        $a_msg_flags['mbox']  = $mbox;
+        $a_msg_flags['mbox']  = $header->folder;
 
         // merge with plugin result (Deprecated, use $header->flags)
         if (!empty($header->list_flags) && is_array($header->list_flags))

--
Gitblit v1.9.1