Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unknown-author feature #728

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions controller/editorcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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
Expand All @@ -218,6 +220,7 @@ public function SaveCommon($defFormats,
$chat,
$compactHeader,
$feedback,
$unknownAuthor,
$forcesave,
$help,
$toolbarNoTabs,
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -220,6 +221,7 @@
chat: chat,
compactHeader: compactHeader,
feedback: feedback,
unknownAuthor: onlyofficeUnknownAuthor,
forcesave: forcesave,
help: help,
toolbarNoTabs: toolbarNoTabs,
Expand Down
26 changes: 26 additions & 0 deletions lib/appconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down
3 changes: 3 additions & 0 deletions templates/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@
<a target="_blank" class="icon-info svg" title="" href="https://api.onlyoffice.com/editors/config/editor/customization" data-original-title="<?php p($l->t("View details")) ?>"></a>
</h2>

<p><?php p($l->t("Unknown author display name")) ?></p>
<p><input id="onlyofficeUnknownAuthor" value="<?php p($_["unknownAuthor"]) ?>" placeholder="<no-data>" type="text"></p>

<p>
<input type="checkbox" class="checkbox" id="onlyofficeForcesave"
<?php if ($_["forcesave"]) { ?>checked="checked"<?php } ?> />
Expand Down