From 0f48e6e660cb5aa0d7bfdf11967b648c78cb64f9 Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Tue, 08 Apr 2014 03:14:05 -0400
Subject: [PATCH] Fix message UID extraction for _uid=*; update unread count for all affected mailboxes

---
 program/include/rcmail.php  |   23 +++++++++++++++++------
 program/steps/mail/mark.inc |    6 ++++--
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 952e8a5..87cf992 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -2029,13 +2029,24 @@
             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;
+
+        // special case: *
+        if ($_uid == '*' && is_object($_SESSION['search'][1]) && $_SESSION['search'][1]->multi) {
+            // extract the full list of UIDs per folder from the search set
+            foreach ($_SESSION['search'][1]->sets as $subset) {
+                $mbox = $subset->get_parameters('MAILBOX');
+                $result[$mbox] = $subset->get();
+            }
+        }
+        else {
+            // create a per-folder UIDs array
+            foreach (explode(',', $_uid) as $uid) {
+                list($uid, $mbox) = explode('-', $uid, 2);
+                if (empty($mbox))
+                    $mbox = $_mbox;
+                $result[$mbox][] = $uid;
+            }
         }
 
         return $result;
diff --git a/program/steps/mail/mark.inc b/program/steps/mail/mark.inc
index 149bc8e..e81f6c9 100644
--- a/program/steps/mail/mark.inc
+++ b/program/steps/mail/mark.inc
@@ -4,7 +4,7 @@
  | program/steps/mail/mark.inc                                           |
  |                                                                       |
  | This file is part of the Roundcube Webmail client                     |
- | Copyright (C) 2005-2013, The Roundcube Dev Team                       |
+ | Copyright (C) 2005-2014, The Roundcube Dev Team                       |
  |                                                                       |
  | Licensed under the GNU General Public License version 3 or            |
  | any later version with exceptions for skins & plugins.                |
@@ -76,7 +76,9 @@
     }
 
     if ($flag == 'SEEN' || $flag == 'UNSEEN' || ($flag == 'DELETED' && !$skip_deleted)) {
-        rcmail_send_unread_count($RCMAIL->storage->get_folder());
+        foreach (rcmail::get_uids() as $mbox => $uids) {
+            rcmail_send_unread_count($mbox);
+        }
     }
     else if ($flag == 'DELETED' && $skip_deleted) {
         if ($_POST['_from'] == 'show') {

--
Gitblit v1.9.1