| | |
| | | |
| | | /* |
| | | +-----------------------------------------------------------------------+ |
| | | | program/include/rcube_imap.php | |
| | | | | |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2012, The Roundcube Dev Team | |
| | | | Copyright (C) 2011-2012, Kolab Systems AG | |
| | |
| | | | | |
| | | | PURPOSE: | |
| | | | IMAP Storage Engine | |
| | | | | |
| | | +-----------------------------------------------------------------------+ |
| | | | Author: Thomas Bruederli <roundcube@gmail.com> | |
| | | | Author: Aleksander Machniak <alec@alec.pl> | |
| | | +-----------------------------------------------------------------------+ |
| | | */ |
| | | |
| | | |
| | | /** |
| | | * Interface class for accessing an IMAP server |
| | |
| | | |
| | | $attempt = 0; |
| | | do { |
| | | $data = rcube::get_instance()->plugins->exec_hook('imap_connect', |
| | | $data = rcube::get_instance()->plugins->exec_hook('storage_connect', |
| | | array_merge($this->options, array('host' => $host, 'user' => $user, |
| | | 'attempt' => ++$attempt))); |
| | | |
| | |
| | | * Get message count for a specific folder |
| | | * |
| | | * @param string $folder Folder name |
| | | * @param string $mode Mode for count [ALL|THREADS|UNSEEN|RECENT] |
| | | * @param string $mode Mode for count [ALL|THREADS|UNSEEN|RECENT|EXISTS] |
| | | * @param boolean $force Force reading from server and update cache |
| | | * @param boolean $status Enables storing folder status info (max UID/count), |
| | | * required for folder_status() |
| | |
| | | * protected method for getting nr of messages |
| | | * |
| | | * @param string $folder Folder name |
| | | * @param string $mode Mode for count [ALL|THREADS|UNSEEN|RECENT] |
| | | * @param string $mode Mode for count [ALL|THREADS|UNSEEN|RECENT|EXISTS] |
| | | * @param boolean $force Force reading from server and update cache |
| | | * @param boolean $status Enables storing folder status info (max UID/count), |
| | | * required for folder_status() |
| | |
| | | return $this->search_set->count(); |
| | | } |
| | | } |
| | | |
| | | // EXISTS is a special alias for ALL, it allows to get the number |
| | | // of all messages in a folder also when search is active and with |
| | | // any skip_deleted setting |
| | | |
| | | $a_folder_cache = $this->get_cache('messagecount'); |
| | | |
| | |
| | | $count = $this->conn->countRecent($folder); |
| | | } |
| | | // use SEARCH for message counting |
| | | else if (!empty($this->options['skip_deleted'])) { |
| | | else if ($mode != 'EXISTS' && !empty($this->options['skip_deleted'])) { |
| | | $search_str = "ALL UNDELETED"; |
| | | $keys = array('COUNT'); |
| | | |
| | |
| | | } |
| | | else { |
| | | $count = $this->conn->countMessages($folder); |
| | | if ($status) { |
| | | $this->set_folder_stats($folder,'cnt', $count); |
| | | if ($status && $mode == 'ALL') { |
| | | $this->set_folder_stats($folder, 'cnt', $count); |
| | | $this->set_folder_stats($folder, 'maxuid', $count ? $this->id2uid($count, $folder) : 0); |
| | | } |
| | | } |
| | |
| | | * @param boolean $is_file True if $message is a filename |
| | | * @param array $flags Message flags |
| | | * @param mixed $date Message internal date |
| | | * @param bool $binary Enables BINARY append |
| | | * |
| | | * @return int|bool Appended message UID or True on success, False on error |
| | | */ |
| | | public function save_message($folder, &$message, $headers='', $is_file=false, $flags = array(), $date = null) |
| | | public function save_message($folder, &$message, $headers='', $is_file=false, $flags = array(), $date = null, $binary = false) |
| | | { |
| | | if (!strlen($folder)) { |
| | | $folder = $this->folder; |
| | |
| | | $date = $this->date_format($date); |
| | | |
| | | if ($is_file) { |
| | | $saved = $this->conn->appendFromFile($folder, $message, $headers, $flags, $date); |
| | | $saved = $this->conn->appendFromFile($folder, $message, $headers, $flags, $date, $binary); |
| | | } |
| | | else { |
| | | $saved = $this->conn->append($folder, $message, $flags, $date); |
| | | $saved = $this->conn->append($folder, $message, $flags, $date, $binary); |
| | | } |
| | | |
| | | if ($saved) { |