From ad274e6db6423a279524c0c8120db041720c4177 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Mon, 26 May 2014 23:14:00 +0200 Subject: [PATCH] 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(). --- ChangeLog | 7 +++++++ classes/plpage.php | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) 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); } -- 2.1.4