summaryrefslogtreecommitdiff
path: root/program/steps/mail/func.inc
diff options
context:
space:
mode:
authorThomas <tb@woodcrest.local>2013-10-09 17:12:30 +0200
committerThomas <tb@woodcrest.local>2013-10-09 17:12:30 +0200
commit9e63cd5f24defa521724dfe3dcbbaa4385761836 (patch)
tree9e089f565808323f66ff10eb6d78f133ed859f5a /program/steps/mail/func.inc
parentf540f86d19ae1d374ba3c78fe11eaf3f771af150 (diff)
Support globally unique message UIDs with IMAP folder name appended
Diffstat (limited to 'program/steps/mail/func.inc')
-rw-r--r--program/steps/mail/func.inc44
1 files changed, 44 insertions, 0 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index b677c4675..807ec3ce9 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -66,6 +66,21 @@ if (!empty($_REQUEST['_search']) && isset($_SESSION['search'])
$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
@@ -161,6 +176,35 @@ $RCMAIL->register_action_map(array(
));
+/**
+ * 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 'to' if current folder is configured Sent or Drafts