[BUGFIX] Move delete and history menu item above moreoptions 80/43880/4
authorBenjamin Mack <benni@typo3.org>
Wed, 7 Oct 2015 06:22:15 +0000 (08:22 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Thu, 8 Oct 2015 04:33:34 +0000 (06:33 +0200)
In ClickMenu the menu items history and delete are registered
below the moreoption items. Within the more option items a check
is done against the delete menu item which never exists at that
point of code execution. Move this piece of code above moreoptions.

Releases: master
Resolves: #67415
Change-Id: I606e7717ca9e0be5d5256e66879b6a1b1a183887
Reviewed-on: http://review.typo3.org/43880
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php

index cec5365..4eaea9a 100644 (file)
@@ -252,7 +252,7 @@ class ClickMenu {
                        // Get permissions
                        $lCP = $this->backendUser->calcPerms(BackendUtility::getRecord('pages', $table === 'pages' ? $this->rec['uid'] : $this->rec['pid']));
                        // View
                        // Get permissions
                        $lCP = $this->backendUser->calcPerms(BackendUtility::getRecord('pages', $table === 'pages' ? $this->rec['uid'] : $this->rec['pid']));
                        // View
-                       if (!in_array('view', $this->disabledItems)) {
+                       if (!in_array('view', $this->disabledItems, TRUE)) {
                                if ($table === 'pages') {
                                        $menuItems['view'] = $this->DB_view($uid);
                                }
                                if ($table === 'pages') {
                                        $menuItems['view'] = $this->DB_view($uid);
                                }
@@ -263,31 +263,31 @@ class ClickMenu {
                        }
                        // Edit:
                        if (!$root && ($this->backendUser->isPSet($lCP, $table, 'edit') || $this->backendUser->isPSet($lCP, $table, 'editcontent'))) {
                        }
                        // Edit:
                        if (!$root && ($this->backendUser->isPSet($lCP, $table, 'edit') || $this->backendUser->isPSet($lCP, $table, 'editcontent'))) {
-                               if (!in_array('edit', $this->disabledItems)) {
+                               if (!in_array('edit', $this->disabledItems, TRUE)) {
                                        $menuItems['edit'] = $this->DB_edit($table, $uid);
                                }
                                $this->editOK = TRUE;
                        }
                        // New:
                                        $menuItems['edit'] = $this->DB_edit($table, $uid);
                                }
                                $this->editOK = TRUE;
                        }
                        // New:
-                       if (!in_array('new', $this->disabledItems) && $this->backendUser->isPSet($lCP, $table, 'new')) {
+                       if (!in_array('new', $this->disabledItems, TRUE) && $this->backendUser->isPSet($lCP, $table, 'new')) {
                                $menuItems['new'] = $this->DB_new($table, $uid);
                        }
                        // Info:
                                $menuItems['new'] = $this->DB_new($table, $uid);
                        }
                        // Info:
-                       if (!in_array('info', $this->disabledItems) && !$root) {
+                       if (!in_array('info', $this->disabledItems, TRUE) && !$root) {
                                $menuItems['info'] = $this->DB_info($table, $uid);
                        }
                        $menuItems['spacer1'] = 'spacer';
                        // Copy:
                                $menuItems['info'] = $this->DB_info($table, $uid);
                        }
                        $menuItems['spacer1'] = 'spacer';
                        // Copy:
-                       if (!in_array('copy', $this->disabledItems) && !$root && !$DBmount && !$l10nOverlay) {
+                       if (!in_array('copy', $this->disabledItems, TRUE) && !$root && !$DBmount && !$l10nOverlay) {
                                $menuItems['copy'] = $this->DB_copycut($table, $uid, 'copy');
                        }
                        // Cut:
                                $menuItems['copy'] = $this->DB_copycut($table, $uid, 'copy');
                        }
                        // Cut:
-                       if (!in_array('cut', $this->disabledItems) && !$root && !$DBmount && !$l10nOverlay) {
+                       if (!in_array('cut', $this->disabledItems, TRUE) && !$root && !$DBmount && !$l10nOverlay) {
                                $menuItems['cut'] = $this->DB_copycut($table, $uid, 'cut');
                        }
                        // Paste:
                        $elFromAllTables = count($this->clipObj->elFromTable(''));
                                $menuItems['cut'] = $this->DB_copycut($table, $uid, 'cut');
                        }
                        // Paste:
                        $elFromAllTables = count($this->clipObj->elFromTable(''));
-                       if (!in_array('paste', $this->disabledItems) && $elFromAllTables) {
+                       if (!in_array('paste', $this->disabledItems, TRUE) && $elFromAllTables) {
                                $selItem = $this->clipObj->getSelectedRecord();
                                $elInfo = array(
                                        GeneralUtility::fixed_lgd_cs($selItem['_RECORD_TITLE'], $this->backendUser->uc['titleLen']),
                                $selItem = $this->clipObj->getSelectedRecord();
                                $elInfo = array(
                                        GeneralUtility::fixed_lgd_cs($selItem['_RECORD_TITLE'], $this->backendUser->uc['titleLen']),
@@ -304,11 +304,22 @@ class ClickMenu {
                                        $menuItems['pasteafter'] = $this->DB_paste($table, -$uid, 'after', $elInfo);
                                }
                        }
                                        $menuItems['pasteafter'] = $this->DB_paste($table, -$uid, 'after', $elInfo);
                                }
                        }
+
+                       // Delete:
+                       $elInfo = array(GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $this->rec), $this->backendUser->uc['titleLen']));
+                       if (!in_array('delete', $this->disabledItems, TRUE) && !$root && !$DBmount && $this->backendUser->isPSet($lCP, $table, 'delete')) {
+                               $menuItems['spacer2'] = 'spacer';
+                               $menuItems['delete'] = $this->DB_delete($table, $uid, $elInfo);
+                       }
+                       if (!in_array('history', $this->disabledItems, TRUE)) {
+                               $menuItems['history'] = $this->DB_history($table, $uid, $elInfo);
+                       }
+
                        $localItems = array();
                        if (!$this->cmLevel && !in_array('moreoptions', $this->disabledItems, TRUE)) {
                                // Creating menu items here:
                                if ($this->editOK) {
                        $localItems = array();
                        if (!$this->cmLevel && !in_array('moreoptions', $this->disabledItems, TRUE)) {
                                // Creating menu items here:
                                if ($this->editOK) {
-                                       $localItems[] = 'spacer';
+                                       $localItems['spacer3'] = 'spacer';
                                        $localItems['moreoptions'] = $this->linkItem(
                                                $this->label('more'),
                                                '',
                                        $localItems['moreoptions'] = $this->linkItem(
                                                $this->label('more'),
                                                '',
@@ -373,16 +384,6 @@ class ClickMenu {
                                        $menuItems = array_merge($menuItems, $localItems);
                                }
                        }
                                        $menuItems = array_merge($menuItems, $localItems);
                                }
                        }
-
-                       // Delete:
-                       $elInfo = array(GeneralUtility::fixed_lgd_cs(BackendUtility::getRecordTitle($table, $this->rec), $this->backendUser->uc['titleLen']));
-                       if (!in_array('delete', $this->disabledItems) && !$root && !$DBmount && $this->backendUser->isPSet($lCP, $table, 'delete')) {
-                               $menuItems['spacer2'] = 'spacer';
-                               $menuItems['delete'] = $this->DB_delete($table, $uid, $elInfo);
-                       }
-                       if (!in_array('history', $this->disabledItems)) {
-                               $menuItems['history'] = $this->DB_history($table, $uid, $elInfo);
-                       }
                }
                // Adding external elements to the menuItems array
                $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
                }
                // Adding external elements to the menuItems array
                $menuItems = $this->processingByExtClassArray($menuItems, $table, $uid);
@@ -934,7 +935,7 @@ class ClickMenu {
                                        .'</span>';
                        }
                        // Hide
                                        .'</span>';
                        }
                        // Hide
-                       if (!in_array('hide', $this->disabledItems) && $isStorageRoot && $userMayEditStorage) {
+                       if (!in_array('hide', $this->disabledItems, TRUE) && $isStorageRoot && $userMayEditStorage) {
                                $record = BackendUtility::getRecord('sys_file_storage', $fileObject->getStorage()->getUid());
                                $menuItems['hide'] = $this->DB_changeFlag(
                                        'sys_file_storage',
                                $record = BackendUtility::getRecord('sys_file_storage', $fileObject->getStorage()->getUid());
                                $menuItems['hide'] = $this->DB_changeFlag(
                                        'sys_file_storage',
@@ -945,7 +946,7 @@ class ClickMenu {
                                );
                        }
                        // Edit
                                );
                        }
                        // Edit
-                       if (!in_array('edit', $this->disabledItems) && $fileObject->checkActionPermission('write')) {
+                       if (!in_array('edit', $this->disabledItems, TRUE) && $fileObject->checkActionPermission('write')) {
                                if (!$folder && !$isStorageRoot && $fileObject->isIndexed() && $this->backendUser->check('tables_modify', 'sys_file_metadata')) {
                                        $metaData = $fileObject->_getMetaData();
                                        $menuItems['edit2'] = $this->DB_edit('sys_file_metadata', $metaData['uid']);
                                if (!$folder && !$isStorageRoot && $fileObject->isIndexed() && $this->backendUser->check('tables_modify', 'sys_file_metadata')) {
                                        $metaData = $fileObject->_getMetaData();
                                        $menuItems['edit2'] = $this->DB_edit('sys_file_metadata', $metaData['uid']);
@@ -957,19 +958,19 @@ class ClickMenu {
                                }
                        }
                        // Rename
                                }
                        }
                        // Rename
-                       if (!in_array('rename', $this->disabledItems) && !$isStorageRoot && $fileObject->checkActionPermission('rename')) {
+                       if (!in_array('rename', $this->disabledItems, TRUE) && !$isStorageRoot && $fileObject->checkActionPermission('rename')) {
                                $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename', 'rename', 'actions-edit-rename');
                        }
                        // Upload
                                $menuItems['rename'] = $this->FILE_launch($identifier, 'file_rename', 'rename', 'actions-edit-rename');
                        }
                        // Upload
-                       if (!in_array('upload', $this->disabledItems) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
+                       if (!in_array('upload', $this->disabledItems, TRUE) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
                                $menuItems['upload'] = $this->FILE_launch($identifier, 'file_upload', 'upload', 'actions-edit-upload');
                        }
                        // New
                                $menuItems['upload'] = $this->FILE_launch($identifier, 'file_upload', 'upload', 'actions-edit-upload');
                        }
                        // New
-                       if (!in_array('new', $this->disabledItems) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
+                       if (!in_array('new', $this->disabledItems, TRUE) && $folder && $isOnline && $fileObject->checkActionPermission('write')) {
                                $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder', 'new', 'actions-document-new');
                        }
                        // Info
                                $menuItems['new'] = $this->FILE_launch($identifier, 'file_newfolder', 'new', 'actions-document-new');
                        }
                        // Info
-                       if (!in_array('info', $this->disabledItems) && $fileObject->checkActionPermission('read')) {
+                       if (!in_array('info', $this->disabledItems, TRUE) && $fileObject->checkActionPermission('read')) {
                                if ($isStorageRoot && $userMayViewStorage) {
                                        $menuItems['info'] = $this->DB_info('sys_file_storage', $fileObject->getStorage()->getUid());
                                } elseif (!$folder) {
                                if ($isStorageRoot && $userMayViewStorage) {
                                        $menuItems['info'] = $this->DB_info('sys_file_storage', $fileObject->getStorage()->getUid());
                                } elseif (!$folder) {
@@ -978,16 +979,16 @@ class ClickMenu {
                        }
                        $menuItems[] = 'spacer';
                        // Copy:
                        }
                        $menuItems[] = 'spacer';
                        // Copy:
-                       if (!in_array('copy', $this->disabledItems) && !$isStorageRoot && $fileObject->checkActionPermission('read')) {
+                       if (!in_array('copy', $this->disabledItems, TRUE) && !$isStorageRoot && $fileObject->checkActionPermission('read')) {
                                $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
                        }
                        // Cut:
                                $menuItems['copy'] = $this->FILE_copycut($identifier, 'copy');
                        }
                        // Cut:
-                       if (!in_array('cut', $this->disabledItems) && !$isStorageRoot && $fileObject->checkActionPermission('move')) {
+                       if (!in_array('cut', $this->disabledItems, TRUE) && !$isStorageRoot && $fileObject->checkActionPermission('move')) {
                                $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
                        }
                        // Paste:
                        $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
                                $menuItems['cut'] = $this->FILE_copycut($identifier, 'cut');
                        }
                        // Paste:
                        $elFromAllTables = count($this->clipObj->elFromTable('_FILE'));
-                       if (!in_array('paste', $this->disabledItems) && $elFromAllTables && $folder && $fileObject->checkActionPermission('write')) {
+                       if (!in_array('paste', $this->disabledItems, TRUE) && $elFromAllTables && $folder && $fileObject->checkActionPermission('write')) {
                                $elArr = $this->clipObj->elFromTable('_FILE');
                                $selItem = reset($elArr);
                                $clickedFileOrFolder = ResourceFactory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
                                $elArr = $this->clipObj->elFromTable('_FILE');
                                $selItem = reset($elArr);
                                $clickedFileOrFolder = ResourceFactory::getInstance()->retrieveFileOrFolderObject($combinedIdentifier);
@@ -1003,7 +1004,7 @@ class ClickMenu {
                        }
                        $menuItems[] = 'spacer';
                        // Delete:
                        }
                        $menuItems[] = 'spacer';
                        // Delete:
-                       if (!in_array('delete', $this->disabledItems) && $fileObject->checkActionPermission('delete')) {
+                       if (!in_array('delete', $this->disabledItems, TRUE) && $fileObject->checkActionPermission('delete')) {
                                if ($isStorageRoot && $userMayEditStorage) {
                                        $elInfo = array(GeneralUtility::fixed_lgd_cs($fileObject->getStorage()->getName(), $this->backendUser->uc['titleLen']));
                                        $menuItems['delete'] = $this->DB_delete('sys_file_storage', $fileObject->getStorage()->getUid(), $elInfo);
                                if ($isStorageRoot && $userMayEditStorage) {
                                        $elInfo = array(GeneralUtility::fixed_lgd_cs($fileObject->getStorage()->getName(), $this->backendUser->uc['titleLen']));
                                        $menuItems['delete'] = $this->DB_delete('sys_file_storage', $fileObject->getStorage()->getUid(), $elInfo);