From: Nicolas Iooss Date: Mon, 26 May 2014 21:14:00 +0000 (+0200) Subject: Allow parenthesis before hasPerm in smarty templates X-Git-Tag: core/1.1.13~1 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=ad274e6db6423a279524c0c8120db041720c4177;p=platal.git Allow parenthesis before hasPerm in smarty templates In smarty templates, this syntax works fine: {if !hasPerm('directory_private') && other_test() } ... but not this one: {if (!hasPerm('directory_private') || test1()) && test2()} ... because the regexp which handle hasPerm "function" in smarty does not support parenthesis. Fix this bug by explicitly allowing space and open parenthesis before hasPerm(). --- diff --git a/ChangeLog b/ChangeLog index 9ae2a69..29e17df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,11 @@ ================================================================================ +VERSION 1.1.13 XX XX XXXX + +Bugs: + + * Allow parenthesis before hasPerm() in templates -IOS + +================================================================================ VERSION 1.1.12 08 03 2014 Bugs: diff --git a/classes/plpage.php b/classes/plpage.php index b79fa1c..30c2a82 100644 --- a/classes/plpage.php +++ b/classes/plpage.php @@ -525,10 +525,10 @@ function core_include($source, $smarty) function if_rewrites($source, $smarty) { $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}'), + 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); }