From 99ce0a2512e38ab7d0569ebdb91b24cfdde3b719 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Sat, 22 Jul 2006 16:35:20 +0000 Subject: [PATCH] more on perms git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@564 839d8a87-29fc-0310-9880-83ba4fa771e5 --- htdocs/wiki.php | 19 +++++++++++++------ include/wiki.inc.php | 9 +++++++++ templates/skins.tpl | 2 +- templates/wiki.tpl | 18 +++++++++--------- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/htdocs/wiki.php b/htdocs/wiki.php index 1d0963e..ab25fbc 100644 --- a/htdocs/wiki.php +++ b/htdocs/wiki.php @@ -31,16 +31,15 @@ if (!$n) { } new_skinned_page('wiki.tpl'); +$perms = get_perms($n); switch (Env::get('action')) { case '': - list($r) = get_perms($n); - wiki_apply_perms($r); + wiki_apply_perms($perms[0]); break; case 'edit': - list(, $e) = get_perms($n); - wiki_apply_perms($e); + wiki_apply_perms($perms[1]); break; default: @@ -78,9 +77,17 @@ if (Env::get('action')) { } } +$page->assign('perms', $perms); +$page->assign('perms_opts', + array('public' => 'Public', 'logged' => 'Connecté', + 'mdp' => 'Authentifié', 'admin' => 'Admin')); + +$page->assign('canedit', wiki_may_have_perms($perms[1])); +$page->assign('has_perms', wiki_may_have_perms('admin')); + $page->assign('wikipage', str_replace('.', '/', $n)); -$page->assign('pmwiki', $wikiAll); -$page->assign('has_perms', S::has_perms()); +$page->assign('pmwiki', $wikiAll); + $page->addCssLink('css/wiki.css'); $page->run(); diff --git a/include/wiki.inc.php b/include/wiki.inc.php index 000690e..7e69dd2 100644 --- a/include/wiki.inc.php +++ b/include/wiki.inc.php @@ -59,6 +59,15 @@ function get_perms($n) return array('logged', 'admin'); } +function wiki_may_have_perms($perm) { + switch ($perm) { + case 'public': return true; + case 'logged': return S::logged(); + case 'mdp': return S::logged(); + default: return S::has_perms(); + } +} + function wiki_apply_perms($perm) { global $page, $platal; diff --git a/templates/skins.tpl b/templates/skins.tpl index d5dd210..7645bfd 100644 --- a/templates/skins.tpl +++ b/templates/skins.tpl @@ -41,7 +41,7 @@ Pour toute information compl
- {iterate item=skin from=$skins} + {iterate item=skin from=$skins} - {if true} + {if $canedit} {/if} {if $has_perms} -- 2.1.4
diff --git a/templates/wiki.tpl b/templates/wiki.tpl index 07355ec..0c679a4 100644 --- a/templates/wiki.tpl +++ b/templates/wiki.tpl @@ -24,22 +24,22 @@
Voir la page + {if $has_perms} + {/if} Éditer + {if $has_perms} + {else} + {$perms[0]} + {/if}