Correct changes of "" to ''.
[squirrelmail.git] / functions / imap_search.php
index d765c65f31c627260a52e56d3d87ce3401988c94..a9cda0660a1fc32bf1920dac85f614a88db5a80b 100644 (file)
@@ -1,6 +1,7 @@
-<?php     
+<?php 
 /******************************************************************
  ** IMAP SEARCH ROUTIES
+ ** $Id$
  *****************************************************************/
    if (!isset($imap_php))
       include("../functions/imap.php");
@@ -21,7 +22,7 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
    
    # Construct the Search QuERY
    
-   if ($languages[$squirrelmail_language]["CHARSET"]) {
+   if (isset($languages[$squirrelmail_language]["CHARSET"]) && $languages[$squirrelmail_language]["CHARSET"]) {
       $ss = "a001 SEARCH CHARSET ".$languages[$squirrelmail_language]["CHARSET"]." ALL $search_where \"$search_what\"\r\n";
    } else {
       $ss = "a001 SEARCH ALL $search_where \"$search_what\"\r\n";
@@ -38,16 +39,18 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
       #Check to see if a SEARCH Responce was recived
       if (substr($readin[$c],0,9) == "* SEARCH ")
          $messagelist = explode(" ",substr($readin[$c],9));
-      else
+      else if (isset($errors))
          $errors = $errors.$readin[$c];
+      else
+         $errors = $readin[$c];
       $c++;
    }
 
    #If nothing is found * SEARCH should be the first error else echo errors
-   if (strstr($errors,"* SEARCH")) {
+   if (isset($errors) && strstr($errors,"* SEARCH")) {
       echo "<br><CENTER>No Messages Found</CENTER>";
       return;
-   } else {
+   } else if (isset($errors)) {
       echo "<!-- ".$errors." -->";
    }
 
@@ -63,14 +66,15 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
       else
          $hdr = sqimap_get_small_header ($imapConnection, $messagelist[$q], false);
                                                
-                       $from[$q] = $hdr->from;
-                       $date[$q] = $hdr->date;
-                       $subject[$q] = $hdr->subject;
+         $from[$q] = $hdr->from;
+         $date[$q] = $hdr->date;
+         $subject[$q] = $hdr->subject;
          $to[$q] = $hdr->to;
          $priority[$q] = $hdr->priority;
          $cc[$q] = $hdr->cc;
+                $size[$q] = $hdr->size;
+                $type[$q] = $hdr->type0;
          $id[$q] = $messagelist[$q];
-
          $flags[$q] = sqimap_get_flags ($imapConnection, $messagelist[$q]);
       }
 
@@ -87,8 +91,10 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
          $messages[$j]["SUBJECT"] = decodeHeader($subject[$j]);
          $messages[$j]["SUBJECT-SORT"] = strtolower(decodeHeader($subject[$j]));
          $messages[$j]["TO"] = decodeHeader($to[$j]);
-                       $messages[$j]["PRIORITY"] = $priority[$j];
+         $messages[$j]["PRIORITY"] = $priority[$j];
          $messages[$j]["CC"] = $cc[$j];
+                $messages[$j]["SIZE"] = $size[$j];
+                $messages[$j]["TYPE0"] = $type[$j];
 
          $num = 0;
          while ($num < count($flags[$j])) {
@@ -113,7 +119,7 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
       $i = 0;
       $j = 0;
       while ($j < count($messagelist)) {
-         if ($messages[$j]["FLAG_DELETED"] == true) {
+         if (isset($messages[$j]["FLAG_DELETED"]) && $messages[$j]["FLAG_DELETED"] == true) {
             $j++;
             continue;
          }
@@ -128,6 +134,7 @@ function sqimap_search($imapConnection,$search_where,$search_what,$mailbox,$colo
 
       if (count($messagelist) > 0) {
          $j=0;
+                if (!isset ($msg)) { $msg = ""; }
          mail_message_listing_beginning($imapConnection, 
             "move_messages.php?msg=$msg&mailbox=$urlMailbox&where=".urlencode($search_where)."&what=".urlencode($search_what),
              '', -1, '<b>' . _("Found") . ' ' . count($messagelist) . ' ' . _("messages") . '</b>',