From f35a06935dd883131b6987e23229f1393c0e91dd Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Sun, 8 Dec 2013 22:48:25 -0800 Subject: [PATCH] Killed first bug- Message class 'checkFlag' was returning wrong values if the message had been changed with setFlag This was because the setFlag function was not setting the value stored in the message object, just the one on the server. --- src/Fetch/Message.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Fetch/Message.php b/src/Fetch/Message.php index af01340..9796250 100644 --- a/src/Fetch/Message.php +++ b/src/Fetch/Message.php @@ -618,7 +618,7 @@ class Message */ public function checkFlag($flag = 'flagged') { - return (isset($this->status[$flag]) && $this->status[$flag] == true); + return (isset($this->status[$flag]) && $this->status[$flag] === true); } /** @@ -634,12 +634,14 @@ class Message if (!in_array($flag, self::$flagTypes) || $flag == 'recent') throw new \InvalidArgumentException('Unable to set invalid flag "' . $flag . '"'); - $flag = '\\' . ucfirst($flag); + $imapifiedFlag = '\\' . ucfirst($flag); - if ($enable) { - return imap_setflag_full($this->imapStream, $this->uid, $flag, ST_UID); + if ($enable === true) { + $this->status[$flag] = true; + return imap_setflag_full($this->imapStream, $this->uid, $imapifiedFlag, ST_UID); } else { - return imap_clearflag_full($this->imapStream, $this->uid, $flag, ST_UID); + unset($this->status[$flag]); + return imap_clearflag_full($this->imapStream, $this->uid, $imapifiedFlag, ST_UID); } }