From a2efe30f0470b8150e70189e6f8d9d7d8601ea87 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Tue, 28 Sep 2010 14:37:33 +0200 Subject: [PATCH] Use user object from session to compute permission when using 'hasPerm' in templates. Signed-off-by: Florent Bruneau --- classes/plpage.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/classes/plpage.php b/classes/plpage.php index 63ece95..258a8c3 100644 --- a/classes/plpage.php +++ b/classes/plpage.php @@ -494,13 +494,11 @@ function core_include($source, &$smarty) function if_rewrites($source, &$smarty) { - $perms = 'isset($smarty.session.perms|smarty:nodefaults) && $smarty.session.perms|smarty:nodefaults && $smarty.session.perms'; - return preg_replace(array('/\{if([^}]*) (\!?)hasPerms\(([^)]+)\)([^}]*)\}/', - '/\{if([^}]*) (\!?)hasPerm\(([^)]+)\)([^}]*)\}/', - '/\{if([^}]*) (\!?)t\(([^)]+)\)([^}]*)\}/'), - array('{if\1 \2(' . $perms . '->hasFlagCombination(\3))\4}', - '{if\1 \2(' . $perms . '->hasFlag(\3))\4}', - '{if\1 \2(isset(\3|smarty:nodefaults) && (\3|smarty:nodefaults))\4}'), + $perms = 'isset($smarty.session.user|smarty:nodefaults) && $smarty.session.user'; + return preg_replace(array('/\{(else)?if([^}]*) (\!?)hasPerms?\(([^)]+)\)([^}]*)\}/', + '/\{(else)?if([^}]*) (\!?)t\(([^)]+)\)([^}]*)\}/'), + array('{\1if\2 \3(' . $perms . '->checkPerms(\4))\5}', + '{\1if\2 \3(isset(\4|smarty:nodefaults) && (\4|smarty:nodefaults))\5}'), $source); } -- 2.1.4