From a5ed1aec186d46f44605aff4a3e0f6c23ea391fa Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 27 Mar 2009 11:22:06 -0600 Subject: [PATCH] Mark mailbox readonly if UIDs are not sticky. --- imp/lib/Imap.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/imp/lib/Imap.php b/imp/lib/Imap.php index b5957ac59..f5c1cae44 100644 --- a/imp/lib/Imap.php +++ b/imp/lib/Imap.php @@ -231,18 +231,31 @@ class IMP_Imap } /** - * Is the current IMAP connection read-only? + * Is the given mailbox read-only? * - * @param string $mailbox The mailbox. + * @param string $mailbox The mailbox to check. * - * @return boolean Is the connection read-only? + * @return boolean Is the mailbox read-only? */ public function isReadOnly($mailbox) { if (!isset($this->_readonly[$mailbox])) { - $this->_readonly[$mailbox] = - !empty($GLOBALS['conf']['hooks']['mbox_readonly']) && + /* These tests work on both regular and search mailboxes. */ + $res = !empty($GLOBALS['conf']['hooks']['mbox_readonly']) && Horde::callHook('_imp_hook_mbox_readonly', array($mailbox), 'imp'); + + /* This check can only be done for regular IMAP mailboxes. */ + // TODO: POP3 also? + if (!$res && + ($_SESSION['imp']['protocol'] == 'imap') && + !$GLOBALS['imp_search']->isSearchMbox($mailbox)) { + try { + $status = $this->ob->status($mailbox, Horde_Imap_Client::STATUS_UIDNOTSTICKY); + $res = $status['uidnotsticky']; + } catch (Horde_Imap_Client_Exception $e) {} + } + + $this->_readonly[$mailbox] = $res; } return $this->_readonly[$mailbox]; -- 2.11.0