Replace array_search that only uses a boolean to check whether the value
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 24 May 2004 19:55:21 +0000 (19:55 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 24 May 2004 19:55:21 +0000 (19:55 +0000)
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
functions/imap_messages.php
functions/mailbox_display.php
src/read_body.php

index 13eab2d..e219894 100755 (executable)
@@ -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
index 2f14a90..5930134 100755 (executable)
@@ -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 != '*' ) {
index 433f510..b256a43 100644 (file)
@@ -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 '&nbsp;';
                     }
-                    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 '&nbsp;';
@@ -869,7 +869,7 @@ function mail_message_listing_beginning ($imapConnection,
 
                     echo getButton('SUBMIT', 'attache',_("Forward"));
                     echo '&nbsp;';
-                    if (array_search('\\deleted',$aMailbox['PERMANENTFLAGS'], true) !== FALSE) {
+                    if (in_array('\\deleted',$aMailbox['PERMANENTFLAGS'], true)) {
                         echo getButton('SUBMIT', 'delete',_("Delete"));
                         echo '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash");
                         echo '&nbsp;';
@@ -882,7 +882,7 @@ function mail_message_listing_beginning ($imapConnection,
                 ?></small>
                 </td>
                 <?php
-                if (array_search('\\deleted',$aMailbox['PERMANENTFLAGS'], true) !== FALSE) {
+                if (in_array('\\deleted',$aMailbox['PERMANENTFLAGS'], true)) {
                     echo '<td align="right">
                 <small>';
                     //echo $thread_link_str;   //previous behaviour
index f72f6a1..7e12373 100644 (file)
@@ -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 .= '</form>&nbsp;';
 
-    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 .= '<form action="'.$delete_url.'" method="post" style="display: inline">';
@@ -661,7 +659,7 @@ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $mbx_res
     // Add top move link
     $menu_row .= '</small></td><td align="right">';
     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;