Skip to content

Commit 56b02b5

Browse files
committed
Merge remote-tracking branch 'remotes/origin/feature/extend-watermark-placeholders' into develop
2 parents 2aab7d5 + cb00b56 commit 56b02b5

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- replaced general save success message with dedicated messages for each settings section
99
- show warning popup when jwt secret is empty and success message otherwise
1010
- download all document pages when converting to image types with Download As method
11+
- extend supported watermark placeholders
1112

1213
## Added
1314
- plugin description and useful links in admin settings

lib/Controller/EditorApiController.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok
603603

604604
$params = $this->setCustomization($params);
605605

606-
$params = $this->setWatermark($params, !empty($shareToken), $userId, $file);
606+
$params = $this->setWatermark($params, !empty($shareToken), $user, $file);
607607

608608
if ($this->config->useDemo()) {
609609
$params["editorConfig"]["tenant"] = $this->config->getSystemValue("instanceid", true);
@@ -840,12 +840,12 @@ private function setCustomization($params) {
840840
*
841841
* @param array params - file parameters
842842
* @param bool isPublic - with access token
843-
* @param string userId - user identifier
843+
* @param IUser $user - current user
844844
* @param string file - file
845845
*
846846
* @return array
847847
*/
848-
private function setWatermark($params, $isPublic, $userId, $file) {
848+
private function setWatermark($params, $isPublic, $user, $file) {
849849
$watermarkTemplate = $this->getWatermarkText(
850850
$isPublic,
851851
$userId,
@@ -855,13 +855,22 @@ private function setWatermark($params, $isPublic, $userId, $file) {
855855
);
856856

857857
if ($watermarkTemplate !== false) {
858-
if (empty($userId)) {
858+
if (empty($user)) {
859+
$userId = $this->trans->t('Anonymous');
860+
$userDisplayName = $this->trans->t('Anonymous');
861+
$email = $this->trans->t('Anonymous');
859862
$timezone = $this->timezoneService->getDefaultTimezone();
860863
} else {
864+
$userId = $user->getUID();
865+
$userDisplayName = $user->getDisplayName();
866+
$email = $user->getEMailAddress();
861867
$timezone = $this->timezoneService->getUserTimezone($userId) ?? $this->timezoneService->getDefaultTimezone();
862868
}
869+
863870
$replacements = [
864-
"userId" => isset($userId) ? $userId : $this->trans->t('Anonymous'),
871+
"userId" => $userId,
872+
"userDisplayName" => $userDisplayName,
873+
"email" => $email,
865874
"date" => (new \DateTime("now", new \DateTimeZone($timezone)))->format("Y-m-d H:i:s"),
866875
"themingName" => \OC::$server->getThemingDefaults()->getName()
867876
];

templates/settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@
372372
<br />
373373
<p><?php p($l->t("Watermark text")) ?></p>
374374
<br />
375-
<p class="settings-hint"><?php p($l->t("Supported placeholders")) ?>: {userId}, {date}, {themingName}</p>
375+
<p class="settings-hint"><?php p($l->t("Supported placeholders")) ?>: {userId}, {userDisplayName}, {email}, {date}, {themingName}</p>
376376
<p><input id="onlyofficeWatermark_text" value="<?php p($_["watermark"]["text"]) ?>" placeholder="<?php p($l->t("DO NOT SHARE THIS")) ?> {userId} {date}" type="text"></p>
377377

378378
<br />

0 commit comments

Comments
 (0)