TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Fluid\ViewHelpers\Security\IfHasRoleViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\Security\IfHasRoleViewHelper:
TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper TYPO3\CMS\Fluid\Core\ViewHelper\Facets\ChildNodeAccessInterface TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface Tx_Fluid_ViewHelpers_Security_IfHasRoleViewHelper

Public Member Functions

 render ($role)
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper
 setChildNodes (array $childNodes)
 
 __construct ()
 
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 
- Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 setArguments (array $arguments)
 
 setRenderingContext (\TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
 injectReflectionService (\TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService)
 
 isEscapingInterceptorEnabled ()
 
 setViewHelperNode (\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode $node)
 
 setRenderChildrenClosure (\Closure $renderChildrenClosure)
 
 initializeArgumentsAndRender ()
 
 initialize ()
 
 renderChildren ()
 
 prepareArguments ()
 
 validateArguments ()
 
 initializeArguments ()
 
 compile ($argumentsVariableName, $renderChildrenClosureVariableName, &$initializationPhpCode, \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode $syntaxTreeNode, \TYPO3\CMS\Fluid\Core\Compiler\TemplateCompiler $templateCompiler)
 
 resetState ()
 

Protected Member Functions

 frontendUserHasRole ($role)
 
- Protected Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper
 renderThenChild ()
 
 renderElseChild ()
 
- Protected Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 registerArgument ($name, $type, $description, $required=FALSE, $defaultValue=NULL)
 
 overrideArgument ($name, $type, $description, $required=FALSE, $defaultValue=NULL)
 
 callRenderMethod ()
 
 buildRenderChildrenClosure ()
 
 hasArgument ($argumentName)
 

Additional Inherited Members

- Static Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
static renderStatic (array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Static Public Member Functions inherited from TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface
static renderStatic (array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)
 
- Protected Attributes inherited from TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
 $arguments
 
 $templateVariableContainer
 
 $controllerContext
 
 $renderingContext
 
 $renderChildrenClosure = NULL
 
 $viewHelperVariableContainer
 
 $objectManager
 
 $escapingInterceptorEnabled = TRUE
 

Detailed Description

This view helper implements an ifHasRole/else condition for FE users/groups.

= Examples =

<f:security.ifHasRole role="Administrator"> This is being shown in case the current FE user belongs to a FE usergroup (aka role) titled "Administrator" (case sensitive) </f:security.ifHasRole> <output> Everything inside the <f:ifHasRole> tag is being displayed if the logged in FE user belongs to the specified role. </output>

<f:security.ifHasRole role="1"> This is being shown in case the current FE user belongs to a FE usergroup (aka role) with the uid "1" </f:security.ifHasRole> <output> Everything inside the <f:ifHasRole> tag is being displayed if the logged in FE user belongs to the specified role. </output>

<f:security.ifHasRole role="Administrator"> <f:then> This is being shown in case you have the role. </f:then> <f:else> This is being displayed in case you do not have the role. </f:else> </f:security.ifHasRole> <output> Everything inside the "then" tag is displayed if the logged in FE user belongs to the specified role. Otherwise, everything inside the "else"-tag is displayed. </output>

Definition at line 63 of file IfHasRoleViewHelper.php.

Member Function Documentation

◆ frontendUserHasRole()

TYPO3\CMS\Fluid\ViewHelpers\Security\IfHasRoleViewHelper::frontendUserHasRole (   $role)
protected

Determines whether the currently logged in FE user belongs to the specified usergroup

Parameters
string$roleThe usergroup (either the usergroup uid or its title)
Returns
boolean TRUE if the currently logged in FE user belongs to $role

Definition at line 87 of file IfHasRoleViewHelper.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Fluid\ViewHelpers\Security\IfHasRoleViewHelper\render().

◆ render()

TYPO3\CMS\Fluid\ViewHelpers\Security\IfHasRoleViewHelper::render (   $role)

renders <f:then> child if the current logged in FE user belongs to the specified role (aka usergroup) otherwise renders <f:else> child.

Parameters
string$roleThe usergroup (either the usergroup uid or its title)
Returns
string the rendered string

Definition at line 73 of file IfHasRoleViewHelper.php.

References TYPO3\CMS\Fluid\ViewHelpers\Security\IfHasRoleViewHelper\frontendUserHasRole(), TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper\renderElseChild(), and TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper\renderThenChild().