From: Florent Bruneau Date: Tue, 28 Sep 2010 12:37:33 +0000 (+0200) Subject: Use user object from session to compute permission when using 'hasPerm' in X-Git-Tag: core/1.1.1~19 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=a2efe30f0470b8150e70189e6f8d9d7d8601ea87;p=platal.git Use user object from session to compute permission when using 'hasPerm' in templates. Signed-off-by: Florent Bruneau --- 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); }