From 0456f728ee3f6312101d0a372b7385fb34fdaf2a Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Mon, 07 Apr 2014 11:30:12 -0400
Subject: [PATCH] Make UID extraction function globally availbale (for plugins)

---
 program/include/rcmail.php |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 7a6fb89..952e8a5 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -2010,6 +2010,37 @@
         return $size;
     }
 
+    /**
+     * Returns message UID(s) and IMAP folder(s) from GET/POST data
+     *
+     * @param  string UID value to decode
+     * @param  string Default mailbox value (if not encoded in UIDs)
+     * @return array  List of message UIDs per folder
+     */
+    public static function get_uids($uids = null, $mbox = null)
+    {
+        // message UID (or comma-separated list of IDs) is provided in
+        // the form of <ID>-<MBOX>[,<ID>-<MBOX>]*
+
+        $_uid  = $uids ?: get_input_value('_uid', RCUBE_INPUT_GPC);
+        $_mbox = $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;
+    }
+
 
     /************************************************************************
      *********          Deprecated methods (to be removed)          *********

--
Gitblit v1.9.1