Thomas Bruederli
2014-04-07 0456f728ee3f6312101d0a372b7385fb34fdaf2a
Make UID extraction function globally availbale (for plugins)
6 files modified
74 ■■■■ changed files
program/include/rcmail.php 31 ●●●●● patch | view | raw | blame | history
program/steps/mail/copy.inc 2 ●●● patch | view | raw | blame | history
program/steps/mail/func.inc 31 ●●●●● patch | view | raw | blame | history
program/steps/mail/mark.inc 2 ●●● patch | view | raw | blame | history
program/steps/mail/move_del.inc 4 ●●●● patch | view | raw | blame | history
program/steps/mail/sendmail.inc 4 ●●●● patch | view | raw | blame | history
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)          *********
program/steps/mail/copy.inc
@@ -28,7 +28,7 @@
if (!empty($_POST['_uid']) && strlen($_POST['_target_mbox'])) {
    $target = rcube_utils::get_input_value('_target_mbox', rcube_utils::INPUT_POST, true);
    foreach (rcmail_get_uids() as $mbox => $uids) {
    foreach (rcmail::get_uids() as $mbox => $uids) {
      $copied += (int)$RCMAIL->storage->copy_message($uids, $target, $mbox);
    }
program/steps/mail/func.inc
@@ -187,37 +187,6 @@
/**
 * 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
 */
function rcmail_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;
}
/**
 * Returns default search mods
 */
function rcmail_search_mods()
program/steps/mail/mark.inc
@@ -47,7 +47,7 @@
        $old_pages = ceil($old_count / $RCMAIL->storage->get_pagesize());
    }
    foreach (rcmail_get_uids() as $mbox => $uids) {
    foreach (rcmail::get_uids() as $mbox => $uids) {
        $marked += (int)$RCMAIL->storage->set_flag($uids, $flag, $mbox);
        $count += count($uids);
    }
program/steps/mail/move_del.inc
@@ -35,7 +35,7 @@
    $target = rcube_utils::get_input_value('_target_mbox', rcube_utils::INPUT_POST, true);
    $trash  = $RCMAIL->config->get('trash_mbox');
    foreach (rcmail_get_uids() as $mbox => $uids) {
    foreach (rcmail::get_uids() as $mbox => $uids) {
        $moved += (int)$RCMAIL->storage->move_message($uids, $target, $mbox);
        $count += count($uids);
    }
@@ -56,7 +56,7 @@
}
// delete messages 
else if ($RCMAIL->action=='delete' && !empty($_POST['_uid'])) {
    foreach (rcmail_get_uids() as $mbox => $uids) {
    foreach (rcmail::get_uids() as $mbox => $uids) {
        $del += (int)$RCMAIL->storage->delete_message($uids, $mbox);
        $count += count($uids);
    }
program/steps/mail/sendmail.inc
@@ -535,12 +535,12 @@
    // set replied/forwarded flag
    if ($COMPOSE['reply_uid']) {
        foreach (rcmail_get_uids($COMPOSE['reply_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
        foreach (rcmail::get_uids($COMPOSE['reply_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
            $RCMAIL->storage->set_flag($uids, 'ANSWERED', $mbox);
        }
    }
    else if ($COMPOSE['forward_uid']) {
        foreach (rcmail_get_uids($COMPOSE['forward_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
        foreach (rcmail::get_uids($COMPOSE['forward_uid'], $COMPOSE['mailbox']) as $mbox => $uids) {
            $RCMAIL->storage->set_flag($uids, 'FORWARDED', $mbox);
        }
    }