Project

General

Profile

Actions

Bug #81308

closed

Epic #83669: Improve file list / file browser

Deleting a referenced file via filelist module, definined in sys_file_metadata

Added by Sascha Maier almost 7 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2017-05-22
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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.


Files

sys_file_metadata_file_reference.png (4.05 KB) sys_file_metadata_file_reference.png Sascha Maier, 2017-05-22 22:38
patch.diff (1.21 KB) patch.diff Sascha Maier, 2017-05-23 08:53

Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #71319: IRRE in sys_file_metadata doesn't work for normal usersClosed2015-11-04

Actions
Related to TYPO3 Core - Bug #75332: Saving relations to files in sys_file_metadata does not work for normal usersClosed2016-03-31

Actions
Related to TYPO3 Core - Bug #75748: Editor can't remove images attached to other imagesClosed2016-04-18

Actions
Actions

Also available in: Atom PDF