Permalink
Browse files

- 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'
  • Loading branch information...
1 parent b8d96f6 commit 614c642a4ba8b050ecb26d25d349077f6192aa8d @alecpl alecpl committed Sep 17, 2010
Showing with 94 additions and 23 deletions.
  1. +1 −0 CHANGELOG
  2. +0 −6 index.php
  3. +21 −5 program/js/app.js
  4. +25 −10 program/steps/mail/func.inc
  5. +2 −2 program/steps/mail/list.inc
  6. +45 −0 program/steps/utils/save_pref.inc
View
@@ -23,6 +23,7 @@ CHANGELOG RoundCube Webmail
- Fix messages background image handling in some cases (#1486990)
- Fix format=flowed handling (#1486989)
- Fix when IMAP connection fails in 'get' action session shouldn't be destroyed (#1486995)
+- Fix list_cols is not updated after column dragging (#1486999)
RELEASE 0.4
-----------
View
@@ -187,12 +187,6 @@
$OUTPUT->reset();
$OUTPUT->send();
}
-// save preference value
-else if ($RCMAIL->action == 'save-pref') {
- $RCMAIL->user->save_prefs(array(get_input_value('_name', RCUBE_INPUT_POST) => get_input_value('_value', RCUBE_INPUT_POST)));
- $OUTPUT->reset();
- $OUTPUT->send();
-}
// map task/action to a certain include file
View
@@ -1288,7 +1288,7 @@ function rcube_webmail()
}
}
- this.http_post('save-pref', '_name=collapsed_folders&_value='+urlencode(this.env.collapsed_folders));
+ this.http_post('utils/save-pref', '_name=collapsed_folders&_value='+urlencode(this.env.collapsed_folders));
this.set_unread_count_display(id, false);
};
@@ -1459,7 +1459,7 @@ function rcube_webmail()
if ((found = $.inArray('subject', this.env.coltypes)) >= 0)
this.set_env('subject_col', found);
- this.http_post('save-pref', { '_name':'list_cols', '_value':this.env.coltypes });
+ this.http_post('utils/save-pref', { '_name':'list_cols', '_value':this.env.coltypes, '_session':'list_attrib/columns' });
};
this.check_droptarget = function(id)
@@ -4894,8 +4894,17 @@ function rcube_webmail()
// send a http request to the server
this.http_request = function(action, querystring, lock)
{
+ var url = this.env.comm_path;
+
+ // overwrite task name
+ if (action.match(/([a-z]+)\/([a-z-_]+)/)) {
+ action = RegExp.$2;
+ url = url.replace(/\_task=[a-z]+/, '_task='+RegExp.$1);
+ }
+
// trigger plugin hook
var result = this.triggerEvent('request'+action, querystring);
+
if (typeof result != 'undefined') {
// abort if one the handlers returned false
if (result === false)
@@ -4904,8 +4913,7 @@ function rcube_webmail()
querystring = result;
}
- querystring += (querystring ? '&' : '') + '_remote=1';
- var url = this.env.comm_path + '&_action=' + action + '&' + querystring;
+ url += '&_remote=1&_action=' + action + (querystring ? '&' : '') + querystring;
// send request
console.log('HTTP GET: ' + url);
@@ -4915,7 +4923,15 @@ function rcube_webmail()
// send a http POST request to the server
this.http_post = function(action, postdata, lock)
{
- var url = this.env.comm_path+'&_action=' + action;
+ var url = this.env.comm_path;
+
+ // overwrite task name
+ if (action.match(/([a-z]+)\/([a-z-_]+)/)) {
+ action = RegExp.$2;
+ url = url.replace(/\_task=[a-z]+/, '_task='+RegExp.$1);
+ }
+
+ url += '&_action=' + action;
if (postdata && typeof(postdata) == 'object') {
postdata._remote = 1;
@@ -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
@@ -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)
@@ -0,0 +1,45 @@
+<?php
+/*
+
+ +-----------------------------------------------------------------------+
+ | program/steps/utils/save_pref.inc |
+ | |
+ | This file is part of the RoundCube Webmail client |
+ | Copyright (C) 2005-2010, RoundCube Dev. - Switzerland |
+ | Licensed under the GNU GPL |
+ | |
+ | PURPOSE: |
+ | Save preferences setting in database |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Aleksander Machniak <alec@alec.pl> |
+ +-----------------------------------------------------------------------+
+
+ $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();
+
+

0 comments on commit 614c642

Please sign in to comment.