more accurate check with support for zero

This commit is contained in:
Lewis Cowles 2015-05-24 10:38:53 +01:00
parent 397b748370
commit c40d2ce48c

View File

@ -323,13 +323,16 @@ class Server
*/ */
public function numMessages( $mailbox='' ) public function numMessages( $mailbox='' )
{ {
$oldMailbox = $this->getMailBox(); $mboxExists = $this->hasMailbox( $mailbox );
if( $mailbox !== '' ) { if( $mboxExists ) {
$oldMailbox = $this->getMailBox();
$this->setMailbox( $mailbox ); $this->setMailbox( $mailbox );
} }
$cnt = imap_num_msg($this->getImapStream()); $cnt = imap_num_msg( $this->getImapStream() );
$this->setMailbox( $oldMailbox ); if( $mboxExists ) {
return $cnt; $this->setMailbox( $oldMailbox );
}
return ( !$mboxExists && $mailbox !== '' ) ? 0 : $cnt;
} }
/** /**