From 614c642a4ba8b050ecb26d25d349077f6192aa8d Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 17 Sep 2010 09:14:13 +0000 Subject: - 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 +++++++++++++++++++++--------- program/steps/mail/list.inc | 4 ++-- program/steps/utils/save_pref.inc | 45 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 program/steps/utils/save_pref.inc (limited to 'program/steps') diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index eb785ca68..91fd05e8c 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -171,7 +171,9 @@ function rcmail_message_list($attrib) && (($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 @@ function rcmail_message_list($attrib) /** * 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 diff --git a/program/steps/mail/list.inc b/program/steps/mail/list.inc index 69d03b3bf..9f59243d2 100644 --- a/program/steps/mail/list.inc +++ b/program/steps/mail/list.inc @@ -48,7 +48,7 @@ if ($cols = get_input_value('_cols', RCUBE_INPUT_GET)) $save_arr['list_cols'] = explode(',', $cols); } -if ($save_arr) +if ($save_arr) $RCMAIL->user->save_prefs($save_arr); $mbox_name = $IMAP->get_mailbox_name(); @@ -88,7 +88,7 @@ $OUTPUT->command('set_rowcount', rcmail_get_messagecount_text($count)); $OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text()); // add message rows -rcmail_js_message_list($a_headers, FALSE, (bool) $cols); +rcmail_js_message_list($a_headers, FALSE, $cols); if (isset($a_headers) && count($a_headers)) { if ($search_request) diff --git a/program/steps/utils/save_pref.inc b/program/steps/utils/save_pref.inc new file mode 100644 index 000000000..25f12df3b --- /dev/null +++ b/program/steps/utils/save_pref.inc @@ -0,0 +1,45 @@ + | + +-----------------------------------------------------------------------+ + + $Id: html2text.inc 3780 2010-06-23 09:55:08Z alec $ + +*/ + +$name = get_input_value('_name', RCUBE_INPUT_POST); +$value = get_input_value('_value', RCUBE_INPUT_POST); + +// save preference value +$RCMAIL->user->save_prefs(array($name => $value)); + +// update also session if requested +if ($sessname = get_input_value('_session', RCUBE_INPUT_POST)) { + // Support multidimensional arrays... + $vars = explode('/', $sessname); + + // ... up to 3 levels + if (count($vars) == 1) + $_SESSION[$vars[0]] = $value; + else if (count($vars) == 2) + $_SESSION[$vars[0]][$vars[1]] = $value; + else if (count($vars) == 3) + $_SESSION[$vars[0]][$vars[1]][$vars[2]] = $value; +} + +$OUTPUT->reset(); +$OUTPUT->send(); + + -- cgit v1.2.3