[BUGFIX] If User TSConfig disables avatar it gets lost when saved 60/51860/4
authorThomas Hohn <thomas@hohn.dk>
Sun, 26 Feb 2017 11:01:33 +0000 (12:01 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 26 Feb 2017 17:52:22 +0000 (18:52 +0100)
If the user is not allow to modify the avatar it gets
lost since there was no distinction between deleted and
not allowed to modify causing the avatar to be deleted
on save.

Resolves: #80002
Releases: master
Change-Id: I1cf6fa93c2af1122c481b52860990c2433d86594
Reviewed-on: https://review.typo3.org/51860
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <no-reply@typo3.com>
typo3/sysext/setup/Classes/Controller/SetupModuleController.php

index 78bcc7e..64ea541 100644 (file)
@@ -960,6 +960,11 @@ class SetupModuleController extends AbstractModule
             return;
         }
 
+        // If user is not allowed to modify avatar $fileUid is empty - so don't overwrite existing avatar
+        if (empty($fileUid)) {
+            return;
+        }
+
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file_reference');
         $queryBuilder->getRestrictions()->removeAll();
         $queryBuilder
@@ -984,6 +989,11 @@ class SetupModuleController extends AbstractModule
             )
             ->execute();
 
+        // If Avatar is marked for delete => set it to empty string so it will be updated properly
+        if ($fileUid === 'delete') {
+            $fileUid = '';
+        }
+
         // Create new reference
         if ($fileUid) {
 
@@ -1035,7 +1045,7 @@ class SetupModuleController extends AbstractModule
             function clearExistingImage() {
                 $(' . GeneralUtility::quoteJSvalue('#image_' . htmlspecialchars($fieldName)) . ').hide();
                 $(' . GeneralUtility::quoteJSvalue('#clear_button_' . htmlspecialchars($fieldName)) . ').hide();
-                $(' . GeneralUtility::quoteJSvalue('#field_' . htmlspecialchars($fieldName)) . ').val(\'\');
+                $(' . GeneralUtility::quoteJSvalue('#field_' . htmlspecialchars($fieldName)) . ').val(\'delete\');
             }
 
             function setFileUid(field, value, fileUid) {