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 13eab2d4d868c18907c3d77753023506c1d1d58b..e2198947a7629fdfa923d45494c76eec7f4c194c 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 2f14a9084f5aca13ad6f969cde462a3ce81e9227..5930134d09f5c52770f49529072765ad6ea9d46f 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 433f5105cfa11f188007f680e169362dd5717482..b256a43ec3e1e8e49597fe03d4a3361e9fbd0987 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 f72f6a150b68bb7bb1139d342d2c815b5d154ba3..7e12373efcb5c20c50b35f2441a3ecbf61c26708 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;