summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authorAnika Henke <anika@selfthinker.org>2013-01-26 16:53:23 +0000
committerAnika Henke <anika@selfthinker.org>2013-01-26 16:53:23 +0000
commit3c94d07beba64154ecd707805fa87f2eaf5e4d02 (patch)
tree9be7178deadbba10404f3757f776e9eedcf9fe5b /inc/common.php
parentb5460ee2c820d95f75fd47d2f8bcbe5dddc21e7e (diff)
downloadrpg-3c94d07beba64154ecd707805fa87f2eaf5e4d02.tar.gz
rpg-3c94d07beba64154ecd707805fa87f2eaf5e4d02.tar.bz2
store choices for recent changes and diff views in cookie (FS#2438 and
FS#2700) Note: These changes don't work yet. The cookie is not set and deletes the old one.
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/inc/common.php b/inc/common.php
index bc49e76b2..c74010223 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1560,4 +1560,30 @@ function get_doku_pref($pref, $default) {
return $default;
}
+/**
+ * Add a preference to the DokuWiki cookie
+ */
+function set_doku_pref($pref, $val) {
+ global $conf;
+ $orig = get_doku_pref($pref, false);
+ $cookieVal = '';
+
+ if($orig && ($orig != $val)) {
+ $parts = explode('#', $_COOKIE['DOKU_PREFS']);
+ $cnt = count($parts);
+ for($i = 0; $i < $cnt; $i += 2) {
+ if($parts[$i] == $pref) {
+ $parts[$i + 1] = urlencode($val);
+ }
+ }
+ $cookieVal = implode('#', $parts);
+ } else if (!$orig) {
+ $cookieVal = $_COOKIE['DOKU_PREFS'].'#'.urlencode($pref).'#'.urlencode($val);
+ }
+
+ if (!empty($cookieVal)) {
+ setcookie('DOKU_PREFS', $cookieVal, mktime('+1 year'), DOKU_BASE, '', ($conf['securecookie'] && is_ssl()));
+ }
+}
+
//Setup VIM: ex: et ts=2 :