Make UID extraction function globally availbale (for plugins)

pull/175/head
Thomas Bruederli 10 years ago
parent 6dc1a66451
commit 0456f728ee

@ -2010,6 +2010,37 @@ class rcmail extends rcube
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) *********

@ -28,7 +28,7 @@ if (!$OUTPUT->ajax_call) {
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);
}

@ -186,37 +186,6 @@ $RCMAIL->register_action_map(array(
));
/**
* 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
*/

@ -47,7 +47,7 @@ if (($_uids = rcube_utils::get_input_value('_uid', rcube_utils::INPUT_POST))
$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);
}

@ -35,7 +35,7 @@ if ($RCMAIL->action == 'move' && !empty($_POST['_uid']) && strlen($_POST['_targe
$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 @@ if ($RCMAIL->action == 'move' && !empty($_POST['_uid']) && strlen($_POST['_targe
}
// 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);
}

@ -535,12 +535,12 @@ if (!$savedraft) {
// 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);
}
}

Loading…
Cancel
Save