Changeset View
Changeset View
Standalone View
Standalone View
src/include/rcube_imap_generic.php
Show First 20 Lines • Show All 781 Lines • ▼ Show 20 Lines | class rcube_imap_generic | ||||
/** | /** | ||||
* Detects hierarchy delimiter | * Detects hierarchy delimiter | ||||
* | * | ||||
* @return string The delimiter | * @return string The delimiter | ||||
*/ | */ | ||||
public function getHierarchyDelimiter() | public function getHierarchyDelimiter() | ||||
{ | { | ||||
if ($this->prefs['delimiter']) { | if (isset($this->prefs['delimiter'])) { | ||||
return $this->prefs['delimiter']; | return $this->prefs['delimiter']; | ||||
} | } | ||||
// try (LIST "" ""), should return delimiter (RFC2060 Sec 6.3.8) | // try (LIST "" ""), should return delimiter (RFC2060 Sec 6.3.8) | ||||
list($code, $response) = $this->execute('LIST', | list($code, $response) = $this->execute('LIST', | ||||
array($this->escape(''), $this->escape(''))); | array($this->escape(''), $this->escape(''))); | ||||
if ($code == self::ERROR_OK) { | if ($code == self::ERROR_OK) { | ||||
▲ Show 20 Lines • Show All 631 Lines • ▼ Show 20 Lines | |||||
* Removes all messages in a folder | * Removes all messages in a folder | ||||
* | * | ||||
* @param string $mailbox Mailbox name | * @param string $mailbox Mailbox name | ||||
* | * | ||||
* @return boolean True on success, False on error | * @return boolean True on success, False on error | ||||
*/ | */ | ||||
public function clearFolder($mailbox) | public function clearFolder($mailbox) | ||||
{ | { | ||||
$res = false; | |||||
if ($this->countMessages($mailbox) > 0) { | if ($this->countMessages($mailbox) > 0) { | ||||
$res = $this->flag($mailbox, '1:*', 'DELETED'); | $res = $this->flag($mailbox, '1:*', 'DELETED'); | ||||
} | } | ||||
if ($res) { | if ($res) { | ||||
if ($this->selected === $mailbox) { | if ($this->selected === $mailbox) { | ||||
$res = $this->close(); | $res = $this->close(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | |||||
* @return int Number of messages, False on error | * @return int Number of messages, False on error | ||||
*/ | */ | ||||
public function countMessages($mailbox) | public function countMessages($mailbox) | ||||
{ | { | ||||
if ($this->selected === $mailbox && isset($this->data['EXISTS'])) { | if ($this->selected === $mailbox && isset($this->data['EXISTS'])) { | ||||
return $this->data['EXISTS']; | return $this->data['EXISTS']; | ||||
} | } | ||||
// Check internal cache | if (isset($this->data["STATUS:".$mailbox])) { | ||||
$cache = $this->data['STATUS:'.$mailbox]; | $cache = $this->data["STATUS:".$mailbox]; | ||||
if (!empty($cache) && isset($cache['MESSAGES'])) { | if (!empty($cache) && isset($cache['MESSAGES'])) { | ||||
return (int) $cache['MESSAGES']; | return (int) $cache['MESSAGES']; | ||||
} | } | ||||
} | |||||
// Try STATUS (should be faster than SELECT) | // Try STATUS (should be faster than SELECT) | ||||
$counts = $this->status($mailbox); | $counts = $this->status($mailbox); | ||||
if (is_array($counts)) { | if (is_array($counts)) { | ||||
return (int) $counts['MESSAGES']; | return (int) $counts['MESSAGES']; | ||||
} | } | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 2,455 Lines • Show Last 20 Lines |