Translated strings in plugin to gettext.
[squirrelmail.git] / functions / imap_messages.php
index 8fd99a9fde1346258be5d6f2019eb260a1496342..d609c8ea873b212380fc7639a99de4055e01d280 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * imap_messages.php
  *
- * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
  * Licensed under the GNU GPL. For full terms see the file COPYING.
  *
  * This implements functions that manipulate messages
@@ -21,7 +21,6 @@ function sqimap_messages_copy ($imap_stream, $start, $end, $mailbox) {
 function sqimap_msgs_list_copy ($imap_stream, $id, $mailbox) {
     global $uid_support;
     $msgs_id = sqimap_message_list_squisher($id);    
-    echo $msgs_id;
     $read = sqimap_run_command ($imap_stream, "COPY $msgs_id \"$mailbox\"", true, $response, $message, $uid_support);
     $read = sqimap_run_command ($imap_stream, "STORE $msgs_id +FLAGS (\\Deleted)", true, $response, $message, $uid_support);
 }
@@ -44,7 +43,7 @@ function sqimap_msgs_list_delete ($imap_stream, $mailbox, $id) {
     if (($move_to_trash == true) && (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
         $read = sqimap_run_command ($imap_stream, "COPY $msgs_id \"$trash_folder\"", true, $response, $message, $uid_support);
     }
-    $read = sqimap_run_command ($imap_stream, "STORE $msgs_id +FLAGS (\\Deleted)", $handle_errors, $response, $message, $uid_support);
+    $read = sqimap_run_command ($imap_stream, "STORE $msgs_id +FLAGS (\\Deleted)", true, $response, $message, $uid_support);
 }
 
 
@@ -85,7 +84,7 @@ function sqimap_get_small_header ($imap_stream, $id, $sent) {
  */
 function sqimap_message_list_squisher($messages_array) {
     if( !is_array( $messages_array ) ) {
-        return;
+        return $messages_array;
     }
 
     sort($messages_array, SORT_NUMERIC);
@@ -380,10 +379,6 @@ function get_thread_sort ($imap_stream) {
     if (isset($thread_list)) {
         $thread_temp = preg_split("//", $thread_list, -1, PREG_SPLIT_NO_EMPTY);
     }
-    $t = new thread();
-    $t->parseThread($thread_list);
-    print_r($t);
-    echo $thread_list;
     $char_count = count($thread_temp);
     $counter = 0;
     $thread_new = array();
@@ -421,53 +416,6 @@ function get_thread_sort ($imap_stream) {
     return $thread_list;
 }
 
-class thread {
-   var $thread_cnt=0,
-       $id='',
-       $childs = array();
-       
-   function addChild($id) {
-       $this->childs[] = new thread();
-   }
-   
-   function parseThread($thread_list, $i=0, $thread_cnt=0) {
-        $par = false;
-       $thread_id = '';
-       for ($cnt = strlen($thread_list);$i<$cnt;++$i) {
-           $char = $thread_list{$i};
-           switch ($char) {
-           case '(':
-               $par = new thread();
-               ++$thread_cnt;
-               $thread_id = '';
-               break;
-           case ' ':
-               $par->id = $thread_id;
-               ++$thread_cnt;
-               $res_a = $this->parseThread($thread,$i, $thread_cnt);
-               $par->childs[] = $res_a[0];
-               $i = $res_a[1];
-               $thread_id = '';
-               break;
-           case ')':
-               if ($thread_id) {
-                   $par->id = $thread_id;
-                   $thread_id='';
-               }
-               $par->thread_cnt=$thread_cnt;
-               if (count($this->childs)) {
-                   return array($par, $i);
-               } else {
-                   $this->childs[] = $par;
-               }
-           default:
-               $thread_id .= $char;
-               break;
-           }
-       }
-       print_r($this);
-    }               
-}   
 
 function elapsedTime($start) {
  $stop = gettimeofday();
@@ -512,14 +460,14 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list) {
                       _("ERROR : Could not complete request.") .
                       '</b><br>' .
                       _("Unknown response from IMAP server: ") . ' 1.' .
-                      $r[0] . "</font><br>\n";
+                      htmlspecialchars($r[0]) . "</font><br>\n";
             } else if (! isset($id2index[$regs[1]]) || !count($id2index[$regs[1]])) {
                 set_up_language($squirrelmail_language);
                 echo '<br><b><font color=$color[2]>' .
                       _("ERROR : Could not complete request.") .
                       '</b><br>' .
                       _("Unknown message number in reply from server: ") .
-                      $regs[1] . "</font><br>\n";
+                      htmlspecialchars($regs[1]) . "</font><br>\n";
             } else {
                 $read_list[$id2index[$regs[1]]] = $r;
             }
@@ -530,14 +478,14 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list) {
                      _("ERROR : Could not complete request.") .
                      '</b><br>' .
                      _("Unknown response from IMAP server: ") . ' 1.' .
-                     $r[0] . "</font><br>\n";
+                     htmlspecialchars($r[0]) . "</font><br>\n";
             } else if (! isset($id2index[$regs[2]]) || !count($id2index[$regs[2]])) {
                 set_up_language($squirrelmail_language);
                 echo '<br><b><font color=$color[2]>' .
                       _("ERROR : Could not complete request.") .
                       '</b><br>' .
                       _("Unknown message number in reply from server: ") .
-                      $regs[2] . "</font><br>\n";
+                      htmlspecialchars($regs[2]) . "</font><br>\n";
             } else {
                 $read_list[$id2index[$regs[2]]] = $r;
                 $unique_id = $regs[2];
@@ -561,13 +509,13 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list) {
         $subject = _("(no subject)");
         $from = _("Unknown Sender");
         $priority = 0;
-        $messageid = "<>";
-        $cc = "";
-        $to = "";
-        $date = "";
-        $type[0] = "";
-        $type[1] = "";
-        $inrepto = "";
+        $messageid = '<>';
+        $cc = '';
+        $to = '';
+        $date = '';
+        $type[0] = '';
+        $type[1] = '';
+        $inrepto = '';
         $flag_seen = false;
         $flag_answered = false;
         $flag_deleted = false;
@@ -577,9 +525,9 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list) {
 
         foreach ($read as $read_part) {
             //unfold multi-line headers
-           if ($prevline && strpos($read_part, "\t ") === true) {
-               $read_part = substr($prevline, 0, -2) . preg_replace('/(\t\s+)/',' ',$read_part);
-           }
+            if ($prevline && strpos($read_part, "\t ") === true) {
+                $read_part = substr($prevline, 0, -2) . preg_replace('/(\t\s+)/',' ',$read_part);
+            }
             $prevline = $read_part;
             if ($read_part{0} == '*') {
                 if ($internaldate) {
@@ -588,7 +536,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list) {
                         $tmpdate = str_replace('  ',' ',$tmpdate);
                         $tmpdate = explode(' ',$tmpdate);
                         $date = str_replace('-',' ',$tmpdate[0]) . " " .
-                                $tmpdate[1] . " " .
+                                $tmpdate[1] . ' ' .
                                 $tmpdate[2];
                     }
                 }
@@ -614,7 +562,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list) {
                     $unique_id = $reg[1];
                 }
             } else {
-                $firstchar = $read_part{0};
+                $firstchar = strtoupper($read_part{0});
                 if ($firstchar == 'T') {
                     $regpattern = $patterns[0];
                     $id = 1;