Example #1
0
    /**
     * Checks if folder exists and is subscribed
     *
     * @param string   $folder       Folder name
     * @param boolean  $subscription Enable subscription checking
     *
     * @return boolean TRUE or FALSE
     */
    public function folder_exists($folder, $subscription=false)
    {
        if ($folder == 'INBOX') {
            return true;
        }

        $key  = $subscription ? 'subscribed' : 'existing';

        if (is_array($this->icache[$key]) && in_array($folder, $this->icache[$key])) {
            return true;
        }

        if (!$this->check_connection()) {
            return false;
        }

        if ($subscription) {
            $a_folders = $this->conn->listSubscribed('', $folder);
        }
        else {
            $a_folders = $this->conn->listMailboxes('', $folder);
        }

        if (is_array($a_folders) && in_array($folder, $a_folders)) {
            $this->icache[$key][] = $folder;
            return true;
        }

        return false;
    }
Example #2
0
 /**
  * Checks if folder exists and is subscribed
  *
  * @param string   $folder       Folder name
  * @param boolean  $subscription Enable subscription checking
  *
  * @return boolean TRUE or FALSE
  */
 public function folder_exists($folder, $subscription = false)
 {
     if ($folder == 'INBOX') {
         return true;
     }
     $key = $subscription ? 'subscribed' : 'existing';
     if (is_array($this->icache[$key]) && in_array($folder, $this->icache[$key])) {
         return true;
     }
     if (!$this->check_connection()) {
         return false;
     }
     if ($subscription) {
         // It's possible we already called LIST command, check LIST data
         if (!empty($this->conn->data['LIST']) && !empty($this->conn->data['LIST'][$folder]) && in_array_nocase('\\Subscribed', $this->conn->data['LIST'][$folder])) {
             $a_folders = array($folder);
         } else {
             $a_folders = $this->conn->listSubscribed('', $folder);
         }
     } else {
         // It's possible we already called LIST command, check LIST data
         if (!empty($this->conn->data['LIST']) && isset($this->conn->data['LIST'][$folder])) {
             $a_folders = array($folder);
         } else {
             $a_folders = $this->conn->listMailboxes('', $folder);
         }
     }
     if (is_array($a_folders) && in_array($folder, $a_folders)) {
         $this->icache[$key][] = $folder;
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * Checks if folder exists and is subscribed
  *
  * @param string   $mailbox      Folder name
  * @param boolean  $subscription Enable subscription checking
  *
  * @return boolean TRUE or FALSE
  */
 function mailbox_exists($mailbox, $subscription = false)
 {
     if ($mailbox == 'INBOX') {
         return true;
     }
     $key = $subscription ? 'subscribed' : 'existing';
     if (is_array($this->icache[$key]) && in_array($mailbox, $this->icache[$key])) {
         return true;
     }
     if ($subscription) {
         $a_folders = $this->conn->listSubscribed('', $mailbox);
     } else {
         $a_folders = $this->conn->listMailboxes('', $mailbox);
     }
     if (is_array($a_folders) && in_array($mailbox, $a_folders)) {
         $this->icache[$key][] = $mailbox;
         return true;
     }
     return false;
 }