fix sort by internaldate if the internaldate does not have the expected
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 21 May 2004 16:00:16 +0000 (16:00 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 21 May 2004 16:00:16 +0000 (16:00 +0000)
format.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7511 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/date.php
functions/imap_messages.php

index 82190a0f66eec7ac974dbae9002ff3d85ac70052..2f65cc6cc3a8aa311cdc33082c98481f0ad958ff 100644 (file)
@@ -37,26 +37,26 @@ function getGMTSeconds($stamp, $tzc) {
         case 'PST':
             $tzc = '-0800';
             break;
-        case 'Mountain':   
-        case 'MST':   
-        case 'PDT':   
-            $tzc = '-0700';     
+        case 'Mountain':
+        case 'MST':
+        case 'PDT':
+            $tzc = '-0700';
             break;
         case 'Central':
         case 'CST':
-        case 'MDT':   
-            $tzc = '-0600';     
+        case 'MDT':
+            $tzc = '-0600';
             break;
         case 'Eastern':
         case 'EST':
-        case 'CDT':   
-            $tzc = '-0500';     
+        case 'CDT':
+            $tzc = '-0500';
             break;
         case 'EDT':
             $tzc = '-0400';
             break;
-        case 'GMT':   
-            $tzc = '+0000';     
+        case 'GMT':
+            $tzc = '+0000';
             break;
         case 'BST':
         case 'MET':
@@ -64,17 +64,17 @@ function getGMTSeconds($stamp, $tzc) {
             $tzc = '+0100';
             break;
         case 'EET':
-        case 'IST':   
-        case 'MET DST':   
-        case 'METDST':   
-            $tzc = '+0200';     
+        case 'IST':
+        case 'MET DST':
+        case 'METDST':
+            $tzc = '+0200';
             break;
-        case 'HKT':   
-            $tzc = '+0800';     
+        case 'HKT':
+            $tzc = '+0800';
             break;
-        case 'JST':   
+        case 'JST':
         case 'KST':
-            $tzc = '+0900';     
+            $tzc = '+0900';
             break;
     }
     $neg = false;
@@ -86,14 +86,14 @@ function getGMTSeconds($stamp, $tzc) {
     $hh = substr($tzc,1,2);
     $mm = substr($tzc,3,2);
     $iTzc = ($hh * 60 + $mm) * 60;
-    if ($neg) $iTzc = -1 * (int) $iTzc; 
+    if ($neg) $iTzc = -1 * (int) $iTzc;
     /* stamp in gmt */
     $stamp -= $iTzc;
     /** now find what the server is at **/
     $current = date('Z', time());
     /* stamp in local timezone */
     $stamp += $current;
-    
+
     return $stamp;
 }
 
@@ -176,7 +176,7 @@ function getDayAbrv( $day_number ) {
 /**
  * Returns the (localized) string for a given month number.
  *
- * @param string month_number the month number (01..12) 
+ * @param string month_number the month number (01..12)
  * @return string the month name in human readable form
  */
 function getMonthName( $month_number ) {
@@ -227,7 +227,7 @@ function getMonthName( $month_number ) {
  * Returns the (localized) string for a given month number,
  * short representation.
  *
- * @param string month_number the month number (01..12) 
+ * @param string month_number the month number (01..12)
  * @return string the shortened month in human readable form
  */
 function getMonthAbrv( $month_number ) {
@@ -286,7 +286,7 @@ function date_intl( $date_format, $stamp ) {
     // to reduce the date calls we retrieve m and w in the same call
     $ret = date('w#m#'. $ret, $stamp );
     // extract day and month in order to replace later by intl day and month
-    $aParts = explode('#',$ret);        
+    $aParts = explode('#',$ret);
     $ret = str_replace(array('$1','$4','$2','$3',), array(getDayAbrv($aParts[0]),
                                                           getMonthAbrv($aParts[1]),
                                                          getMonthName($aParts[1]),
@@ -306,7 +306,7 @@ function date_intl( $date_format, $stamp ) {
 function getLongDateString( $stamp ) {
 
     global $hour_format;
-    
+
     if ($stamp == -1) {
         return '';
     }
@@ -316,7 +316,7 @@ function getLongDateString( $stamp ) {
     } else {
         $date_format = _("D, F j, Y G:i");
     }
-    
+
     return( date_intl( $date_format, $stamp ) );
 
 }
@@ -338,19 +338,19 @@ function getDateString( $stamp ) {
     if ( $stamp == -1 ) {
        return '';
     }
-    
+
     $now = time();
-    
+
     $dateZ = date('Z', $now );
 
     // FIXME: isn't this obsolete and introduced as a terrible workaround
-    // for bugs at other places which are fixed a long time ago? 
+    // for bugs at other places which are fixed a long time ago?
     if ($invert_time) {
         $dateZ = - $dateZ;
     }
     $midnight = $now - ($now % 86400) - $dateZ;
     $nextmid = $midnight + 86400 - $dateZ;
-    
+
     if (($show_full_date == 1) || ($nextmid < $stamp)) {
         $date_format = _("M j, Y");
     } else if ($midnight < $stamp) {
@@ -371,7 +371,7 @@ function getDateString( $stamp ) {
         /* before this week */
         $date_format = _("M j, Y");
     }
-    
+
     return( date_intl( $date_format, $stamp ) );
 }
 
@@ -395,13 +395,22 @@ function getTimeStamp($dateParts) {
     **        and everything would be bumped up one.
     **/
 
-    /* 
+    /*
      * Simply check to see if the first element in the dateParts
      * array is an integer or not.
      * Since the day of week is optional, this check is needed.
      */
      if (count($dateParts) <2) {
         return -1;
+     } else if (count($dateParts) ==3) {
+        if (substr_count($dateParts[0],'-') == 2 &&
+            substr_count($dateParts[1],':') == 2) {
+            //  dd-Month-yyyy 23:19:05 +0200
+            //  redefine the date
+            $aDate = explode('-',$dateParts[0]);
+            $newDate = array($aDate[0],$aDate[1],$aDate[2],$dateParts[1],$dateParts[2]);
+            $dateParts = $newDate;
+        }
      }
 
     /* remove day of week */
index 709668b1fd14e177213bec6c6f95abda5b277535..4dfa79d584190e6695c747b47c6af7881531d89e 100755 (executable)
@@ -210,6 +210,7 @@ function get_squirrel_sort ($imap_stream, $sSortField, $reverse = false) {
         $msgs = sqimap_get_small_header_list($imap_stream, false, '*',
                                       array(), array('UID', $sSortField));
     }
+    $aUid = array();
     $walk = false;
     switch ($sSortField) {
       // natcasesort section
@@ -254,8 +255,13 @@ function get_squirrel_sort ($imap_stream, $sSortField, $reverse = false) {
         }
         // nobreak;
       case 'RFC822.SIZE':
+        if(!$walk) {
+            // redefine $sSortField to maintain the same namespace between
+            // server-side sorting and squirrelmail sorting
+            $sSortField = 'SIZE';
+        }
         foreach ($msgs as $item) {
-            $aUid[$item['ID']] = isset($item['SIZE']) ? $item['SIZE'] : 0;
+            $aUid[$item['ID']] = (isset($item[$sSortField])) ? $item[$sSortField] : 0;
         }
         if ($reverse) {
             arsort($aUid,SORT_NUMERIC);
@@ -666,7 +672,7 @@ function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false,
 
                 break;
             case 'INTERNALDATE':
-                $msg['INTERNALDATE'] = parseString($read,$i);
+                $msg['INTERNALDATE'] = str_replace('  ', ' ',parseString($read,$i));
                 break;
             case 'BODY.PEEK[HEADER.FIELDS':
             case 'BODY[HEADER.FIELDS':