/** * Subscribe/unsubscribe a list of folders and update local cache */ protected function change_subscription($folders, $mode) { $updated = false; if (!empty($folders)) { if (!$this->check_connection()) { return false; } foreach ((array)$folders as $i => $folder) { $folders[$i] = $folder; if ($mode == 'subscribe') { $updated = $this->conn->subscribe($folder); } else if ($mode == 'unsubscribe') { $updated = $this->conn->unsubscribe($folder); } } } // clear cached folders list(s) if ($updated) { $this->clear_cache('mailboxes', true); } return $updated; }
/** * Remove folder from server * * @param string $folder Folder name * * @return boolean True on success */ function delete_folder($folder) { $delm = $this->get_hierarchy_delimiter(); if (!$this->check_connection()) { return false; } // get list of folders if (strpos($folder, '%') === false && strpos($folder, '*') === false) { $sub_mboxes = $this->list_folders('', $folder . $delm . '*'); } else { $sub_mboxes = $this->list_folders(); } // send delete command to server $result = $this->conn->deleteFolder($folder); if ($result) { // unsubscribe folder $this->conn->unsubscribe($folder); foreach ($sub_mboxes as $c_mbox) { if (strpos($c_mbox, $folder . $delm) === 0) { $this->conn->unsubscribe($c_mbox); if ($this->conn->deleteFolder($c_mbox)) { $this->clear_message_cache($c_mbox); } } } // clear folder-related cache $this->clear_message_cache($folder); $this->clear_cache('mailboxes', true); } return $result; }
/** * Subscribe/unsubscribe a list of mailboxes and update local cache * @access private */ private function _change_subscription($a_mboxes, $mode) { $updated = false; if (is_array($a_mboxes)) { foreach ($a_mboxes as $i => $mbox_name) { $mailbox = $this->mod_mailbox($mbox_name); $a_mboxes[$i] = $mailbox; if ($mode == 'subscribe') { $updated = $this->conn->subscribe($mailbox); } else { if ($mode == 'unsubscribe') { $updated = $this->conn->unsubscribe($mailbox); } } } } // get cached mailbox list if ($updated) { $a_mailbox_cache = $this->get_cache('mailboxes'); if (!is_array($a_mailbox_cache)) { return $updated; } // modify cached list if ($mode == 'subscribe') { $a_mailbox_cache = array_merge($a_mailbox_cache, $a_mboxes); } else { if ($mode == 'unsubscribe') { $a_mailbox_cache = array_diff($a_mailbox_cache, $a_mboxes); } } // write mailboxlist to cache $this->update_cache('mailboxes', $this->_sort_mailbox_list($a_mailbox_cache)); } return $updated; }
/** * Remove folder (with subfolders) from the server * * @param string $folder Folder name * * @return boolean True on success, False on failure */ function delete_folder($folder) { if (!$this->check_connection()) { return false; } $delm = $this->get_hierarchy_delimiter(); // get list of sub-folders or all folders // if folder name contains special characters $path = strspn($folder, '%*') > 0 ? $folder . $delm : ''; $sub_mboxes = $this->list_folders('', $path . '*'); // According to RFC3501 deleting a \Noselect folder // with subfolders may fail. To workaround this we delete // subfolders first (in reverse order) (#5466) if (!empty($sub_mboxes)) { foreach (array_reverse($sub_mboxes) as $mbox) { if (strpos($mbox, $folder . $delm) === 0) { if ($this->conn->deleteFolder($mbox)) { $this->conn->unsubscribe($mbox); $this->clear_message_cache($mbox); } } } } // delete the folder if ($result = $this->conn->deleteFolder($folder)) { // and unsubscribe it $this->conn->unsubscribe($folder); $this->clear_message_cache($folder); } $this->clear_cache('mailboxes', true); return $result; }
/** * Subscribe/unsubscribe a list of mailboxes and update local cache * @access private */ private function _change_subscription($a_mboxes, $mode) { $updated = false; if (is_array($a_mboxes)) { foreach ($a_mboxes as $i => $mailbox) { $a_mboxes[$i] = $mailbox; if ($mode == 'subscribe') { $updated = $this->conn->subscribe($mailbox); } else { if ($mode == 'unsubscribe') { $updated = $this->conn->unsubscribe($mailbox); } } } } // clear cached mailbox list(s) if ($updated) { $this->clear_cache('mailboxes', true); } return $updated; }