From 614c642a4ba8b050ecb26d25d349077f6192aa8d Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 17 Sep 2010 05:14:13 -0400
Subject: [PATCH] - Fix list_cols is not updated after column dragging (#1486999) - Improved save-pref action and moved to separate file in utils task directory - Improved http_post/http_request to support first argument in form 'task/action'

---
 program/steps/mail/func.inc |   35 +++++++++++++++++++++++++----------
 1 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index eb785ca..91fd05e 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -171,7 +171,9 @@
       && (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false)
     $a_show_cols[$f] = 'to';
 
-  // make sure 'threads' column is present 
+  // make sure 'threads' and 'subject' columns are present
+  if (!in_array('subject', $a_show_cols))
+    array_unshift($a_show_cols, 'subject');
   if (!in_array('threads', $a_show_cols))
     array_unshift($a_show_cols, 'threads');
 
@@ -223,28 +225,41 @@
 
 /**
  * return javascript commands to add rows to the message list
- * or to replace the whole list (IE only)
  */
-function rcmail_js_message_list($a_headers, $insert_top=FALSE, $head_replace=FALSE)
+function rcmail_js_message_list($a_headers, $insert_top=FALSE, $a_show_cols=null)
 {
   global $CONFIG, $IMAP, $RCMAIL, $OUTPUT;
 
-  if (!empty($_SESSION['list_attrib']['columns']))
-    $a_show_cols = $_SESSION['list_attrib']['columns'];
-  else
-    $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject');
+  if (empty($a_show_cols)) {
+    if (!empty($_SESSION['list_attrib']['columns']))
+      $a_show_cols = $_SESSION['list_attrib']['columns'];
+    else
+      $a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject');
+  }
+  else {
+    if (!is_array($a_show_cols))
+      $a_show_cols = preg_split('/[\s,;]+/', strip_quotes($a_show_cols));
+    $head_replace = true;
+  }
 
   $mbox = $IMAP->get_mailbox_name();
   $delim = $IMAP->get_hierarchy_delimiter();
+
+  // make sure 'threads' and 'subject' columns are present
+  if (!in_array('subject', $a_show_cols))
+    array_unshift($a_show_cols, 'subject');
+  if (!in_array('threads', $a_show_cols))
+    array_unshift($a_show_cols, 'threads');
+
+  $_SESSION['list_attrib']['columns'] = $a_show_cols;
 
   // show 'to' instead of 'from' in sent/draft messages
   if ((strpos($mbox.$delim, $CONFIG['sent_mbox'].$delim)===0 || strpos($mbox.$delim, $CONFIG['drafts_mbox'].$delim)===0)
       && (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false)
     $a_show_cols[$f] = 'to';
 
-  // make sure 'threads' column is present 
-  if (!in_array('threads', $a_show_cols))
-    array_unshift($a_show_cols, 'threads');
+  // Make sure there are no duplicated columns (#1486999)
+  $a_show_cols = array_unique($a_show_cols);
 
   // Plugins may set header's list_cols/list_flags and other rcube_mail_header variables
   // and list columns

--
Gitblit v1.9.1