/**
* imap_messages.php
*
- * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* This implements functions that manipulate messages
* @param string $mailbox Mailbox messages are being deleted from
* @return void
*/
-function sqimap_messages_delete ($imap_stream, $start, $end, $mailbox) {
+function sqimap_messages_delete ($imap_stream, $start, $end, $mailbox, $bypass_trash=false) {
global $move_to_trash, $trash_folder, $auto_expunge, $uid_support;
- if (($move_to_trash == true) && (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
+ if (($move_to_trash == true) && ($bypass_trash != true) &&
+ (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
sqimap_messages_copy ($imap_stream, $start, $end, $trash_folder);
}
sqimap_messages_flag ($imap_stream, $start, $end, "Deleted", true);
function sqimap_msgs_list_delete ($imap_stream, $mailbox, $id, $bypass_trash=false) {
global $move_to_trash, $trash_folder, $uid_support;
$msgs_id = sqimap_message_list_squisher($id);
- if (($move_to_trash == true) && (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder)) && ($bypass_trash != true)) {
+ if (($move_to_trash == true) && ($bypass_trash != true) &&
+ (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder)) ) {
$read = sqimap_run_command ($imap_stream, "COPY $msgs_id " . sqimap_encode_mailbox_name($trash_folder), true, $response, $message, $uid_support);
}
$read = sqimap_run_command ($imap_stream, "STORE $msgs_id +FLAGS (\\Deleted)", true, $response, $message, $uid_support);
return $server_sort_array;
}
-
+/**
+ * Get sort order from server if server does not have the SORT extension
+ * and return it as array for mailbox_display.
+ *
+ * @param resource $imap_stream
+ * @param array $mbxresponse response from a sqimap_mailbox_select
+ * @return array $php_sort_array
+ */
function sqimap_get_php_sort_order ($imap_stream, $mbxresponse) {
global $uid_support;
$query = "SEARCH UID 1:$uidnext";
$uids = sqimap_run_command ($imap_stream, $query, true, $response, $message, true);
if (isset($uids[0])) {
- if (preg_match("/^\* SEARCH (.+)$/", $uids[0], $regs)) {
- $php_sort_array = preg_split("/ /", trim($regs[1]));
+ $php_sort_array = array();
+ // EIMS workaround. EIMS returns the result as multiple untagged SEARCH responses
+ foreach($uids as $line) {
+ if (preg_match("/^\* SEARCH (.+)$/", $line, $regs)) {
+ $php_sort_array += preg_split("/ /", trim($regs[1]));
+ }
}
}
if (!preg_match("/OK/", $response)) {
$i = 0;
foreach ($read_list as $r) {
+ /* initialize/reset vars */
$subject = _("(no subject)");
$from = _("Unknown sender");
$priority = 0;
$messageid = '<>';
- $cc = $to = $date = $type[0] = $type[1] = $inrepto = '';
+ $type = array('','');
+ $cc = $to = $inrepto = '';
+ // use unset because we do isset below
+ unset($date);
$flag_seen = $flag_answered = $flag_deleted = $flag_flagged = false;
$read = implode('',$r);
$i = strpos($read,'{',$i);
$header = parseString($read,$i);
if ($header === false) break 3;
- /* First we unfold the header */
- $hdr = trim(str_replace(array("\r\n\t", "\r\n "),array('', ''), $header));
+ /* First we replace all \r\n by \n, and unfold the header */
+ $hdr = trim(str_replace(array("\r\n", "\n\t", "\n "),array("\n", ' ', ' '), $header));
/* Now we can make a new header array with */
/* each element representing a headerline */
- $hdr = explode("\r\n" , $hdr);
+ $hdr = explode("\n" , $hdr);
foreach ($hdr as $line) {
$pos = strpos($line, ':');
if ($pos > 0) {
if(!is_array($type)) {
$type[0] = 'text';
}
- if (!isset($type[1])) {
- $type[1] = '';
- }
break;
default: break;
}
$date = str_replace(' ', ' ', $date);
$tmpdate = explode(' ', trim($date));
} else {
- $tmpdate = $date = array('', '', '', '', '', '');
+ $tmpdate = $date = array();
}
if ($uid_support) {
$msgi ="$unique_id";