TYPO3  7.6
PermissionsViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Beuser\ViewHelpers;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 
29 {
33  protected static $permissionLabels = array();
34 
43  public function render($permission, $scope, $pageId)
44  {
45  return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext);
46  }
47 
58  {
59  $masks = array(1, 16, 2, 4, 8);
60 
61  if (empty(static::$permissionLabels)) {
62  foreach ($masks as $mask) {
63  static::$permissionLabels[$mask] = LocalizationUtility::translate(
64  'LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:' . $mask,
65  'be_user'
66  );
67  }
68  }
69 
70  $icon = '';
71  foreach ($masks as $mask) {
72  if ($arguments['permission'] & $mask) {
73  $permissionClass = 'fa-check text-success';
74  $mode = 'delete';
75  } else {
76  $permissionClass = 'fa-times text-danger';
77  $mode = 'add';
78  }
79  $icon .= '<span style="cursor:pointer"'
80  . ' title="' . htmlspecialchars(static::$permissionLabels[$mask]) . '"'
81  . ' data-page="' . $arguments['pageId'] . '"'
82  . ' data-permissions="' . $arguments['permission'] . '"'
83  . ' data-who="' . $arguments['scope'] . '"'
84  . ' data-bits="' . $mask . '"'
85  . ' data-mode="' . $mode . '"'
86  . ' class="t3-icon change-permission fa ' . $permissionClass . '"></span>';
87  }
88 
89  return '<span id="' . $arguments['pageId'] . '_' . $arguments['scope'] . '">' . $icon . '</span>';
90  }
91 }