Added new test before redirection
This commit is contained in:
parent
e2abf31c39
commit
b4c049327c
22
action.php
22
action.php
|
@ -80,6 +80,7 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
|
||||||
function redirect(&$event, $param) {
|
function redirect(&$event, $param) {
|
||||||
global $conf;
|
global $conf;
|
||||||
global $lang;
|
global $lang;
|
||||||
|
global $ID;
|
||||||
|
|
||||||
if ($this->multiNsOk()) {
|
if ($this->multiNsOk()) {
|
||||||
$created = array();
|
$created = array();
|
||||||
|
@ -148,15 +149,18 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
|
||||||
array_push($wikistart, $language.':'.$conf['start'], ':'.$language.':'.$conf['start']);
|
array_push($wikistart, $language.':'.$conf['start'], ':'.$language.':'.$conf['start']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If Public page was just created, redirect to it and edit (or show)
|
// If user isn't on public or private page yet, check for redirection conditions
|
||||||
if (($created['public']) && (page_exists($this->public_page))) {
|
if (($ID != $this->public_page) && ($ID != $this->private_page)) {
|
||||||
send_redirect(wl($this->public_page, array('do='.$this->getConf('action')), true));
|
// If Public page was just created, redirect to it and edit (or show)
|
||||||
// Else if private start page was just created and edit option is set, redirect to it and edit
|
if (($created['public']) && (page_exists($this->public_page))) {
|
||||||
} elseif (($created['private']) && (page_exists($this->private_page)) && ($this->getConf('edit_before_create'))) {
|
send_redirect(wl($this->public_page, array('do='.$this->getConf('action')), true));
|
||||||
send_redirect(wl($this->private_page, array('do='.$this->getConf('action')), true));
|
// Else if private start page was just created and edit option is set, redirect to it and edit
|
||||||
// Else if redirection is enabled and user's private page exists AND [(user isn't requesting a specific page OR he's requesting wiki start page) AND logged in 2sec ago max]
|
} elseif (($created['private']) && (page_exists($this->private_page)) && ($this->getConf('edit_before_create'))) {
|
||||||
} elseif (($this->getConf('redirection')) && (page_exists($this->private_page)) && (((!isset($_GET['id'])) or (in_array($_GET['id'], $wikistart))) && (time()-$_SESSION["uhptimestamp"] <= 2))) {
|
send_redirect(wl($this->private_page, array('do='.$this->getConf('action')), true));
|
||||||
send_redirect(wl($this->private_page, '', true));
|
// Else if redirection is enabled and user's private page exists AND [(user isn't requesting a specific page OR he's requesting wiki start page) AND logged in 2sec ago max]
|
||||||
|
} elseif (($this->getConf('redirection')) && (page_exists($this->private_page)) && (((!isset($_GET['id'])) or (in_array($_GET['id'], $wikistart))) && (time()-$_SESSION["uhptimestamp"] <= 2))) {
|
||||||
|
send_redirect(wl($this->private_page, '', true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
base userhomepage
|
base userhomepage
|
||||||
author Simon Delage
|
author Simon Delage
|
||||||
email simon.geekitude@gmail.com
|
email simon.geekitude@gmail.com
|
||||||
date 2016-02-05
|
date 2016-02-09
|
||||||
name User Homepage
|
name User Homepage
|
||||||
desc Automatically create user's private namespace and/or public page and redirects users to private namespace on login.
|
desc Automatically create user's private namespace and/or public page and redirects users to private namespace on login.
|
||||||
url https://www.dokuwiki.org/plugin:userhomepage
|
url https://www.dokuwiki.org/plugin:userhomepage
|
||||||
|
|
Loading…
Reference in a new issue