From 5fa6f166d4d8f6a3a36d2e4a5e7c6d47f5e486d1 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Tue, 14 Jan 2025 11:13:41 +0100 Subject: add display parameter --- app/views/file/_file_aside.php | 2 +- app/views/files/index.php | 2 +- lib/filesystem/FolderType.php | 2 +- lib/filesystem/InboxOutboxFolder.php | 2 +- lib/filesystem/PermissionEnabledFolder.php | 4 ++-- lib/filesystem/StandardFolder.php | 4 ++-- lib/filesystem/UnknownFolderType.php | 2 +- lib/filesystem/VirtualFolderType.php | 2 +- lib/models/FileRef.php | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/views/file/_file_aside.php b/app/views/file/_file_aside.php index 5229655..bc71f1a 100644 --- a/app/views/file/_file_aside.php +++ b/app/views/file/_file_aside.php @@ -16,7 +16,7 @@ getSize() ?> getSize(), false) : "-" ?> - getFolderType()->countDownloads($file->getFileRef())): ?> + getFolderType()->countDownloads($file->getFileRef(), true)): ?> getDownloads()) ?> diff --git a/app/views/files/index.php b/app/views/files/index.php index 0f5c566..c14c0a9 100644 --- a/app/views/files/index.php +++ b/app/views/files/index.php @@ -15,7 +15,7 @@ } $show_downloads = Config::get()->DISPLAY_DOWNLOAD_COUNTER === 'always' - && $topFolder->countDownloads(); + && $topFolder->countDownloads(display: true); $vue_breadcrumbs = []; $folder = $topFolder; do { diff --git a/lib/filesystem/FolderType.php b/lib/filesystem/FolderType.php index 4b0501a..4c548bd 100644 --- a/lib/filesystem/FolderType.php +++ b/lib/filesystem/FolderType.php @@ -295,5 +295,5 @@ interface FolderType * If a specific file ref is passed, you may decide whether to count the * download for this file ref or not. */ - public function countDownloads(?FileRef $ref = null): bool; + public function countDownloads(?FileRef $ref = null, bool $display = false): bool; } diff --git a/lib/filesystem/InboxOutboxFolder.php b/lib/filesystem/InboxOutboxFolder.php index bab9253..a07d67b 100644 --- a/lib/filesystem/InboxOutboxFolder.php +++ b/lib/filesystem/InboxOutboxFolder.php @@ -314,7 +314,7 @@ class InboxOutboxFolder implements FolderType return ['description' => $this->description]; } - public function countDownloads(?FileRef $ref = null): bool + public function countDownloads(?FileRef $ref = null, bool $display = false): bool { return true; } diff --git a/lib/filesystem/PermissionEnabledFolder.php b/lib/filesystem/PermissionEnabledFolder.php index 032f699..c1b3d71 100644 --- a/lib/filesystem/PermissionEnabledFolder.php +++ b/lib/filesystem/PermissionEnabledFolder.php @@ -161,9 +161,9 @@ class PermissionEnabledFolder extends StandardFolder ]; } - public function countDownloads(?FileRef $ref = null): bool + public function countDownloads(?FileRef $ref = null, bool $display = false): bool { return ($this->permission & $this->perms['r']) - && parent::countDownloads($ref); + && parent::countDownloads($ref, $display); } } diff --git a/lib/filesystem/StandardFolder.php b/lib/filesystem/StandardFolder.php index 61642e9..fa7f7b3 100644 --- a/lib/filesystem/StandardFolder.php +++ b/lib/filesystem/StandardFolder.php @@ -552,9 +552,9 @@ class StandardFolder implements FolderType return ['description' => $this->description]; } - public function countDownloads(?FileRef $ref = null): bool + public function countDownloads(?FileRef $ref = null, bool $display = false): bool { - if (!$ref) { + if (!$ref || $display) { return true; } diff --git a/lib/filesystem/UnknownFolderType.php b/lib/filesystem/UnknownFolderType.php index 2cd7fd2..a2d2fce 100644 --- a/lib/filesystem/UnknownFolderType.php +++ b/lib/filesystem/UnknownFolderType.php @@ -297,7 +297,7 @@ class UnknownFolderType implements FolderType return ['description' => $this->description]; } - public function countDownloads(?FileRef $ref = null): bool + public function countDownloads(?FileRef $ref = null, bool $display = false): bool { return true; } diff --git a/lib/filesystem/VirtualFolderType.php b/lib/filesystem/VirtualFolderType.php index 0e2c2b4..11d544c 100644 --- a/lib/filesystem/VirtualFolderType.php +++ b/lib/filesystem/VirtualFolderType.php @@ -323,7 +323,7 @@ class VirtualFolderType implements FolderType return ['description' => $this->description]; } - public function countDownloads(?FileRef $ref = null): bool + public function countDownloads(?FileRef $ref = null, bool $display = false): bool { return true; } diff --git a/lib/models/FileRef.php b/lib/models/FileRef.php index eeedf26..aba20ee 100644 --- a/lib/models/FileRef.php +++ b/lib/models/FileRef.php @@ -223,7 +223,7 @@ class FileRef extends SimpleORMap implements PrivacyObject, FeedbackRange */ public function incrementDownloadCounter() { - if (!$this->folder->getTypedFolder()->countDownloads($this)) { + if (!$this->folder->getTypedFolder()->countDownloads($this, false)) { return 0; } -- cgit v1.0