Browse Source

Fixed imap search bug.
Updated Spanish strings.

philippe_mingo 24 years ago
parent
commit
09481c9b5a
2 changed files with 20 additions and 15 deletions
  1. 1 0
      functions/imap_messages.php
  2. 19 15
      functions/imap_search.php

+ 1 - 0
functions/imap_messages.php

@@ -67,6 +67,7 @@
    // Sort the message list and crunch to be as small as possible
    // Sort the message list and crunch to be as small as possible
    // (overflow could happen, so make it small if possible)
    // (overflow could happen, so make it small if possible)
    function sqimap_message_list_squisher($messages_array) {
    function sqimap_message_list_squisher($messages_array) {
+      if( !is_array( $messages_array ) ) return;
       sort($messages_array, SORT_NUMERIC);
       sort($messages_array, SORT_NUMERIC);
       $msgs_str = '';
       $msgs_str = '';
       while ($messages_array) {
       while ($messages_array) {

+ 19 - 15
functions/imap_search.php

@@ -1,4 +1,4 @@
-<?php 
+<?php
    /******************************************************************
    /******************************************************************
     ** IMAP SEARCH ROUTIES
     ** IMAP SEARCH ROUTIES
     ** $Id$
     ** $Id$
@@ -17,30 +17,34 @@
 
 
 function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$color) {
 function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$color) {
    global $msgs, $message_highlight_list, $squirrelmail_language, $languages, $index_order;
    global $msgs, $message_highlight_list, $squirrelmail_language, $languages, $index_order;
+
    $urlMailbox = urlencode($mailbox);
    $urlMailbox = urlencode($mailbox);
-   
-   # Construct the Search QuERY
-   $ss = sqimap_session_id();
-   if (isset($languages[$squirrelmail_language]["CHARSET"]) && $languages[$squirrelmail_language]["CHARSET"]) {
-      $ss = " SEARCH CHARSET ".$languages[$squirrelmail_language]["CHARSET"]." ALL $search_where \"$search_what\"\r\n";
+   $isid = sqimap_session_id();
+
+   /* Construct the Search QuERY */
+   $ss = $isid;
+   if (isset($languages[$squirrelmail_language]['CHARSET']) &&
+       $languages[$squirrelmail_language]['CHARSET']) {
+      $ss .= " SEARCH CHARSET ".$languages[$squirrelmail_language]['CHARSET']." ALL $search_where \"$search_what\"\r\n";
    } else {
    } else {
-      $ss = " SEARCH ALL $search_where \"$search_what\"\r\n";
+      $ss .= " SEARCH ALL $search_where \"$search_what\"\r\n";
    }
    }
    fputs($imapConnection,$ss);
    fputs($imapConnection,$ss);
 
 
    # Read Data Back From IMAP
    # Read Data Back From IMAP
-   $readin = sqimap_read_data ($imapConnection, sqimap_session_id(), false, $result, $message);
-   if (isset($languages[$squirrelmail_language]["CHARSET"]) && strtolower($result) == "no") { 
-      $ss = sqimap_session_id() . " SEARCH CHARSET \"US-ASCII\" ALL $search_where \"$search_what\"\r\n";
+   $readin = sqimap_read_data ($imapConnection, $isid, false, $result, $message);
+   if (isset($languages[$squirrelmail_language]['CHARSET']) && strtolower($result) == 'no') {
+      $ss = $isid . " SEARCH CHARSET \"US-ASCII\" ALL $search_where \"$search_what\"\r\n";
       fputs ($imapConnection, $ss);
       fputs ($imapConnection, $ss);
-      $readin = sqimap_read_data ($imapConnection, sqimap_session_id(), true, $result, $message);
+      $readin = sqimap_read_data ($imapConnection, $isid, true, $result, $message);
    }
    }
+
    unset($messagelist); $msgs=""; $c = 0;
    unset($messagelist); $msgs=""; $c = 0;
 
 
-   #Keep going till we find the SEARCH responce
-   while ($c < count($readin)) {
+   /* Keep going till we find the SEARCH responce */
+   while ($c < count( $readin )) {
 
 
-      #Check to see if a SEARCH Responce was recived
+      /* Check to see if a SEARCH Responce was recived */
       if (substr($readin[$c],0,9) == "* SEARCH ")
       if (substr($readin[$c],0,9) == "* SEARCH ")
          $messagelist = explode(" ",substr($readin[$c],9));
          $messagelist = explode(" ",substr($readin[$c],9));
       else if (isset($errors))
       else if (isset($errors))
@@ -152,4 +156,4 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
       }
       }
    }
    }
 
 
-?>
+?>