From 4df4ab500788f0792b75baf1fa98e4647d713ed1 Mon Sep 17 00:00:00 2001 From: corbosman Date: Thu, 19 Feb 2015 14:55:09 +0100 Subject: session refactor and add redis driver --- config/defaults.inc.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'config/defaults.inc.php') diff --git a/config/defaults.inc.php b/config/defaults.inc.php index 06ea9ec21..fd47c59a1 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -374,9 +374,14 @@ $config['session_auth_name'] = null; // Session path. Defaults to PHP session.cookie_path setting. $config['session_path'] = null; -// Backend to use for session storage. Can either be 'db' (default), 'memcache' or 'php' +// Backend to use for session storage. Can either be 'db' (default), 'redis', 'memcache', or 'php' +// // If set to 'memcache', a list of servers need to be specified in 'memcache_hosts' // Make sure the Memcache extension (http://pecl.php.net/package/memcache) version >= 2.0.0 is installed +// +// If set to 'redis', a server needs to be specified in 'redis_hosts' +// Make sure the Redis extension (http://pecl.php.net/package/redis) version >= 2.0.0 is installed +// // Setting this value to 'php' will use the default session save handler configured in PHP $config['session_storage'] = 'db'; @@ -397,6 +402,13 @@ $config['memcache_timeout'] = 1; // See http://php.net/manual/en/memcache.addserver.php $config['memcache_retry_interval'] = 15; +// use this for accessing redis +// currently only one host is supported. cluster support may come in a future release. +// you can pass 4 fields, host, port, database and password. +// unset fields will be set to the default values host=127.0.0.1, port=6379, database=0, password= (empty) + +$config['redis_hosts'] = null; // e.g. array( 'localhost:6379' ); array( '192.168.1.1:6379:1:secret' ); + // check client IP in session authorization $config['ip_check'] = false; -- cgit v1.2.3 From 8f485469c7955fbf5b420ee0b6f043282965715b Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 24 Feb 2015 12:23:11 +0100 Subject: Add possibility to configure max_allowed_packet value for all database engines (#1490283) --- CHANGELOG | 1 + config/defaults.inc.php | 6 ++++++ program/lib/Roundcube/rcube_db.php | 2 +- program/lib/Roundcube/rcube_db_mysql.php | 6 ++++++ program/lib/Roundcube/rcube_db_pgsql.php | 4 +++- 5 files changed, 17 insertions(+), 2 deletions(-) (limited to 'config/defaults.inc.php') diff --git a/CHANGELOG b/CHANGELOG index ee4a81e7d..064023187 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ CHANGELOG Roundcube Webmail - Plugin API: Add special onload() method to execute plugin actions before startup (session and GUI initialization) - Add possibility to print contact information (of a single contact) +- Add possibility to configure max_allowed_packet value for all database engines (#1490283) - Fix refreshing of drafts list when sending a message which was saved in meantime (#1490238) - Fix saving/sending emoticon images when assets_dir is set - Fix PHP fatal error when visiting Vacation interface and there's no sieve script yet diff --git a/config/defaults.inc.php b/config/defaults.inc.php index 06ea9ec21..edc5b32df 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -51,6 +51,12 @@ $config['db_table_dsn'] = array( // 'cache_messages' => 'r', ); +// It is possible to specify database variable values e.g. some limits here. +// Use them if your server is not MySQL or for better performance. +// For example Roundcube uses max_allowed_packet value (in bytes) +// which limits query size for database cache operations. +$config['db_max_allowed_packet'] = 23423440; + // ---------------------------------- // LOGGING/DEBUGGING diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index ab7058f2f..2cacb3013 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -357,7 +357,7 @@ class rcube_db public function get_variable($varname, $default = null) { // to be implemented by driver class - return $default; + return rcube::get_instance()->config->get('db_' . $varname, $default); } /** diff --git a/program/lib/Roundcube/rcube_db_mysql.php b/program/lib/Roundcube/rcube_db_mysql.php index 067e94be6..dd28c25c8 100644 --- a/program/lib/Roundcube/rcube_db_mysql.php +++ b/program/lib/Roundcube/rcube_db_mysql.php @@ -167,6 +167,12 @@ class rcube_db_mysql extends rcube_db return $this->variables[$varname]; } + // configured value has higher prio + $conf_value = rcube::get_instance()->config->get('db_' . $varname); + if ($conf_value !== null) { + return $this->variables[$varname] = $conf_value; + } + $result = $this->query('SHOW VARIABLES LIKE ?', $varname); while ($row = $this->fetch_array($result)) { diff --git a/program/lib/Roundcube/rcube_db_pgsql.php b/program/lib/Roundcube/rcube_db_pgsql.php index d33cdd859..ff41df224 100644 --- a/program/lib/Roundcube/rcube_db_pgsql.php +++ b/program/lib/Roundcube/rcube_db_pgsql.php @@ -139,9 +139,11 @@ class rcube_db_pgsql extends rcube_db // There's a known case when max_allowed_packet is queried // PostgreSQL doesn't have such limit, return immediately if ($varname == 'max_allowed_packet') { - return $default; + return rcube::get_instance()->config->get('db_' . $varname, $default); } + $this->variables[$varname] = rcube::get_instance()->config->get('db_' . $varname); + if (!isset($this->variables)) { $this->variables = array(); -- cgit v1.2.3 From 2a31f6dbd7c63232918d175fb2879682217946ea Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 25 Feb 2015 21:08:16 +0100 Subject: Reset default db_max_allowed_packet, fix max packet size detection --- config/defaults.inc.php | 2 +- program/lib/Roundcube/rcube_cache.php | 6 ++++-- program/lib/Roundcube/rcube_cache_shared.php | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'config/defaults.inc.php') diff --git a/config/defaults.inc.php b/config/defaults.inc.php index edc5b32df..50c392db3 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -55,7 +55,7 @@ $config['db_table_dsn'] = array( // Use them if your server is not MySQL or for better performance. // For example Roundcube uses max_allowed_packet value (in bytes) // which limits query size for database cache operations. -$config['db_max_allowed_packet'] = 23423440; +$config['db_max_allowed_packet'] = null; // ---------------------------------- diff --git a/program/lib/Roundcube/rcube_cache.php b/program/lib/Roundcube/rcube_cache.php index 52a2db997..303abdac4 100644 --- a/program/lib/Roundcube/rcube_cache.php +++ b/program/lib/Roundcube/rcube_cache.php @@ -605,8 +605,10 @@ class rcube_cache $this->max_packet = 2097152; // default/max is 2 MB if ($this->type == 'db') { - $value = $this->db->get_variable('max_allowed_packet', $this->max_packet); - $this->max_packet = max($value, $this->max_packet) - 2000; + if ($value = $this->db->get_variable('max_allowed_packet', $this->max_packet)) { + $this->max_packet = $value; + } + $this->max_packet -= 2000; } else if ($this->type == 'memcache') { $stats = $this->db->getStats(); diff --git a/program/lib/Roundcube/rcube_cache_shared.php b/program/lib/Roundcube/rcube_cache_shared.php index 339a9aa20..3f0f20e41 100644 --- a/program/lib/Roundcube/rcube_cache_shared.php +++ b/program/lib/Roundcube/rcube_cache_shared.php @@ -595,8 +595,10 @@ class rcube_cache_shared $this->max_packet = 2097152; // default/max is 2 MB if ($this->type == 'db') { - $value = $this->db->get_variable('max_allowed_packet', 1048500); - $this->max_packet = min($value, $this->max_packet) - 2000; + if ($value = $this->db->get_variable('max_allowed_packet', $this->max_packet)) { + $this->max_packet = $value; + } + $this->max_packet -= 2000; } else if ($this->type == 'memcache') { $stats = $this->db->getStats(); -- cgit v1.2.3 From 09225a41ec7135031a4c0304b8dcdccd45904939 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 16 Apr 2015 10:55:32 +0200 Subject: Add option to place signature at bottom of the quoted text even in top-posting mode [sig_below] --- CHANGELOG | 1 + config/defaults.inc.php | 5 ++++ program/js/app.js | 6 +++-- program/js/editor.js | 51 +++++++++++++++++------------------ program/localization/en_US/labels.inc | 1 + program/steps/mail/compose.inc | 7 +++-- program/steps/settings/func.inc | 14 ++++++++++ program/steps/settings/save_prefs.inc | 1 + 8 files changed, 56 insertions(+), 30 deletions(-) (limited to 'config/defaults.inc.php') diff --git a/CHANGELOG b/CHANGELOG index 6c584fce1..c3049eb73 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ CHANGELOG Roundcube Webmail - Plugin API: Added message_part_body hook - Plugin API: Added message_ready hook - Plugin API: Add special onload() method to execute plugin actions before startup (session and GUI initialization) +- Add option to place signature at bottom of the quoted text even in top-posting mode [sig_below] - Fix handling of %-encoded entities in mailto: URLs (#1490346) - Fix zipped messages downloads after selecting all messages in a folder (#1490339) - Fix vpopmaild driver of password plugin diff --git a/config/defaults.inc.php b/config/defaults.inc.php index 50ae71ed9..df8b612ea 100644 --- a/config/defaults.inc.php +++ b/config/defaults.inc.php @@ -1086,6 +1086,11 @@ $config['strip_existing_sig'] = true; // 3 - Forwards and Replies only $config['show_sig'] = 1; +// By default the signature is placed depending on cursor position (reply_mode). +// Sometimes it might be convenient to start the reply on top but keep +// the signature below the quoted text (sig_below = true). +$config['sig_below'] = false; + // Use MIME encoding (quoted-printable) for 8bit characters in message body $config['force_7bit'] = false; diff --git a/program/js/app.js b/program/js/app.js index 64fd548c9..b6b4d319c 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -3384,14 +3384,16 @@ function rcube_webmail() if (!html_mode) { pos = this.env.top_posting ? 0 : input_message.value.length; - this.set_caret_pos(input_message, pos); // add signature according to selected identity - // if we have HTML editor, signature is added in callback + // if we have HTML editor, signature is added in a callback if (input_from.prop('type') == 'select-one') { this.change_identity(input_from[0]); } + // set initial cursor position + this.set_caret_pos(input_message, pos); + // scroll to the bottom of the textarea (#1490114) if (pos) { $(input_message).scrollTop(input_message.scrollHeight); diff --git a/program/js/editor.js b/program/js/editor.js index 296a161ca..abd800ca3 100644 --- a/program/js/editor.js +++ b/program/js/editor.js @@ -485,32 +485,37 @@ function rcube_text_editor(config, id) sig = rcmail.env.signatures[id].text; sig = sig.replace(/\r\n/g, '\n'); - if (rcmail.env.top_posting) { - if (p >= 0) { // in place of removed signature - message = message.substring(0, p) + sig + message.substring(p, message.length); - cursor_pos = p - 1; - } - else if (!message) { // empty message - cursor_pos = 0; - message = '\n\n' + sig; - } - else if (pos = rcmail.get_caret_pos(input_message.get(0))) { // at cursor position + // in place of removed signature + if (p >= 0) { + message = message.substring(0, p) + sig + message.substring(p, message.length); + cursor_pos = p - 1; + } + // empty message + else if (!message) { + message = '\n\n' + sig; + cursor_pos = 0; + } + else if (rcmail.env.top_posting && !rcmail.env.sig_below) { + // at cursor position + if (pos = rcmail.get_caret_pos(input_message.get(0))) { message = message.substring(0, pos) + '\n' + sig + '\n\n' + message.substring(pos, message.length); cursor_pos = pos; } - else { // on top - cursor_pos = 0; + // on top + else { message = '\n\n' + sig + '\n\n' + message.replace(/^[\r\n]+/, ''); + cursor_pos = 0; } } else { message = message.replace(/[\r\n]+$/, ''); - cursor_pos = !rcmail.env.top_posting && message.length ? message.length+1 : 0; + cursor_pos = !rcmail.env.top_posting && message.length ? message.length + 1 : 0; message += '\n\n' + sig; } } - else + else { cursor_pos = rcmail.env.top_posting ? 0 : message.length; + } input_message.val(message); @@ -528,24 +533,18 @@ function rcube_text_editor(config, id) sigElem = doc.createElement('div'); sigElem.setAttribute('id', '_rc_sig'); - if (rcmail.env.top_posting) { - // if no existing sig and top posting then insert at caret pos + if (rcmail.env.top_posting && !rcmail.env.sig_below) { this.editor.getWin().focus(); // correct focus in IE & Chrome var node = this.editor.selection.getNode(); - if (node.nodeName == 'BODY') { - // no real focus, insert at start - body.insertBefore(sigElem, body.firstChild); - body.insertBefore(doc.createElement('br'), body.firstChild); - } - else { - body.insertBefore(sigElem, node.nextSibling); - body.insertBefore(doc.createElement('br'), node.nextSibling); - } + + // insert at start or at cursor position if found + body.insertBefore(sigElem, node.nodeName == 'BODY' ? body.firstChild : node.nextSibling); + body.insertBefore(doc.createElement('p'), sigElem); } else { body.appendChild(sigElem); - position_element = $(sigElem).prev(); + position_element = rcmail.env.top_posting ? body.firstChild : $(sigElem).prev(); } } diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc index fac52ba1e..8202b140d 100644 --- a/program/localization/en_US/labels.inc +++ b/program/localization/en_US/labels.inc @@ -509,6 +509,7 @@ $labels['autoaddsignature'] = 'Automatically add signature'; $labels['newmessageonly'] = 'new message only'; $labels['replyandforwardonly'] = 'replies and forwards only'; $labels['insertsignature'] = 'Insert signature'; +$labels['sigbelow'] = 'Place signature below the quoted message'; $labels['previewpanemarkread'] = 'Mark previewed messages as read'; $labels['afternseconds'] = 'after $n seconds'; $labels['reqmdn'] = 'Always request a return receipt'; diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index ba6f334c9..5009c525a 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -91,6 +91,7 @@ $OUTPUT->set_env('compose_id', $COMPOSE['id']); $OUTPUT->set_env('session_id', session_id()); $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder()); $OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0); +$OUTPUT->set_env('sig_below', $RCMAIL->config->get('sig_below')); $OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ','))); $OUTPUT->set_env('save_localstorage', (bool)$RCMAIL->config->get('compose_save_localstorage')); $OUTPUT->set_env('is_sent', false); @@ -612,8 +613,10 @@ function rcmail_compose_header_from($attrib) if (count($MESSAGE->identities)) { $a_signatures = array(); $identities = array(); - $separator = intval($RCMAIL->config->get('reply_mode')) > 0 - && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD) ? '---' : '-- '; + $top_posting = intval($RCMAIL->config->get('reply_mode')) > 0 + && !$RCMAIL->config->get('sig_below') + && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD); + $separator = $top_posting ? '---' : '-- '; $field_attrib['onchange'] = rcmail_output::JS_OBJECT_NAME.".change_identity(this)"; $select_from = new html_select($field_attrib); diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index 46aed3019..c763dd39a 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -845,6 +845,20 @@ function rcmail_user_prefs($current = null) ); } + if (!isset($no_override['sig_below'])) { + if (!$current) { + continue 2; + } + + $field_id = 'rcmfd_sig_below'; + $input = new html_checkbox(array('name' => '_sig_below', 'id' => $field_id, 'value' => 1)); + + $blocks['sig']['options']['sig_below'] = array( + 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('sigbelow'))), + 'content' => $input->show($RCMAIL->config->get('sig_below') ? 1 : 0), + ); + } + if (!isset($no_override['strip_existing_sig'])) { if (!$current) { continue 2; diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index f0ce9c9a3..4ecaa70e6 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -85,6 +85,7 @@ case 'compose': 'spellcheck_ignore_caps' => isset($_POST['_spellcheck_ignore_caps']) ? true : false, 'show_sig' => isset($_POST['_show_sig']) ? intval($_POST['_show_sig']) : 1, 'reply_mode' => isset($_POST['_reply_mode']) ? intval($_POST['_reply_mode']) : 0, + 'sig_below' => isset($_POST['_sig_below']) ? true : false, 'strip_existing_sig' => isset($_POST['_strip_existing_sig']), 'default_font' => rcube_utils::get_input_value('_default_font', rcube_utils::INPUT_POST), 'default_font_size' => rcube_utils::get_input_value('_default_font_size', rcube_utils::INPUT_POST), -- cgit v1.2.3