Added option to set ACL on templates

This commit is contained in:
Simon DELAGE 2014-09-12 09:40:51 +02:00
parent bd68596c7c
commit 2b5fa08ca9
5 changed files with 21 additions and 3 deletions

View File

@ -69,13 +69,21 @@ class action_plugin_userhomepage extends DokuWiki_Action_Plugin{
// If both private and public namespaces are identical, we need more ACL to force read rights for @ALL on public pages
if ($this->getConf('users_namespace') == $this->getConf('public_pages_ns')) {
foreach (glob("data/pages/".$this->getConf('public_pages_ns')."/*.txt") as $filename) {
$acl->_acl_add($this->getConf('public_pages_ns').':'.explode('.', end(explode('/', $filename)))[0], '@ALL', AUTH_READ);
// ACL on templates will be managed another way
if (strpos($filename, 'userhomepage_p') == false) {
$acl->_acl_add($this->getConf('public_pages_ns').':'.explode('.', end(explode('/', $filename)))[0], '@ALL', AUTH_READ);
}
}
// Otherwise we just need to give read access to @ALL on public pages namespace
} else {
$acl->_acl_add(cleanID($this->getConf('public_pages_ns')).':*', '@ALL', AUTH_READ);
}
}
// For templates if they're in data/pages
if (strpos($this->getConf('templates_path'),'data/pages') !== false) {
$acl->_acl_add(end(explode('/',$this->getConf('templates_path'))).':userhomepage_private', '@ALL', (int)$this->getConf('set_permissions_templates'));
$acl->_acl_add(end(explode('/',$this->getConf('templates_path'))).':userhomepage_public', '@ALL', (int)$this->getConf('set_permissions_templates'));
}
// If we changed some ACL, we probably duplicated some lines
if (($this->getConf('set_permissions')) or ($this->getConf('set_permissions_public'))) {
// Some lines in conf/acl.auth.php file have probably been duplicated so let's read the file

View File

@ -9,7 +9,7 @@
$conf['create_private_ns'] = 0;
$conf['use_name_string'] = 0;
$conf['use_start_page'] = 1;
$conf['users_namespace'] = 'private';
$conf['users_namespace'] = 'user';
$conf['set_permissions'] = 1;
$conf['set_permissions_others'] = '0';
$conf['group_by_name'] = 0;
@ -17,5 +17,6 @@
$conf['create_public_page'] = 0;
$conf['public_pages_ns'] = 'user';
$conf['set_permissions_public'] = 1;
$conf['templates_path'] = 'data/pages/wiki';
$conf['templates_path'] = 'data/pages/user';
$conf['set_permissions_templates'] = '0';
$conf['templatepath'] = 'lib/plugins/userhomepage/_template.txt';

View File

@ -18,4 +18,5 @@
$meta['public_pages_ns'] = array('string','_pattern' => '/^(|[a-zA-Z\-:]+)$/','_caution' => 'warning');
$meta['set_permissions_public'] = array('onoff');
$meta['templates_path'] = array('string');
$meta['set_permissions_templates'] = array('multichoice','_choices'=>array('0','1','2'));
$meta['templatepath'] = array('string');

View File

@ -24,4 +24,8 @@
$lang['public_pages_ns'] = 'Namespace under wich public pages are created.';
$lang['set_permissions_public'] = 'Automatically configure ACL for the public pages (anyone can read but only user can edit his own).';
$lang['templates_path'] = 'Path where templates will be stored (userhomepage_private.txt and userhomepage_public.txt). Examples: <code>data/pages/wiki</code> (makes templates editable within DokuWiki) or <code>lib/plugins/userhomepage</code> (to protect templates or centralize them in a farm setup).';
$lang['set_permissions_templates'] = 'If templates are stored in <code>data/pages...</code>, automatically set following ACL for @ALL)';
$lang['set_permissions_templates_o_0'] = 'None';
$lang['set_permissions_templates_o_1'] = 'Read';
$lang['set_permissions_templates_o_2'] = 'Edit';
$lang['templatepath'] = 'Template path from version 3.0.4 if it was installed before. If this file exists, it will be used as default source for new private namespace start page template (clear the path if you don\'t want to).';

View File

@ -24,4 +24,8 @@
$lang['public_pages_ns'] = 'Espace de nom sous lequel créer les pages publiques.';
$lang['set_permissions_public'] = 'Automatiquement configurer les droits d\'accès aux pages publiques (lecture pour tous mais seul l\'utilisateur peut modifier sa page).';
$lang['templates_path'] = 'Chemin où les modèles seront stockés (userhomepage_private.txt et userhomepage_public.txt). Examples: <code>data/pages/wiki</code> (permet d\'éditer les modèles depuis le wiki) ou <code>lib/plugins/userhomepage</code> (pour protéger les modèles ou les centraliser dans une ferme de wikis).';
$lang['set_permissions_templates'] = 'If templates are stored in <code>data/pages...</code>, automatically set following ACL for @ALL)';
$lang['set_permissions_templates_o_0'] = 'None';
$lang['set_permissions_templates_o_1'] = 'Read';
$lang['set_permissions_templates_o_2'] = 'Edit';
$lang['templatepath'] = 'Chemin vers le modèle de la version 3.0.4 si elle était installée précédement. Cette option n\'est là que pour permettre la rétro-compatibilité. Si le fichier existe, il sera utilisé comme source pour le modèle des pages d\'accueil des espaces privés (videz le chemin si vous ne le voulez pas).';