TYPO3 CMS  TYPO3_6-2
CategoryPermissionsAspect.php
Go to the documentation of this file.
1 <?php
3 
21 
30 
34  protected $categoryTableName = 'sys_category';
35 
40 
44  public function __construct($backendUserAuthentication = NULL) {
45  $this->backendUserAuthentication = $backendUserAuthentication ?: $GLOBALS['BE_USER'];
46  }
47 
55  public function addUserPermissionsToCategoryTreeData(DatabaseTreeDataProvider $dataProvider, $treeData) {
56 
57  if (!$this->backendUserAuthentication->isAdmin() && $dataProvider->getTableName() === $this->categoryTableName) {
58 
59  // Get User permissions related to category
60  $categoryMountPoints = $this->backendUserAuthentication->getCategoryMountPoints();
61 
62  // Backup child nodes to be processed.
63  $treeNodeCollection = $treeData->getChildNodes();
64 
65  if (!empty($categoryMountPoints) && !empty($treeNodeCollection)) {
66 
67  // First, remove all child nodes which must be analysed to be considered as "secure".
68  // The nodes were backed up in variable $treeNodeCollection beforehand.
69  $treeData->removeChildNodes();
70 
71  // Create an empty tree node collection to receive the secured nodes.
73  $securedTreeNodeCollection = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Tree\\TreeNodeCollection');
74 
75  foreach ($categoryMountPoints as $categoryMountPoint) {
76 
77  $treeNode = $this->lookUpCategoryMountPointInTreeNodes((int)$categoryMountPoint, $treeNodeCollection);
78  if (!is_null($treeNode)) {
79  $securedTreeNodeCollection->append($treeNode);
80  }
81  }
82 
83  // Reset child nodes.
84  $treeData->setChildNodes($securedTreeNodeCollection);
85  }
86  }
87  }
88 
96  protected function lookUpCategoryMountPointInTreeNodes($categoryMountPoint, TreeNodeCollection $treeNodeCollection) {
97 
98  $result = NULL;
99 
100  // If any User permission, recursively traverse the tree and set tree part as mount point
101  foreach ($treeNodeCollection as $treeNode) {
102 
104  if ((int)$treeNode->getId() === $categoryMountPoint) {
105  $result = $treeNode;
106  break;
107  }
108 
109  if ($treeNode->hasChildNodes()) {
110 
112  $node = $this->lookUpCategoryMountPointInTreeNodes($categoryMountPoint, $treeNode->getChildNodes());
113  if (! is_null($node)) {
114  $result = $node;
115  break;
116  }
117  }
118  }
119  return $result;
120  }
121 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]