From c075fcfeee6685e97ac75f7400f267ddaa7c3e28 Mon Sep 17 00:00:00 2001 From: kink Date: Mon, 24 May 2004 19:55:21 +0000 Subject: [PATCH] Replace array_search that only uses a boolean to check whether the value exists with in_array (which returns just that boolean), and fix the left over call to array_search to also check for NULL return. This should fix the problems that Fredrik, me and other PHP 4.1 users had with Marc's recent changes. From PHP docs: "Note: Prior to PHP 4.2.0, array_search() returns NULL on failure instead of FALSE." git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7547 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/imap_mailbox.php | 2 +- functions/imap_messages.php | 6 +----- functions/mailbox_display.php | 8 ++++---- src/read_body.php | 12 +++++------- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/functions/imap_mailbox.php b/functions/imap_mailbox.php index 13eab2d4..e2198947 100755 --- a/functions/imap_mailbox.php +++ b/functions/imap_mailbox.php @@ -269,7 +269,7 @@ function sqimap_mailbox_expunge_dmn($imapConnection, &$aMailbox, $message_id) { $message_id = (int) $message_id; // we use strickt array_search if (is_array($aMailbox['UIDSET'])) { $key = array_search($message_id,$aMailbox['UIDSET'],true); - if ($key !== false) { + if ($key !== false && !is_null($key)) { unset($aMailbox['UIDSET'][$key]); $aMailbox['UIDSET'] = array_values($aMailbox['UIDSET']); // adapt the exists count to avoid triggering of a new sort diff --git a/functions/imap_messages.php b/functions/imap_messages.php index 2f14a908..5930134d 100755 --- a/functions/imap_messages.php +++ b/functions/imap_messages.php @@ -534,11 +534,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false, $messages = array(); $read_list = array(); - if (array_search('UID',$aFetchItems,true) !== false) { - $bUidFetch = false; - } else { - $bUidFetch = true; - } + $bUidFetch = ! in_array('UID', $aFetchItems, true); /* Get the small headers for each message in $msg_list */ if ($show_num != '999999' && $show_num != '*' ) { diff --git a/functions/mailbox_display.php b/functions/mailbox_display.php index 433f5105..b256a43e 100644 --- a/functions/mailbox_display.php +++ b/functions/mailbox_display.php @@ -856,12 +856,12 @@ function mail_message_listing_beginning ($imapConnection, // display flag buttons only if supported if ($show_flag_buttons && - array_search('\\flagged',$aMailbox['PERMANENTFLAGS'], true) !== FALSE) { + in_array('\\flagged',$aMailbox['PERMANENTFLAGS'], true) ) { echo getButton('SUBMIT', 'markUnflagged',_("Unflag")); echo getButton('SUBMIT', 'markFlagged',_("Flag")); echo ' '; } - if (array_search('\\seen',$aMailbox['PERMANENTFLAGS'], true) !== FALSE) { + if (in_array('\\seen',$aMailbox['PERMANENTFLAGS'], true)) { echo getButton('SUBMIT', 'markUnread',_("Unread")); echo getButton('SUBMIT', 'markRead',_("Read")); echo ' '; @@ -869,7 +869,7 @@ function mail_message_listing_beginning ($imapConnection, echo getButton('SUBMIT', 'attache',_("Forward")); echo ' '; - if (array_search('\\deleted',$aMailbox['PERMANENTFLAGS'], true) !== FALSE) { + if (in_array('\\deleted',$aMailbox['PERMANENTFLAGS'], true)) { echo getButton('SUBMIT', 'delete',_("Delete")); echo '' . _("Bypass Trash"); echo ' '; @@ -882,7 +882,7 @@ function mail_message_listing_beginning ($imapConnection, ?> '; //echo $thread_link_str; //previous behaviour diff --git a/src/read_body.php b/src/read_body.php index f72f6a15..7e12373e 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -119,10 +119,8 @@ function printer_friendly_link($mailbox, $passed_id, $passed_ent_id) { function ServerMDNSupport($aFlags) { /* escaping $ doesn't work -> \x36 */ - return (array_search('$mdnsent',$aFlags,true) !== false || - array_search('\\*',$aFlags,true) !== false) ? true : false; - //$ret = preg_match('/(\x36MDNSent|\\\\\*)/i', $read); - //return $ret; + return ( in_array('$mdnsent',$aFlags,true) || + in_array('\\*',$aFlags,true) ) ; } function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) { @@ -548,7 +546,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res // Only bother with Delete & Prev and Delete & Next IF // top display is enabled. if ( $delete_prev_next_display == 1 && - array_search('\\deleted', $mbx_response['PERMANENTFLAGS'],true) !== false) { + in_array('\\deleted', $mbx_response['PERMANENTFLAGS'],true) ) { $del_prev_link = _("Delete & Prev"); if ($prev >= 0) { $uri = $base_uri . 'src/read_body.php?passed_id='.$prev. @@ -634,7 +632,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res $menu_row .= ' '; - if (array_search('\\deleted', $mbx_response['PERMANENTFLAGS'],true) !== false) { + if ( in_array('\\deleted', $mbx_response['PERMANENTFLAGS'],true) ) { // Form for deletion $delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox; $menu_row .= '
'; @@ -661,7 +659,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res // Add top move link $menu_row .= ''; if ( !(isset($passed_ent_id) && $passed_ent_id) && - array_search('\\deleted', $mbx_response['PERMANENTFLAGS'],true) !== false) { + in_array('\\deleted', $mbx_response['PERMANENTFLAGS'],true) ) { $current_box = 'mailbox='.$mailbox.'&sort='.$sort.'&startMessage='.$startMessage; -- 2.25.1