[BUGFIX] ClickMenu: Visibility-options only if fields allowed 64/28364/2
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 4 Feb 2014 23:38:04 +0000 (00:38 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 5 Apr 2014 21:48:53 +0000 (23:48 +0200)
So far the entries "Hide/Unhide" and "Visibility settings" always
showed up in the ClickMenu. We need to check via excludefields if the
other has any right to change such a field or hide the icons.

Change-Id: Ib86fbd6d30f2cc0ec52e506d5fa2f12c95a2f178
Resolves: #55683
Releases: 6.2, 6.1
Reviewed-on: https://review.typo3.org/28364
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/extra_page_cm_options/Classes/ExtraPageContextMenuOptions.php

index 6b4dbec..75e5255 100644 (file)
@@ -62,13 +62,43 @@ class ExtraPageContextMenuOptions {
                                        0,
                                        1
                                );
-                               if (!in_array('hide', $backRef->disabledItems) && is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) && $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']) {
-                                       $localItems['hide'] = $backRef->DB_hideUnhide($table, $backRef->rec, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']);
+                               $menuItemHideUnhideAllowed = FALSE;
+                               $hiddenField = '';
+                               // Check if column for disabled is defined
+                               if (isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']) && isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'])) {
+                                       $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
+                                       if (
+                                               $hiddenField !== '' && !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
+                                               && (!empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
+                                                       && $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $hiddenField))
+                                       ) {
+                                               $menuItemHideUnhideAllowed = TRUE;
+                                       }
                                }
-                               if (!in_array('edit_access', $backRef->disabledItems) && is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
+                               if ($menuItemHideUnhideAllowed && !in_array('hide', $backRef->disabledItems)) {
+                                       $localItems['hide'] = $backRef->DB_hideUnhide($table, $backRef->rec, $hiddenField);
+                               }
+                               $anyEnableColumnsFieldAllowed = FALSE;
+                               // Check if columns are defined
+                               if (isset($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
+                                       $columnsToCheck = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
+                                       if ($table === 'pages' && !empty($columnsToCheck)) {
+                                               $columnsToCheck[] = 'extendToSubpages';
+                                       }
+                                       foreach ($columnsToCheck as $currentColumn) {
+                                               if (
+                                                       isset($GLOBALS['TCA'][$table]['columns'][$currentColumn])
+                                                       && (!empty($GLOBALS['TCA'][$table]['columns'][$currentColumn]['exclude'])
+                                                               && $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $currentColumn))
+                                               ) {
+                                                       $anyEnableColumnsFieldAllowed = TRUE;
+                                               }
+                                       }
+                               }
+                               if ($anyEnableColumnsFieldAllowed && !in_array('edit_access', $backRef->disabledItems)) {
                                        $localItems['edit_access'] = $backRef->DB_editAccess($table, $uid);
                                }
-                               if (!in_array('edit_pageproperties', $backRef->disabledItems) && $table === 'pages' && $backRef->editPageIconSet) {
+                               if ($table === 'pages' && $backRef->editPageIconSet && !in_array('edit_pageproperties', $backRef->disabledItems)) {
                                        $localItems['edit_pageproperties'] = $backRef->DB_editPageProperties($uid);
                                }
                        }
@@ -93,13 +123,13 @@ class ExtraPageContextMenuOptions {
                } elseif ($subname === 'moreoptions') {
                        // If the page can be edited, then show this:
                        if ($backRef->editOK) {
-                               if (!in_array('move_wizard', $backRef->disabledItems) && ($table === 'pages' || $table === 'tt_content')) {
+                               if (($table === 'pages' || $table === 'tt_content') && !in_array('move_wizard', $backRef->disabledItems)) {
                                        $localItems['move_wizard'] = $backRef->DB_moveWizard($table, $uid, $backRef->rec);
                                }
-                               if (!in_array('new_wizard', $backRef->disabledItems) && ($table === 'pages' || $table === 'tt_content')) {
+                               if (($table === 'pages' || $table === 'tt_content') && !in_array('new_wizard', $backRef->disabledItems)) {
                                        $localItems['new_wizard'] = $backRef->DB_newWizard($table, $uid, $backRef->rec);
                                }
-                               if (!in_array('perms', $backRef->disabledItems) && $table === 'pages' && $GLOBALS['BE_USER']->check('modules', 'web_perm')) {
+                               if ($table === 'pages' && !in_array('perms', $backRef->disabledItems) && $GLOBALS['BE_USER']->check('modules', 'web_perm')) {
                                        $localItems['perms'] = $backRef->DB_perms($table, $uid, $backRef->rec);
                                }
                                if (!in_array('db_list', $backRef->disabledItems) && $GLOBALS['BE_USER']->check('modules', 'web_list')) {
@@ -118,4 +148,4 @@ class ExtraPageContextMenuOptions {
 
 }
 
-?>
\ No newline at end of file
+?>