From 49ce46879d0daf867d89eb8f25f43b393c0019e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=BE=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=B8=D1=82=D0=B0?= Date: Tue, 25 Oct 2022 10:39:10 +0300 Subject: [PATCH] Add unknown-author feature --- controller/editorcontroller.php | 4 ++-- controller/settingscontroller.php | 4 ++++ js/settings.js | 2 ++ lib/appconfig.php | 26 ++++++++++++++++++++++++++ templates/settings.php | 3 +++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 80b25d3d..8c41c412 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -753,8 +753,8 @@ public function history($fileId) { $versionId = $version->getRevisionId(); $author = FileVersions::getAuthor($ownerId, $fileId, $versionId); - $authorId = $author !== null ? $author["id"] : $ownerId; - $authorName = $author !== null ? $author["name"] : $owner->getDisplayName(); + $authorId = $author !== null ? $author["id"] : $this->config->GetUnknownAuthor(); + $authorName = $author !== null ? $author["name"] : $this->config->GetUnknownAuthor(); $historyItem["user"] = [ "id" => $this->buildUserId($authorId), diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 9768b2b8..e7b80a6f 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -122,6 +122,7 @@ public function index() { "chat" => $this->config->GetCustomizationChat(), "compactHeader" => $this->config->GetCustomizationCompactHeader(), "feedback" => $this->config->GetCustomizationFeedback(), + "unknownAuthor" => $this->config->GetUnknownAuthor(), "forcesave" => $this->config->GetCustomizationForcesave(), "help" => $this->config->GetCustomizationHelp(), "toolbarNoTabs" => $this->config->GetCustomizationToolbarNoTabs(), @@ -201,6 +202,7 @@ public function SaveAddress($documentserver, * @param bool $chat - display chat * @param bool $compactHeader - display compact header * @param bool $feedback - display feedback + * @param string $unknownAuthor - unknownAuthor display name * @param bool $forcesave - forcesave * @param bool $help - display help * @param bool $toolbarNoTabs - display toolbar tab @@ -218,6 +220,7 @@ public function SaveCommon($defFormats, $chat, $compactHeader, $feedback, + $unknownAuthor, $forcesave, $help, $toolbarNoTabs, @@ -235,6 +238,7 @@ public function SaveCommon($defFormats, $this->config->SetCustomizationChat($chat); $this->config->SetCustomizationCompactHeader($compactHeader); $this->config->SetCustomizationFeedback($feedback); + $this->config->SetUnknownAuthor($unknownAuthor); $this->config->SetCustomizationForcesave($forcesave); $this->config->SetCustomizationHelp($help); $this->config->SetCustomizationToolbarNoTabs($toolbarNoTabs); diff --git a/js/settings.js b/js/settings.js index 87adadcb..f02f6268 100644 --- a/js/settings.js +++ b/js/settings.js @@ -200,6 +200,7 @@ var chat = $("#onlyofficeChat").is(":checked"); var compactHeader = $("#onlyofficeCompactHeader").is(":checked"); var feedback = $("#onlyofficeFeedback").is(":checked"); + var onlyofficeUnknownAuthor = ($("#onlyofficeUnknownAuthor:visible").val()).trim(); var forcesave = $("#onlyofficeForcesave").is(":checked"); var help = $("#onlyofficeHelp").is(":checked"); var toolbarNoTabs = $("#onlyofficeToolbarNoTabs").is(":checked"); @@ -220,6 +221,7 @@ chat: chat, compactHeader: compactHeader, feedback: feedback, + unknownAuthor: onlyofficeUnknownAuthor, forcesave: forcesave, help: help, toolbarNoTabs: toolbarNoTabs, diff --git a/lib/appconfig.php b/lib/appconfig.php index b3d0af4b..80f5d636 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -130,6 +130,13 @@ class AppConfig { */ private $_versionHistory = "versionHistory"; + /** + * Display name of the unknown author + * + * @var string + */ + private $_unknownAuthor = "unknownAuthor"; + /** * The config key for the chat display setting * @@ -1096,6 +1103,25 @@ public function GetLimitThumbSize() { return 100*1024*1024; } + /** + * Save unknownAuthor setting + * + * @param string $value - unknownAuthor + */ + public function SetUnknownAuthor($value) { + $this->logger->info("Set unknownAuthor: " . trim($value), ["app" => $this->appName]); + $this->config->setAppValue($this->appName, $this->_unknownAuthor, trim($value)); + } + + /** + * Get unknownAuthor setting + * + * @return bool + */ + public function GetUnknownAuthor() { + return $this->config->getAppValue($this->appName, $this->_unknownAuthor, "< no-data >"); + } + /** * Get the jwt header setting * diff --git a/templates/settings.php b/templates/settings.php index fd9d0d88..734a33a4 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -165,6 +165,9 @@ "> +

t("Unknown author display name")) ?>

+

" placeholder="" type="text">

+

checked="checked" />