Fixing bug on Public pages ACL

This commit is contained in:
Simon DELAGE 2014-12-18 01:40:21 +01:00
parent 2e38729a9f
commit 5a615a99a1
2 changed files with 18 additions and 11 deletions

View File

@ -147,23 +147,30 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
if ($this->getConf('acl_all_public') != 'noacl') {
// If both private and public namespaces are identical, we need to force rights for @ALL and/or @user on each public page
if ($this->getConf('users_namespace') == $this->getConf('public_pages_ns')) {
foreach (glob("data/pages/".$this->getConf('public_pages_ns')."/*.txt") as $filename) {
// ACL on templates will be managed another way
if (strpos($filename, 'userhomepage_p') == false) {
// @ALL
$acl->_acl_add($this->getConf('public_pages_ns').':'.explode('.', end(explode('/', $filename)))[0], '@ALL', $this->getConf('acl_all_public'));
// @user
if (($this->getConf('acl_user_public') != 'noacl') && ($this->getConf('acl_user_public') !== $this->getConf('acl_all_public'))) {
$acl->_acl_add($this->getConf('public_pages_ns').':'.explode('.', end(explode('/', $filename)))[0], '@user', $this->getConf('acl_user_public'));
$files = scandir(DOKU_CONF.'../data/pages/'.$this->getConf('public_pages_ns'));
foreach($files as $file) {
if (is_file(DOKU_CONF.'../data/pages/'.$this->getConf('public_pages_ns').'/'.$file)) {
// ACL on templates will be managed another way
if (strpos($file, 'userhomepage_p') !== 0) {
// @ALL
if ($this->getConf('acl_all_public') != 'noacl') {
$acl->_acl_add($this->getConf('public_pages_ns').':'.substr($file, 0, -4), '@ALL', $this->getConf('acl_all_public'));
}
// @user
if ($this->getConf('acl_user_public') != 'noacl') {
$acl->_acl_add($this->getConf('public_pages_ns').':'.substr($file, 0, -4), '@user', $this->getConf('acl_user_public'));
}
}
}
}
// Otherwise we just need to give the right permission to each group on public pages namespace
} else {
// @ALL
$acl->_acl_add(cleanID($this->getConf('public_pages_ns')).':*', '@ALL', $this->getConf('acl_all_public'));
if ($this->getConf('acl_all_public') != 'noacl') {
$acl->_acl_add(cleanID($this->getConf('public_pages_ns')).':*', '@ALL', $this->getConf('acl_all_public'));
}
// @user
if (($this->getConf('acl_user_public') != 'noacl') && ($this->getConf('acl_user_public') !== $this->getConf('acl_all_public'))) {
if ($this->getConf('acl_user_public') != 'noacl') {
$acl->_acl_add(cleanID($this->getConf('public_pages_ns')).':*', '@user', $this->getConf('acl_user_public'));
}
}

View File

@ -1,7 +1,7 @@
base userhomepage
author Simon Delage
email simon.geekitude@gmail.com
date 2014-12-06
date 2014-12-18
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