From bde83e6b8fc090654deaac827b342cea0b69695d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 3 May 2024 15:30:53 +0200 Subject: [PATCH] Remove `downloads` and `lastDownloadTime` These have been meaningless metrics for most of the time and also do not play nicely with the efficient distribution of files. --- ts/WoltLabSuite/Core/Component/File/Upload.ts | 3 ++- .../install/files/acp/templates/attachmentList.tpl | 4 ---- .../js/WoltLabSuite/Core/Component/File/Upload.js | 4 ++-- .../files/lib/acp/page/AttachmentListPage.class.php | 2 +- .../files/lib/data/attachment/Attachment.class.php | 12 ++++++++++-- wcfsetup/install/lang/de.xml | 2 -- wcfsetup/install/lang/en.xml | 2 -- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ts/WoltLabSuite/Core/Component/File/Upload.ts b/ts/WoltLabSuite/Core/Component/File/Upload.ts index 0347930376..00f57b33f9 100644 --- a/ts/WoltLabSuite/Core/Component/File/Upload.ts +++ b/ts/WoltLabSuite/Core/Component/File/Upload.ts @@ -9,6 +9,7 @@ import { import { generateThumbnails } from "WoltLabSuite/Core/Api/Files/GenerateThumbnails"; import ImageResizer from "WoltLabSuite/Core/Image/Resizer"; import { AttachmentData } from "../Ckeditor/Attachment"; +import { innerError } from "WoltLabSuite/Core/Dom/Util"; export type CkeditorDropEvent = { file: File; @@ -184,7 +185,7 @@ function validateFile(element: WoltlabCoreFileUploadElement, file: File): boolea } } - // TODO: show an error message + innerError(element, `TODO: the file extension of '${file.name}' is not allowed`); return false; } diff --git a/wcfsetup/install/files/acp/templates/attachmentList.tpl b/wcfsetup/install/files/acp/templates/attachmentList.tpl index 03c1c44f70..b5a71d5d76 100644 --- a/wcfsetup/install/files/acp/templates/attachmentList.tpl +++ b/wcfsetup/install/files/acp/templates/attachmentList.tpl @@ -95,8 +95,6 @@ {lang}wcf.attachment.filename{/lang} {lang}wcf.attachment.uploadTime{/lang} {lang}wcf.attachment.filesize{/lang} - {lang}wcf.attachment.downloads{/lang} - {lang}wcf.attachment.lastDownloadTime{/lang} {event name='columnHeads'} @@ -130,8 +128,6 @@ {@$attachment->uploadTime|time} {@$attachment->filesize|filesize} - {#$attachment->downloads} - {if $attachment->lastDownloadTime}{@$attachment->lastDownloadTime|time}{/if} {event name='columns'} diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js index 2c1395fd68..d7bde8c01f 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js @@ -1,4 +1,4 @@ -define(["require", "exports", "tslib", "WoltLabSuite/Core/Helper/Selector", "WoltLabSuite/Core/Api/Files/Upload", "WoltLabSuite/Core/Api/Files/Chunk/Chunk", "WoltLabSuite/Core/Api/Files/GenerateThumbnails", "WoltLabSuite/Core/Image/Resizer"], function (require, exports, tslib_1, Selector_1, Upload_1, Chunk_1, GenerateThumbnails_1, Resizer_1) { +define(["require", "exports", "tslib", "WoltLabSuite/Core/Helper/Selector", "WoltLabSuite/Core/Api/Files/Upload", "WoltLabSuite/Core/Api/Files/Chunk/Chunk", "WoltLabSuite/Core/Api/Files/GenerateThumbnails", "WoltLabSuite/Core/Image/Resizer", "WoltLabSuite/Core/Dom/Util"], function (require, exports, tslib_1, Selector_1, Upload_1, Chunk_1, GenerateThumbnails_1, Resizer_1, Util_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setup = void 0; @@ -116,7 +116,7 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Helper/Selector", "Wol return true; } } - // TODO: show an error message + (0, Util_1.innerError)(element, `TODO: the file extension of '${file.name}' is not allowed`); return false; } function setup() { diff --git a/wcfsetup/install/files/lib/acp/page/AttachmentListPage.class.php b/wcfsetup/install/files/lib/acp/page/AttachmentListPage.class.php index 4bd75017b9..71b4ebf810 100644 --- a/wcfsetup/install/files/lib/acp/page/AttachmentListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/AttachmentListPage.class.php @@ -43,7 +43,7 @@ class AttachmentListPage extends SortablePage /** * @inheritDoc */ - public $validSortFields = ['attachmentID', 'filename', 'filesize', 'downloads', 'uploadTime', 'lastDownloadTime']; + public $validSortFields = ['attachmentID', 'filename', 'filesize', 'uploadTime']; /** * @inheritDoc diff --git a/wcfsetup/install/files/lib/data/attachment/Attachment.class.php b/wcfsetup/install/files/lib/data/attachment/Attachment.class.php index de414d1b7f..0313d16318 100644 --- a/wcfsetup/install/files/lib/data/attachment/Attachment.class.php +++ b/wcfsetup/install/files/lib/data/attachment/Attachment.class.php @@ -40,8 +40,6 @@ use wcf\util\FileUtil; * @property-read int $thumbnailSize size of the thumbnail file for the attachment if `$isImage` is `1`, otherwise `0` * @property-read int $thumbnailWidth width of the thumbnail file for the attachment if `$isImage` is `1`, otherwise `0` * @property-read int $thumbnailHeight height of the thumbnail file for the attachment if `$isImage` is `1`, otherwise `0` - * @property-read int $downloads number of times the attachment has been downloaded - * @property-read int $lastDownloadTime timestamp at which the attachment has been downloaded the last time * @property-read int $uploadTime timestamp at which the attachment has been uploaded * @property-read int $showOrder position of the attachment in relation to the other attachment to the same message * @property-read int|null $fileID @@ -384,6 +382,16 @@ class Attachment extends DatabaseObject implements ILinkableObject, IRouteContro #[\Override] public function __get($name) { + // Deprecated attributes that are no longer supported. + $value = match ($name) { + 'downloads' => 0, + 'lastDownloadTime' => 0, + default => null, + }; + if ($value !== null) { + return $value; + } + $file = $this->getFile(); if ($file === null) { return parent::__get($name); diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index bd43d2bad6..2c44c8eaeb 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -3352,8 +3352,6 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExt - - diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index e89ef7358a..7b1e9b857d 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -3277,8 +3277,6 @@ Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensi - - -- 2.20.1