Thomas Bruederli
2014-08-20 44b47dfb359f8a7412208079202fca0adf741540
Add config/preference option to disable saving messages in localStorage (#1489979)
6 files modified
30 ■■■■■ changed files
config/defaults.inc.php 4 ●●●● patch | view | raw | blame | history
program/js/app.js 9 ●●●● patch | view | raw | blame | history
program/localization/en_US/labels.inc 1 ●●●● patch | view | raw | blame | history
program/steps/mail/compose.inc 1 ●●●● patch | view | raw | blame | history
program/steps/settings/func.inc 14 ●●●●● patch | view | raw | blame | history
program/steps/settings/save_prefs.inc 1 ●●●● patch | view | raw | blame | history
config/defaults.inc.php
@@ -947,6 +947,10 @@
// 0 - never, 1 - always, 2 - on reply to HTML message, 3 - on forward or reply to HTML message
$config['htmleditor'] = 0;
// save copies of compose messages in the browser's local storage
// for recovery in case of browser crashes and session timeout.
$config['compose_save_localstorage'] = true;
// show pretty dates as standard
$config['prettydate'] = true;
program/js/app.js
@@ -3361,7 +3361,8 @@
    }
    // check for locally stored compose data
    this.compose_restore_dialog(0, html_mode)
    if (this.env.save_localstorage)
      this.compose_restore_dialog(0, html_mode)
    if (input_to.val() == '')
      input_to.focus();
@@ -3793,7 +3794,7 @@
    }
    // save compose form content to local storage every 5 seconds
    if (!this.local_save_timer && window.localStorage) {
    if (!this.local_save_timer && window.localStorage && this.env.save_localstorage) {
      // track typing activity and only save on changes
      this.compose_type_activity = this.compose_type_activity_last = 0;
      $(document).bind('keypress', function(e){ ref.compose_type_activity++; });
@@ -3849,6 +3850,10 @@
  // store the contents of the compose form to localstorage
  this.save_compose_form_local = function()
  {
    // feature is disabled
    if (!this.env.save_localstorage)
      return;
    var formdata = { session:this.env.session_id, changed:new Date().getTime() },
      ed, empty = true;
program/localization/en_US/labels.inc
@@ -484,6 +484,7 @@
$labels['miscfolding'] = 'RFC 2047/2231 (MS Outlook)';
$labels['2047folding'] = 'Full RFC 2047 (other)';
$labels['force7bit'] = 'Use MIME encoding for 8-bit characters';
$labels['savelocalstorage'] = "Save in the browser's local storage (temporarily)";
$labels['advancedoptions'] = 'Advanced options';
$labels['toggleadvancedoptions'] = 'Toggle advanced options';
$labels['focusonnewmessage'] = 'Focus browser window on new message';
program/steps/mail/compose.inc
@@ -91,6 +91,7 @@
$OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
$OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0);
$OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
$OUTPUT->set_env('save_localstorage', (bool)$RCMAIL->config->get('compose_save_localstorage'));
$drafts_mbox     = $RCMAIL->config->get('drafts_mbox');
$config_show_sig = $RCMAIL->config->get('show_sig', 1);
program/steps/settings/func.inc
@@ -918,6 +918,20 @@
                );
            }
            if (!isset($no_override['compose_save_localstorage'])) {
                if (!$current) {
                    continue 2;
                }
                $field_id = 'rcmfd_compose_save_localstorage';
                $input    = new html_checkbox(array('name' => '_compose_save_localstorage', 'id' => $field_id, 'value' => 1));
                $blocks['advanced']['options']['compose_save_localstorage'] = array(
                    'title'    => html::label($field_id, rcube::Q($RCMAIL->gettext('savelocalstorage'))),
                    'content'  => $input->show($config['compose_save_localstorage']?1:0),
                );
            }
        break;
        // Addressbook config
program/steps/settings/save_prefs.inc
@@ -90,6 +90,7 @@
        'default_font_size'  => rcube_utils::get_input_value('_default_font_size', rcube_utils::INPUT_POST),
        'reply_all_mode'     => intval($_POST['_reply_all_mode']),
        'forward_attachment' => !empty($_POST['_forward_attachment']),
        'compose_save_localstorage' => intval($_POST['_compose_save_localstorage']),
    );
    break;