diff --git a/src/Pluf/Template/Compiler.php b/src/Pluf/Template/Compiler.php index 0901a47..0d9c1b9 100644 --- a/src/Pluf/Template/Compiler.php +++ b/src/Pluf/Template/Compiler.php @@ -128,6 +128,7 @@ class Pluf_Template_Compiler 'aurl' => 'Pluf_Template_Tag_Rurl', 'media' => 'Pluf_Template_Tag_MediaUrl', 'amedia' => 'Pluf_Template_Tag_RmediaUrl', + 'aperm' => 'Pluf_Template_Tag_APerm', 'getmsgs' => 'Pluf_Template_Tag_Messages', ); /** diff --git a/src/Pluf/Template/Tag/APerm.php b/src/Pluf/Template/Tag/APerm.php new file mode 100644 index 0000000..aa42b09 --- /dev/null +++ b/src/Pluf/Template/Tag/APerm.php @@ -0,0 +1,49 @@ + + * {aperm 'can_drive', $user, 'MyApp.can_drive'} + * {aperm 'can_drive_big_car', $user, 'MyApp.can_drive', $bigcar} + * {if $can_drive}Can drive!{/if} + * + * + */ +class Pluf_Template_Tag_APerm extends Pluf_Template_Tag +{ + /** + * @param string Variable to get the permission + * @param Pluf_User + * @param string Permission string + * @param mixed Optional Pluf_Model if using row level permission (null) + */ + function start($var, $user, $perm, $object=null) + { + $this->context->set($var, $user->hasPerm($perm, $object)); + } +}