summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-08-20 09:32:25 +0200
committerAleksander Machniak <alec@alec.pl>2012-08-20 09:32:25 +0200
commitae7027de029e28fdd3894efe919b6171b2b11eab (patch)
treed2a83feb13621c5122d671dc9827ae3e2b38b0b3
parentc8f35a17e645ec7328557846b976e38432c9a062 (diff)
Added session_path config option and unified cookies settings in javascript
-rw-r--r--CHANGELOG1
-rw-r--r--config/main.inc.php.dist7
-rw-r--r--program/include/rcube.php5
-rw-r--r--program/include/rcube_output_html.php5
-rw-r--r--program/js/app.js8
-rw-r--r--program/js/common.js1
-rw-r--r--program/js/googiespell.js4
-rw-r--r--skins/classic/splitter.js4
-rw-r--r--skins/larry/ui.js6
9 files changed, 32 insertions, 9 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 6ea101e8f..4d18f64b7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Added session_path config option and unified cookies settings in javascript
- Added "Undeleted" option to messages list filter
- Rewritten test scripts for PHPUnit
- Add new DB abstraction layer based on PHP PDO, supporting SQLite3 (#1488332)
diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index 1e9c1fdcd..8d615f3b0 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -241,12 +241,15 @@ $rcmail_config['display_version'] = false;
// must be greater than 'keep_alive'/60
$rcmail_config['session_lifetime'] = 10;
-// session domain: .example.org
+// Session domain: .example.org
$rcmail_config['session_domain'] = '';
-// session name. Default: 'roundcube_sessid'
+// Session name. Default: 'roundcube_sessid'
$rcmail_config['session_name'] = null;
+// Session path. Defaults to PHP session.cookie_path setting.
+$rcmail_config['session_path'] = null;
+
// Backend to use for session storage. Can either be 'db' (default) or 'memcache'
// 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
diff --git a/program/include/rcube.php b/program/include/rcube.php
index 84014ef5c..0e40b3c6b 100644
--- a/program/include/rcube.php
+++ b/program/include/rcube.php
@@ -405,12 +405,17 @@ class rcube
$sess_name = $this->config->get('session_name');
$sess_domain = $this->config->get('session_domain');
+ $sess_path = $this->config->get('session_path');
$lifetime = $this->config->get('session_lifetime', 0) * 60;
// set session domain
if ($sess_domain) {
ini_set('session.cookie_domain', $sess_domain);
}
+ // set session path
+ if ($sess_path) {
+ ini_set('session.cookie_path', $sess_path);
+ }
// set session garbage collecting time according to session_lifetime
if ($lifetime) {
ini_set('session.gc_maxlifetime', $lifetime * 2);
diff --git a/program/include/rcube_output_html.php b/program/include/rcube_output_html.php
index 0a8f0e364..a071ee354 100644
--- a/program/include/rcube_output_html.php
+++ b/program/include/rcube_output_html.php
@@ -67,6 +67,11 @@ class rcube_output_html extends rcube_output
$this->set_env('task', $task);
$this->set_env('x_frame_options', $this->config->get('x_frame_options', 'sameorigin'));
+ // add cookie info
+ $this->set_env('cookie_domain', ini_get('session.cookie_domain'));
+ $this->set_env('cookie_path', ini_get('session.cookie_path'));
+ $this->set_env('cookie_secure', ini_get('session.cookie_secure'));
+
// load the correct skin (in case user-defined)
$skin = $this->config->get('skin');
$this->set_skin($skin);
diff --git a/program/js/app.js b/program/js/app.js
index e8bb6c1a7..9ca16b39c 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -6585,6 +6585,12 @@ function rcube_webmail()
return 0;
};
+ // Cookie setter
+ this.set_cookie = function(name, value, expires)
+ {
+ setCookie(name, value, expires, this.env.cookie_path, this.env.cookie_domain, this.env.cookie_secure);
+ }
+
} // end object rcube_webmail
@@ -6615,6 +6621,8 @@ rcube_webmail.long_subject_title_ie = function(elem, indent)
}
};
+rcube_webmail.prototype.get_cookie = getCookie;
+
// copy event engine prototype
rcube_webmail.prototype.addEventListener = rcube_event_engine.prototype.addEventListener;
rcube_webmail.prototype.removeEventListener = rcube_event_engine.prototype.removeEventListener;
diff --git a/program/js/common.js b/program/js/common.js
index fdef3453e..a08387ecb 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -635,6 +635,7 @@ function getCookie(name)
return unescape(dc.substring(begin + prefix.length, end));
};
+// deprecated aliases, to be removed, use rcmail.set_cookie/rcmail.get_cookie
roundcube_browser.prototype.set_cookie = setCookie;
roundcube_browser.prototype.get_cookie = getCookie;
diff --git a/program/js/googiespell.js b/program/js/googiespell.js
index 9f1b41bb2..478858bac 100644
--- a/program/js/googiespell.js
+++ b/program/js/googiespell.js
@@ -25,7 +25,7 @@ var GOOGIE_CUR_LANG,
function GoogieSpell(img_dir, server_url, has_dict)
{
var ref = this,
- cookie_value = getCookie('language');
+ cookie_value = rcmail.get_cookie('language');
GOOGIE_CUR_LANG = cookie_value != null ? cookie_value : GOOGIE_DEFAULT_LANG;
@@ -150,7 +150,7 @@ this.setCurrentLanguage = function(lan_code)
//Set cookie
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
- setCookie('language', lan_code, now);
+ rcmail.set_cookie('language', lan_code, now);
};
this.setForceWidthHeight = function(width, height)
diff --git a/skins/classic/splitter.js b/skins/classic/splitter.js
index 59ebb5151..3f1c97302 100644
--- a/skins/classic/splitter.js
+++ b/skins/classic/splitter.js
@@ -47,7 +47,7 @@ function rcube_splitter(attrib)
rcube_event.add_listener({element: window, event:'resize', object:this, method:'onResize'});
// read saved position from cookie
- var cookie = bw.get_cookie(this.id);
+ var cookie = rcmail.get_cookie(this.id);
if (cookie && !isNaN(cookie)) {
this.pos = parseFloat(cookie);
this.resize();
@@ -197,7 +197,7 @@ function rcube_splitter(attrib)
{
var exp = new Date();
exp.setYear(exp.getFullYear() + 1);
- bw.set_cookie(this.id, this.pos, exp);
+ rcmail.set_cookie(this.id, this.pos, exp);
};
} // end class rcube_splitter
diff --git a/skins/larry/ui.js b/skins/larry/ui.js
index b6056b6ee..ca1680759 100644
--- a/skins/larry/ui.js
+++ b/skins/larry/ui.js
@@ -461,7 +461,7 @@ function rcube_mail_ui()
var button = $(e.target),
frame = $('#mailpreviewframe'),
visible = !frame.is(':visible'),
- splitter = mailviewsplit.pos || parseInt(bw.get_cookie('mailviewsplitter') || 320),
+ splitter = mailviewsplit.pos || parseInt(rcmail.get_cookie('mailviewsplitter') || 320),
topstyles, bottomstyles, uid;
frame.toggle();
@@ -974,7 +974,7 @@ function rcube_splitter(p)
$(window).resize(onResize);
// read saved position from cookie
- var cookie = bw.get_cookie(this.id);
+ var cookie = rcmail.get_cookie(this.id);
if (cookie && !isNaN(cookie)) {
this.pos = parseFloat(cookie);
this.resize();
@@ -1135,7 +1135,7 @@ function rcube_splitter(p)
{
var exp = new Date();
exp.setYear(exp.getFullYear() + 1);
- bw.set_cookie(this.id, this.pos, exp);
+ rcmail.set_cookie(this.id, this.pos, exp);
};
} // end class rcube_splitter