Making sure Public NS doesn't conflict with Private one
This commit is contained in:
parent
cb5f4827d7
commit
76ec613777
44
action.php
44
action.php
|
@ -25,6 +25,8 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
|
||||||
|
|
||||||
function init(&$event, $param) {
|
function init(&$event, $param) {
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
|
if ($this->settingsCheck(true)) {
|
||||||
$this->helper = plugin_load('helper','userhomepage');
|
$this->helper = plugin_load('helper','userhomepage');
|
||||||
// If templates_path option starts with 'data/pages' it can automatically be adapted but should be changed
|
// If templates_path option starts with 'data/pages' it can automatically be adapted but should be changed
|
||||||
if (substr($this->getConf('templates_path'),0,10) == 'data/pages') {
|
if (substr($this->getConf('templates_path'),0,10) == 'data/pages') {
|
||||||
|
@ -63,7 +65,6 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
|
||||||
$this->private_page = $this->helper->getPrivateID();
|
$this->private_page = $this->helper->getPrivateID();
|
||||||
// user:simon.txt
|
// user:simon.txt
|
||||||
$this->public_page = $this->helper->getPublicID();
|
$this->public_page = $this->helper->getPublicID();
|
||||||
|
|
||||||
// If a user is logged in, store timestamp (if it wasn't stored yet)
|
// If a user is logged in, store timestamp (if it wasn't stored yet)
|
||||||
if (($_SERVER['REMOTE_USER']!=null) && (!isset($_SESSION['uhptimestamp']))) {
|
if (($_SERVER['REMOTE_USER']!=null) && (!isset($_SESSION['uhptimestamp']))) {
|
||||||
$_SESSION['uhptimestamp'] = time();
|
$_SESSION['uhptimestamp'] = time();
|
||||||
|
@ -71,11 +72,16 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
|
||||||
} elseif (($_SERVER['REMOTE_USER']==null) && (isset($_SESSION['uhptimestamp']))) {
|
} elseif (($_SERVER['REMOTE_USER']==null) && (isset($_SESSION['uhptimestamp']))) {
|
||||||
$_SESSION['uhptimestamp'] = null;
|
$_SESSION['uhptimestamp'] = null;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return flase;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function redirect(&$event, $param) {
|
function redirect(&$event, $param) {
|
||||||
global $conf;
|
global $conf;
|
||||||
global $lang;
|
global $lang;
|
||||||
|
|
||||||
|
if ($this->settingsCheck()) {
|
||||||
$created = array();
|
$created = array();
|
||||||
// If a user is logged in and not allready requesting his private namespace start page
|
// If a user is logged in and not allready requesting his private namespace start page
|
||||||
if (($_SERVER['REMOTE_USER']!=null)&&($_REQUEST['id']!=$this->private_page)) {
|
if (($_SERVER['REMOTE_USER']!=null)&&($_REQUEST['id']!=$this->private_page)) {
|
||||||
|
@ -144,24 +150,24 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
|
||||||
}
|
}
|
||||||
// If Public page was just created, redirect to it and edit (or show)
|
// If Public page was just created, redirect to it and edit (or show)
|
||||||
if (($created['public']) && (page_exists($this->public_page))) {
|
if (($created['public']) && (page_exists($this->public_page))) {
|
||||||
// send_redirect(wl($this->public_page, 'do='.$this->getConf('action'), false, '&'));
|
|
||||||
send_redirect(wl($this->public_page, array('do='.$this->getConf('action')), true));
|
send_redirect(wl($this->public_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 private start page was just created and edit option is set, redirect to it and edit
|
||||||
} elseif (($created['private']) && (page_exists($this->private_page)) && ($this->getConf('edit_before_create'))) {
|
} elseif (($created['private']) && (page_exists($this->private_page)) && ($this->getConf('edit_before_create'))) {
|
||||||
// send_redirect(wl($this->private_page, 'do='.$this->getConf('action'), false, '&'));
|
|
||||||
send_redirect(wl($this->private_page, array('do='.$this->getConf('action')), true));
|
send_redirect(wl($this->private_page, array('do='.$this->getConf('action')), 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]
|
// 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))) {
|
} 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));
|
|
||||||
send_redirect(wl($this->private_page, '', true));
|
send_redirect(wl($this->private_page, '', true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return flase;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function acl(&$event, $param) {
|
function acl(&$event, $param) {
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
// if ((!$this->getConf('no_acl')) && ($conf['useacl'])) {
|
if ($this->settingsCheck()) {
|
||||||
if ((!$this->getConf('no_acl')) && ($conf['useacl']) && (isset($_SERVER['REMOTE_USER']))) {
|
if ((!$this->getConf('no_acl')) && ($conf['useacl']) && (isset($_SERVER['REMOTE_USER']))) {
|
||||||
$existingLines = file(DOKU_CONF.'acl.auth.php');
|
$existingLines = file(DOKU_CONF.'acl.auth.php');
|
||||||
$newLines = array();
|
$newLines = array();
|
||||||
|
@ -289,6 +295,9 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return flase;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyFile($source = null, $target_dir = null, $target_file = null) {
|
function copyFile($source = null, $target_dir = null, $target_file = null) {
|
||||||
|
@ -353,6 +362,7 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
|
||||||
global $INFO;
|
global $INFO;
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
|
if ($this->settingsCheck()) {
|
||||||
if (($conf['showuseras'] == "username_link") and ($this->getConf('userlink_replace'))) {
|
if (($conf['showuseras'] == "username_link") and ($this->getConf('userlink_replace'))) {
|
||||||
$classes = $this->getConf('userlink_classes');
|
$classes = $this->getConf('userlink_classes');
|
||||||
$classes = str_replace(',', ' ', $classes);
|
$classes = str_replace(',', ' ', $classes);
|
||||||
|
@ -404,6 +414,30 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return flase;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function settingsCheck($msg=false) {
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
// Error #1: Public page switched to namespace and is in conflict with Private namespace
|
||||||
|
if (strpos($this->getConf('public_pages_ns'),':%NAME%:%START%') !== false) {
|
||||||
|
$PublicNS = str_replace(':%NAME%:%START%', '', $this->getConf('public_pages_ns'));
|
||||||
|
$PublicNS = str_replace(':', '', $PublicNS);
|
||||||
|
$PrivateNS = str_replace(':', '', $this->getConf('users_namespace'));
|
||||||
|
if ($PublicNS == $PublicNS) {
|
||||||
|
if ($msg) {
|
||||||
|
msg("UserHomePage error #1 ! Make sure Private and Public namespaces are different. Plugin will have no effect untill this is corrected.", -1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue