Fix for folder cache if the cache was somehow broken. Reproduced bad cache
[squirrelmail.git] / functions / mailbox_display.php
index 4a58d6dacaa9177d04751a746bc960d5029741bf..26290e6813d059359eefd48b301f9e703ee530fb 100644 (file)
@@ -302,6 +302,7 @@ function fetchMessageHeaders($imapConnection, &$aMailbox) {
     $iError = 0;
     $aFetchItems = $aHeaderItems = array();
     // initialize the fields we want to retrieve:
+    $aHeaderFields = array();
     foreach ($aFetchHeaders as $v) {
       switch ($v) {
         case SQM_COL_DATE:       $aHeaderFields[] = 'Date';         break;
@@ -341,7 +342,7 @@ function fetchMessageHeaders($imapConnection, &$aMailbox) {
 
         $id_slice = array_slice($aUid,$start_msg-1,$iLimit);
         /* do some funky cache checks */
-        if (isset($aMailbox['MSG_HEADERS'])) {
+        if (isset($aMailbox['MSG_HEADERS']) && is_array($aMailbox['MSG_HEADERS'])) {
             $aUidCached = array_keys($aMailbox['MSG_HEADERS']);
         } else {
             $aMailbox['MSG_HEADERS'] = array();
@@ -575,7 +576,8 @@ function prepareMessageList(&$aMailbox, $aProps) {
                     // FIXME: don't break 8bit symbols and html entities during truncation
                     if (isset($aColumnDesc[$k]['truncate']) && $aColumnDesc[$k]['truncate']) {
                         $sTmp = truncateWithEntities($value, $aColumnDesc[$k]['truncate']-$iIndent);
-                        $title = ($sTmp != $value) ? $value : '';
+                        // drop any double spaces since these will be displayed in the title
+                        $title = ($sTmp != $value) ? preg_replace('/\s{2,}/', ' ', $value) : '';
                         $value = $sTmp;
                     }
                     /* generate the link to the message */
@@ -600,6 +602,8 @@ function prepareMessageList(&$aMailbox, $aProps) {
                                          'answered'=>false,
                                          'flagged' => false,
                                          'draft' => false);
+                                         
+                    if(!is_array($value)) $value = array();                     
                     foreach ($value as $sFlag => $value) {
                         switch ($sFlag) {
                           case '\\seen'    : $aFlagColumn['seen']     = true; break;
@@ -702,7 +706,7 @@ function setUserPref($username, $pref, $value) {
 */
 function _get_sorted_msgs_list($imapConnection,&$aMailbox) {
     $iSetIndx = (isset($aMailbox['SETINDEX'])) ? $aMailbox['SETINDEX'] : 0;
-    $bDirection = ($aMailbox['SORT'] % 2);
+    $bDirection = !($aMailbox['SORT'] % 2);
     $error = 0;
     if (!$aMailbox['SEARCH'][$iSetIndx]) {
         $aMailbox['SEARCH'][$iSetIndx] = 'ALL';
@@ -1055,7 +1059,6 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) {
     // FIX ME, before we support multiple templates we must review the names of the vars
 
 
-
     $aTemplate['color']     = $color;
     $aTemplate['form_name'] = "FormMsgs" . $safe_name;
     $aTemplate['form_id']   = 'mbx_'.$iFormId;
@@ -1085,6 +1088,7 @@ function showMessagesForMailbox($imapConnection, &$aMailbox,$aProps, &$iError) {
     $aTemplate['alt_index_colors'] = (isset($aProps['config']['alt_index_colors'])) ? $aProps['config']['alt_index_colors'] : false;
     $aTemplate['fancy_index_highlite'] = $fancy_index_highlite;
 
+
     return $aTemplate;
 }