From 5a814ff5e2c9c46d38f7b7afb43c2601ce396d2c Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 18 Nov 2010 10:05:45 -0700 Subject: [PATCH] Move readonly checking to action blocks --- imp/message.php | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/imp/message.php b/imp/message.php index 863c4f67f..227b9dcc8 100644 --- a/imp/message.php +++ b/imp/message.php @@ -62,10 +62,6 @@ if ($vars->actionID) { /* Determine if mailbox is readonly. */ $peek = $readonly = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->isReadOnly(IMP::$mailbox); -if ($readonly && - in_array($vars->actionID, array('delete_message', 'undelete_message', 'move_message', 'flag_message', 'strip_attachment', 'strip_all'))) { - $vars->actionID = null; -} /* Get mailbox/UID of message. */ $index_array = $imp_mailbox->getIMAPIndex(); @@ -88,10 +84,7 @@ case 'whitelist': break; case 'delete_message': -case 'undelete_message': - if ($vars->actionID == 'undelete_message') { - $imp_message->undelete($indices); - } else { + if (!$readonly) { $imp_message->delete( $indices, array( @@ -109,9 +102,16 @@ case 'undelete_message': } break; +case 'undelete_message': + if (!$readonly) { + $imp_message->undelete($indices); + } + break; + case 'move_message': case 'copy_message': - if (isset($vars->targetMbox)) { + if (isset($vars->targetMbox) && + (!$readonly || ($vars->actionID == 'copy_message'))) { $targetMbox = IMP::formMbox($vars->targetMbox, false); if ($vars->newMbox) { $vars->targetMbox = IMP::folderPref($targetMbox, true); @@ -154,7 +154,7 @@ case 'notspam_report': break; case 'flag_message': - if (isset($vars->flag) && count($indices)) { + if (!$readonly && isset($vars->flag) && count($indices)) { $peek = true; $flag = $imp_flags->parseFormId($vars->flag); $imp_message->flag(array($flag['flag']), $indices, $flag['set']); @@ -177,17 +177,19 @@ case 'add_address': case 'strip_all': case 'strip_attachment': - try { - $imp_message->stripPart( - $indices, - ($vars->actionID == 'strip_all') ? null : $vars->imapid, - array( - 'mailboxob' => $imp_mailbox - ) - ); - $notification->push(_("Attachment successfully stripped."), 'horde.success'); - } catch (Horde_Exception $e) { - $notification->push($e); + if (!$readonly) { + try { + $imp_message->stripPart( + $indices, + ($vars->actionID == 'strip_all') ? null : $vars->imapid, + array( + 'mailboxob' => $imp_mailbox + ) + ); + $notification->push(_("Attachment successfully stripped."), 'horde.success'); + } catch (Horde_Exception $e) { + $notification->push($e); + } } break; } -- 2.11.0