Fixed a bug in folder creation(s)

Bug prevented plugin to create required base folders for templates,
users' namespaces or public pages (was tested at early dev stage but
forgot te test it again later)
This commit is contained in:
Simon DELAGE 2015-02-11 12:55:04 +01:00
parent 18f4b5eae8
commit 1e30b8bfc0
2 changed files with 9 additions and 8 deletions

View file

@ -66,7 +66,7 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
// 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 private page doesn't exists, create it (from template)
if ($this->getConf('create_private_ns') && !page_exists($this->private_page) && !checklock($this->private_page) && !checkwordblock()) {
if ($this->getConf('create_private_ns') && is_file(DOKU_CONF.'../'.$this->getConf('templates_path').'/userhomepage_private.txt') && !page_exists($this->private_page) && !checklock($this->private_page) && !checkwordblock()) {
// Target private start page template
$this->private_page_template = DOKU_CONF.'../'.$this->getConf('templates_path').'/userhomepage_private.txt';
// Create private page
@ -80,7 +80,7 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
}
// Public page?
// If public page doesn't exists, create it (from template)
if ($this->getConf('create_public_page') && !page_exists($this->public_page) && !checklock($this->public_page) && !checkwordblock()) {
if ($this->getConf('create_public_page') && is_file(DOKU_CONF.'../'.$this->getConf('templates_path').'/userhomepage_public.txt') && !page_exists($this->public_page) && !checklock($this->public_page) && !checkwordblock()) {
// Target public page template
$this->public_page_template = DOKU_CONF.'../'.$this->getConf('templates_path').'/userhomepage_public.txt';
// Create public page
@ -245,13 +245,14 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
}
function copyFile($source = null, $target_dir = null, $target_file = null) {
if(!@is_dir($target_dir)){
io_mkdir_p($target_dir) || msg("Creating directory $target_dir failed",-1);
if(!is_dir(DOKU_CONF."../".$target_dir)){
io_mkdir_p(DOKU_CONF."../".$target_dir) || msg("Creating directory $target_dir failed",-1);
}
if (!copy(DOKU_INC.$source, DOKU_CONF.'../'.$target_dir.'/'.$target_file)) {
msg($this->getLang('copyerror').' ('.$source.' > '.$target_dir.'/'.$target_file.')', -1);
} else {
copy(DOKU_INC.$source, DOKU_CONF.'../'.$target_dir.'/'.$target_file);
if (is_file(DOKU_INC.$source, DOKU_CONF.'../'.$target_dir.'/'.$target_file)) {
msg($this->getLang('copysuccess').' ('.$source.' > '.$target_dir.'/'.$target_file.')', 1);
} else {
msg($this->getLang('copyerror').' ('.$source.' > '.$target_dir.'/'.$target_file.')', -1);
}
}

View file

@ -1,7 +1,7 @@
base userhomepage
author Simon Delage
email simon.geekitude@gmail.com
date 2015-02-07
date 2015-02-11
name User Homepage
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