- 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'
release-0.6
alecpl 14 years ago
parent b8d96f6e60
commit 614c642a4b

@ -23,6 +23,7 @@ CHANGELOG RoundCube Webmail
- Fix messages background image handling in some cases (#1486990) - Fix messages background image handling in some cases (#1486990)
- Fix format=flowed handling (#1486989) - Fix format=flowed handling (#1486989)
- Fix when IMAP connection fails in 'get' action session shouldn't be destroyed (#1486995) - 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 RELEASE 0.4
----------- -----------

@ -187,12 +187,6 @@ if ($RCMAIL->action == 'keep-alive') {
$OUTPUT->reset(); $OUTPUT->reset();
$OUTPUT->send(); $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 // map task/action to a certain include file

@ -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); this.set_unread_count_display(id, false);
}; };
@ -1459,7 +1459,7 @@ function rcube_webmail()
if ((found = $.inArray('subject', this.env.coltypes)) >= 0) if ((found = $.inArray('subject', this.env.coltypes)) >= 0)
this.set_env('subject_col', found); 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) this.check_droptarget = function(id)
@ -4894,8 +4894,17 @@ function rcube_webmail()
// send a http request to the server // send a http request to the server
this.http_request = function(action, querystring, lock) 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 // trigger plugin hook
var result = this.triggerEvent('request'+action, querystring); var result = this.triggerEvent('request'+action, querystring);
if (typeof result != 'undefined') { if (typeof result != 'undefined') {
// abort if one the handlers returned false // abort if one the handlers returned false
if (result === false) if (result === false)
@ -4904,8 +4913,7 @@ function rcube_webmail()
querystring = result; querystring = result;
} }
querystring += (querystring ? '&' : '') + '_remote=1'; url += '&_remote=1&_action=' + action + (querystring ? '&' : '') + querystring;
var url = this.env.comm_path + '&_action=' + action + '&' + querystring;
// send request // send request
console.log('HTTP GET: ' + url); console.log('HTTP GET: ' + url);
@ -4915,7 +4923,15 @@ function rcube_webmail()
// send a http POST request to the server // send a http POST request to the server
this.http_post = function(action, postdata, lock) 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') { if (postdata && typeof(postdata) == 'object') {
postdata._remote = 1; 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) && (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false)
$a_show_cols[$f] = 'to'; $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)) if (!in_array('threads', $a_show_cols))
array_unshift($a_show_cols, 'threads'); 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 * 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; global $CONFIG, $IMAP, $RCMAIL, $OUTPUT;
if (!empty($_SESSION['list_attrib']['columns'])) if (empty($a_show_cols)) {
$a_show_cols = $_SESSION['list_attrib']['columns']; if (!empty($_SESSION['list_attrib']['columns']))
else $a_show_cols = $_SESSION['list_attrib']['columns'];
$a_show_cols = is_array($CONFIG['list_cols']) ? $CONFIG['list_cols'] : array('subject'); 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(); $mbox = $IMAP->get_mailbox_name();
$delim = $IMAP->get_hierarchy_delimiter(); $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 // 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) 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) && (($f = array_search('from', $a_show_cols)) !== false) && array_search('to', $a_show_cols) === false)
$a_show_cols[$f] = 'to'; $a_show_cols[$f] = 'to';
// make sure 'threads' column is present // Make sure there are no duplicated columns (#1486999)
if (!in_array('threads', $a_show_cols)) $a_show_cols = array_unique($a_show_cols);
array_unshift($a_show_cols, 'threads');
// Plugins may set header's list_cols/list_flags and other rcube_mail_header variables // Plugins may set header's list_cols/list_flags and other rcube_mail_header variables
// and list columns // and list columns

@ -48,7 +48,7 @@ if ($cols = get_input_value('_cols', RCUBE_INPUT_GET))
$save_arr['list_cols'] = explode(',', $cols); $save_arr['list_cols'] = explode(',', $cols);
} }
if ($save_arr) if ($save_arr)
$RCMAIL->user->save_prefs($save_arr); $RCMAIL->user->save_prefs($save_arr);
$mbox_name = $IMAP->get_mailbox_name(); $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()); $OUTPUT->command('set_mailboxname', rcmail_get_mailbox_name_text());
// add message rows // 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 (isset($a_headers) && count($a_headers))
{ {
if ($search_request) 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();
Loading…
Cancel
Save