Merge pull request #25935 from nextcloud/backport/25926/stable21

[stable21] Activity: show if files are hidden or not
This commit is contained in:
Roeland Jago Douma 2021-03-05 14:29:22 +01:00 committed by GitHub
commit d81954f913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 2 deletions

View 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) {