alecpl
2010-09-17 614c642a4ba8b050ecb26d25d349077f6192aa8d
- 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'


1 files added
5 files modified
117 ■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
index.php 6 ●●●●● patch | view | raw | blame | history
program/js/app.js 26 ●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 35 ●●●● patch | view | raw | blame | history
program/steps/mail/list.inc 4 ●●●● patch | view | raw | blame | history
program/steps/utils/save_pref.inc 45 ●●●●● patch | view | raw | blame | history
CHANGELOG
@@ -23,6 +23,7 @@
- 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
-----------
index.php
@@ -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
program/js/app.js
@@ -1288,7 +1288,7 @@
      }
    }
    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 @@
    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 @@
  // 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 @@
        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 @@
  // 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;
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
program/steps/mail/list.inc
@@ -48,7 +48,7 @@
  $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_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)
program/steps/utils/save_pref.inc
New file
@@ -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();