[TASK] Filelist: Renaming: Add a better flash message 03/51203/3
authorJosef Glatz <josefglatz@gmail.com>
Sun, 8 Jan 2017 23:01:08 +0000 (00:01 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 11 Jan 2017 21:16:50 +0000 (22:16 +0100)
Just add another/meaningful message to the flash message
queue if the file/folder was not really renamed. It just gives a
better feedback to the backend user.

Resolves: #79206
Releases: master
Change-Id: Id2378fdd0f24a94c2260cff9fd7e2cb8feb40eaf
Reviewed-on: https://review.typo3.org/51203
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/File/ExtendedFileUtility.php
typo3/sysext/core/Resources/Private/Language/fileMessages.xlf

index d5c3b22..feae8b8 100644 (file)
@@ -844,7 +844,11 @@ class ExtendedFileUtility extends BasicFileUtility
                 // Try to rename the File
                 $resultObject = $sourceFileObject->rename($targetFile);
                 $this->writeLog(5, 0, 1, 'File renamed from "%s" to "%s"', [$sourceFile, $targetFile]);
-                $this->addMessageToFlashMessageQueue('FileUtility.FileRenamedFromTo', [$sourceFile, $targetFile], FlashMessage::OK);
+                if ($sourceFile === $targetFile) {
+                    $this->addMessageToFlashMessageQueue('FileUtility.FileRenamedSameName', [$sourceFile], FlashMessage::INFO);
+                } else {
+                    $this->addMessageToFlashMessageQueue('FileUtility.FileRenamedFromTo', [$sourceFile, $targetFile], FlashMessage::OK);
+                }
             } catch (InsufficientUserPermissionsException $e) {
                 $this->writeLog(5, 1, 102, 'You are not allowed to rename files!', []);
                 $this->addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameFiles');
@@ -867,7 +871,11 @@ class ExtendedFileUtility extends BasicFileUtility
                 // Try to rename the Folder
                 $resultObject = $sourceFileObject->rename($targetFile);
                 $this->writeLog(5, 0, 2, 'Directory renamed from "%s" to "%s"', [$sourceFile, $targetFile]);
-                $this->addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromTo', [$sourceFile, $targetFile], FlashMessage::OK);
+                if ($sourceFile === $targetFile) {
+                    $this->addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedSameName', [$sourceFile], FlashMessage::INFO);
+                } else {
+                    $this->addMessageToFlashMessageQueue('FileUtility.DirectoryRenamedFromTo', [$sourceFile, $targetFile], FlashMessage::OK);
+                }
             } catch (InsufficientUserPermissionsException $e) {
                 $this->writeLog(5, 1, 111, 'You are not allowed to rename directories!', []);
                 $this->addMessageToFlashMessageQueue('FileUtility.YouAreNotAllowedToRenameDirectories');
index 17843ab..c0b5b17 100644 (file)
@@ -45,6 +45,9 @@
                        <trans-unit id="FileUtility.DirectoryRenamedFromTo">
                                <source>Directory renamed from "%s" to "%s".</source>
                        </trans-unit>
+                       <trans-unit id="FileUtility.DirectoryRenamedSameName">
+                               <source>Directory "%s" was not renamed. (Same name as before)</source>
+                       </trans-unit>
                        <trans-unit id="FileUtility.DirectoryWasNotCopiedTo">
                                <source>Directory "%s" WAS NOT copied to "%s"! There might be a problem with write permissions</source>
                        </trans-unit>
@@ -96,6 +99,9 @@
                        <trans-unit id="FileUtility.FileRenamedFromTo">
                                <source>File renamed from "%s" to "%s".</source>
                        </trans-unit>
+                       <trans-unit id="FileUtility.FileRenamedSameName">
+                               <source>File "%s" was not renamed. (Same name as before)</source>
+                       </trans-unit>
                        <trans-unit id="FileUtility.FileSavedToBytesMd5">
                                <source>File saved to "%s", bytes: %s, MD5: %s.</source>
                        </trans-unit>