Issue Bug Closed

#81308Deleting a referenced file via filelist module, definined in sys_file_metadata

Sascha Maier 05/22/17, 22:45 updated 02/04/18, 16:01

Description

We extended the sys_file_metadata table to add references to existing files in normal filelist entries. For admin Users everything is ok. Unfortunately for non-admin users the “delete” button to remove the reference is missing.

Our TCA changes:

<?php

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_file_metadata', array(
    'attachments' => array(
        'exclude' => 1,
        'label' => 'LLL:EXT:as_formular_center/Resources/Private/Language/locallang_be.xlf:sys_file_metadata.as_attachments',
        'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
            'files',
            array(
                'appearance' => array(
                    'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:files.addFileReference'
                )
            )
        )
    )
));
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('sys_file_metadata', 'attachments', '', 'after:source');

Applied the following changes and the button is shown:

diff --git a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
index a67800777d..835bc8b470 100644
--- a/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
+++ b/typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
@@ -525,7 +525,11 @@ class InlineRecordContainer extends AbstractContainer
             // "Delete" link:
             if ($enabledControls['delete'] && ($isPagesTable && $localCalcPerms & Permission::PAGE_DELETE
                     || !$isPagesTable && $calcPerms & Permission::CONTENT_EDIT
-                    || $isSysFileReferenceTable && $calcPerms & Permission::PAGE_EDIT)
+                    || $isSysFileReferenceTable  && (
+                        ( $calcPerms & Permission::PAGE_EDIT )
+                        || ( $rec['table_local'] === 'sys_file' && $rec ['pid'] === 0)
+                    )
+                )
             ) {
                 $title = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:delete'));
                 $icon = $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render();

Problem is, calPerms will not work on rows with pid == 0.

sys_file_metadata_file_reference.png

Reviews 1