]> source.dussan.org Git - nextcloud-server.git/commitdiff
Activity: show if files are hidden or not 25934/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Thu, 4 Mar 2021 12:14:52 +0000 (13:14 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 4 Mar 2021 16:04:27 +0000 (16:04 +0000)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/files/lib/Activity/Provider.php

index 2f6e406978a80f97424e2288c14777078a1f93e2..f50d9d6a42a6bb5db0a2a4f26d167938ded742aa 100644 (file)
@@ -230,10 +230,42 @@ class Provider implements IProvider {
                        $subject = $this->l->t('{user} restored {file}');
                        $this->setIcon($event, 'actions/history', 'core');
                } elseif ($event->getSubject() === 'renamed_self') {
-                       $subject = $this->l->t('You renamed {oldfile} to {newfile}');
+                       $oldFileName = $parsedParameters['oldfile']['name'];
+                       $newFileName = $parsedParameters['newfile']['name'];
+
+                       if ($this->isHiddenFile($oldFileName)) {
+                               if ($this->isHiddenFile($newFileName)) {
+                                       $subject = $this->l->t('You renamed {oldfile} (hidden) to {newfile} (hidden)');
+                               } else {
+                                       $subject = $this->l->t('You renamed {oldfile} (hidden) to {newfile}');
+                               }
+                       } else {
+                               if ($this->isHiddenFile($newFileName)) {
+                                       $subject = $this->l->t('You renamed {oldfile} to {newfile} (hidden)');
+                               } else {
+                                       $subject = $this->l->t('You renamed {oldfile} to {newfile}');
+                               }
+                       }
+
                        $this->setIcon($event, 'change');
                } elseif ($event->getSubject() === 'renamed_by') {
-                       $subject = $this->l->t('{user} renamed {oldfile} to {newfile}');
+                       $oldFileName = $parsedParameters['oldfile']['name'];
+                       $newFileName = $parsedParameters['newfile']['name'];
+
+                       if ($this->isHiddenFile($oldFileName)) {
+                               if ($this->isHiddenFile($newFileName)) {
+                                       $subject = $this->l->t('{user} renamed {oldfile} (hidden) to {newfile} (hidden)');
+                               } else {
+                                       $subject = $this->l->t('{user} renamed {oldfile} (hidden) to {newfile}');
+                               }
+                       } else {
+                               if ($this->isHiddenFile($newFileName)) {
+                                       $subject = $this->l->t('{user} renamed {oldfile} to {newfile} (hidden)');
+                               } else {
+                                       $subject = $this->l->t('{user} renamed {oldfile} to {newfile}');
+                               }
+                       }
+
                        $this->setIcon($event, 'change');
                } elseif ($event->getSubject() === 'moved_self') {
                        $subject = $this->l->t('You moved {oldfile} to {newfile}');
@@ -270,6 +302,10 @@ class Provider implements IProvider {
                return $event;
        }
 
+       private function isHiddenFile(string $filename): bool {
+               return strlen($filename) > 0 && $filename[0] === '.';
+       }
+
        protected function setSubjects(IEvent $event, $subject, array $parameters) {
                $placeholders = $replacements = [];
                foreach ($parameters as $placeholder => $parameter) {