From 2045dd447fa8f6e6b837fbdde0d681aff6631ee8 Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Fri, 11 Aug 2023 19:51:03 +0200 Subject: [PATCH 001/209] Fix no user object provided --- lib/Controller/EditorApiController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Controller/EditorApiController.php b/lib/Controller/EditorApiController.php index b8a50e1c..6edb60d1 100644 --- a/lib/Controller/EditorApiController.php +++ b/lib/Controller/EditorApiController.php @@ -606,6 +606,10 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok * @return array */ private function getFile($userId, $fileId, $filePath = null, $template = false) { + if (empty($userId)) { + return [null, $this->trans->t("UserId is empty"), null]; + } + if (empty($fileId)) { return [null, $this->trans->t("FileId is empty"), null]; } From f87de5a2c2b35c5a22cff444e0c79578e62f7f34 Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 15 Aug 2023 12:35:32 +0300 Subject: [PATCH 002/209] userId added to setUsers() --- controller/editorcontroller.php | 3 ++- js/editor.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index a0f88381..d3f8c83b 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -414,7 +414,8 @@ public function users($fileId) { if ($user->getUID() != $currentUserId && !empty($email)) { array_push($result, [ "email" => $email, - "name" => $user->getDisplayName() + "name" => $user->getDisplayName(), + "id" => $user->getUID() ]); } } diff --git a/js/editor.js b/js/editor.js index 43978446..2b976675 100644 --- a/js/editor.js +++ b/js/editor.js @@ -514,6 +514,7 @@ }), function onSuccess(response) { OCA.Onlyoffice.docEditor.setUsers({ + "c": typeof(event.data.c) !== "undefined" ? event.data.c : null, "users": response }); }); From 92e8e41635bbb128897476d76022e9067de8c70f Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 28 Jul 2023 13:16:51 +0300 Subject: [PATCH 003/209] log user on request from documentserver --- controller/callbackcontroller.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 8bbfa0bc..4ad9118f 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -238,6 +238,10 @@ public function download($doc) { $userId = null; $user = null; + if ($this->userSession->isLoggedIn()) { + $this->logger->debug("Download: by $userId instead of " . $hashData->userId, ["app" => $this->appName]); + } + \OC_Util::tearDownFS(); if (isset($hashData->userId)) { @@ -258,6 +262,9 @@ public function download($doc) { } if (!empty($user) && !$file->isReadable()) { + if ($this->userSession->getUID() != $userId) { + $this->logger->error("Download error: expected $userId instead of " . $this->userSession->getUID(), ["app" => $this->appName]); + } $this->logger->error("Download without access right", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); } From b53ab6d05ad81b39ffb63430669f19c61aae51df Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 4 Oct 2023 12:04:36 +0300 Subject: [PATCH 004/209] PSR2 standard --- controller/callbackcontroller.php | 80 ++++--- controller/editorapicontroller.php | 90 ++++---- controller/editorcontroller.php | 115 ++++++---- controller/federationcontroller.php | 31 +-- controller/joblistcontroller.php | 20 +- controller/settingscontroller.php | 92 ++++---- controller/sharingapicontroller.php | 31 +-- controller/templatecontroller.php | 30 +-- .../Version070000Date20210417111111.php | 106 ++++----- .../Version070400Date20220607111111.php | 140 ++++++------ .../Version070400Date20220929111111.php | 182 ++++++++-------- lib/adminsection.php | 18 +- lib/adminsettings.php | 15 +- lib/appconfig.php | 201 ++++++++++++------ lib/command/documentserver.php | 33 +-- lib/cron/editorscheck.php | 32 +-- lib/crypt.php | 12 +- lib/directeditor.php | 41 ++-- lib/documentservice.php | 39 ++-- lib/extrapermissions.php | 48 +++-- lib/filecreator.php | 30 ++- lib/fileutility.php | 41 ++-- lib/fileversions.php | 66 +++--- lib/hooks.php | 26 ++- lib/keymanager.php | 24 ++- lib/listeners/directeditorlistener.php | 14 +- lib/listeners/filesharinglistener.php | 16 +- lib/listeners/fileslistener.php | 16 +- lib/listeners/viewerlistener.php | 16 +- lib/listeners/widgetlistener.php | 11 +- lib/notifier.php | 26 ++- lib/preview.php | 50 +++-- lib/remoteinstance.php | 26 ++- lib/settingsdata.php | 11 +- lib/templatemanager.php | 30 ++- lib/templateprovider.php | 14 +- 36 files changed, 1050 insertions(+), 723 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 8bbfa0bc..ecc547b9 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -60,7 +60,8 @@ * Download the file without authentication. * Save the file without authentication. */ -class CallbackController extends Controller { +class CallbackController extends Controller +{ /** * Root folder @@ -155,18 +156,19 @@ class CallbackController extends Controller { * @param IManager $shareManager - Share manager * @param ILockManager $lockManager - Lock manager */ - public function __construct($AppName, - IRequest $request, - IRootFolder $root, - IUserSession $userSession, - IUserManager $userManager, - IL10N $trans, - ILogger $logger, - AppConfig $config, - Crypt $crypt, - IManager $shareManager, - ILockManager $lockManager - ) { + public function __construct( + $AppName, + IRequest $request, + IRootFolder $root, + IUserSession $userSession, + IUserManager $userManager, + IL10N $trans, + ILogger $logger, + AppConfig $config, + Crypt $crypt, + IManager $shareManager, + ILockManager $lockManager + ) { parent::__construct($AppName, $request); $this->root = $root; @@ -201,9 +203,10 @@ public function __construct($AppName, * @PublicPage * @CORS */ - public function download($doc) { + public function download($doc) + { - list ($hashData, $error) = $this->crypt->ReadHash($doc); + list($hashData, $error) = $this->crypt->ReadHash($doc); if ($hashData === null) { $this->logger->error("Download with empty or not correct hash: $error", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -251,7 +254,7 @@ public function download($doc) { } $shareToken = isset($hashData->shareToken) ? $hashData->shareToken : null; - list ($file, $error) = empty($shareToken) ? $this->getFile($userId, $fileId, null, $changes ? null : $version, $template) : $this->getFileByToken($fileId, $shareToken, $changes ? null : $version); + list($file, $error) = empty($shareToken) ? $this->getFile($userId, $fileId, null, $changes ? null : $version, $template) : $this->getFileByToken($fileId, $shareToken, $changes ? null : $version); if (isset($error)) { return $error; @@ -325,10 +328,11 @@ public function download($doc) { * @PublicPage * @CORS */ - public function emptyfile($doc) { + public function emptyfile($doc) + { $this->logger->debug("Download empty", ["app" => $this->appName]); - list ($hashData, $error) = $this->crypt->ReadHash($doc); + list($hashData, $error) = $this->crypt->ReadHash($doc); if ($hashData === null) { $this->logger->error("Download empty with empty or not correct hash: $error", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -394,9 +398,10 @@ public function emptyfile($doc) { * @PublicPage * @CORS */ - public function track($doc, $users, $key, $status, $url, $token, $history, $changesurl, $forcesavetype, $actions, $filetype) { + public function track($doc, $users, $key, $status, $url, $token, $history, $changesurl, $forcesavetype, $actions, $filetype) + { - list ($hashData, $error) = $this->crypt->ReadHash($doc); + list($hashData, $error) = $this->crypt->ReadHash($doc); if ($hashData === null) { $this->logger->error("Track with empty or not correct hash: $error", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -501,10 +506,10 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan \OC_Util::setupFS($userId); } - list ($file, $error) = empty($shareToken) ? $this->getFile($userId, $fileId, $filePath) : $this->getFileByToken($fileId, $shareToken); + list($file, $error) = empty($shareToken) ? $this->getFile($userId, $fileId, $filePath) : $this->getFileByToken($fileId, $shareToken); if (isset($error)) { - $this->logger->error("track error $fileId " . json_encode($error->getData()), ["app" => $this->appName]); + $this->logger->error("track error $fileId " . json_encode($error->getData()), ["app" => $this->appName]); return $error; } @@ -632,7 +637,8 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan * * @return array */ - private function getFile($userId, $fileId, $filePath = null, $version = 0, $template = false) { + private function getFile($userId, $fileId, $filePath = null, $version = 0, $template = false) + { if (empty($fileId)) { return [null, new JSONResponse(["message" => $this->trans->t("FileId is empty")], Http::STATUS_BAD_REQUEST)]; } @@ -672,7 +678,7 @@ private function getFile($userId, $fileId, $filePath = null, $version = 0, $temp if ($owner !== null) { if ($owner->getUID() !== $userId) { - list ($file, $error) = $this->getFile($owner->getUID(), $file->getId()); + list($file, $error) = $this->getFile($owner->getUID(), $file->getId()); if (isset($error)) { return [null, $error]; @@ -699,8 +705,9 @@ private function getFile($userId, $fileId, $filePath = null, $version = 0, $temp * * @return array */ - private function getFileByToken($fileId, $shareToken, $version = 0) { - list ($share, $error) = $this->getShare($shareToken); + private function getFileByToken($fileId, $shareToken, $version = 0) + { + list($share, $error) = $this->getShare($shareToken); if (isset($error)) { return [null, $error]; @@ -751,7 +758,8 @@ private function getFileByToken($fileId, $shareToken, $version = 0) { * * @return array */ - private function getShare($shareToken) { + private function getShare($shareToken) + { if (empty($shareToken)) { return [null, new JSONResponse(["message" => $this->trans->t("FileId is empty")], Http::STATUS_BAD_REQUEST)]; } @@ -778,7 +786,8 @@ private function getShare($shareToken) { * * @return string */ - private function parseUserId($userId) { + private function parseUserId($userId) + { $instanceId = $this->config->GetSystemValue("instanceid", true); $instanceId = $instanceId . "_"; @@ -794,7 +803,8 @@ private function parseUserId($userId) { * * @param File $file - file */ - private function lock($file) { + private function lock($file) + { if (!$this->lockManager->isLockProviderAvailable()) { return; } @@ -807,7 +817,8 @@ private function lock($file) { $this->logger->debug("$this->appName has locked file $fileId", ["app" => $this->appName]); } - } catch (PreConditionNotMetException | OwnerLockedException | NoLockProviderException $e) {} + } catch (PreConditionNotMetException | OwnerLockedException | NoLockProviderException $e) { + } } /** @@ -815,7 +826,8 @@ private function lock($file) { * * @param File $file - file */ - private function unlock($file) { + private function unlock($file) + { if (!$this->lockManager->isLockProviderAvailable()) { return; } @@ -826,7 +838,8 @@ private function unlock($file) { $this->lockManager->unlock(new LockContext($file, ILock::TYPE_APP, $this->appName)); $this->logger->debug("$this->appName has unlocked file $fileId", ["app" => $this->appName]); - } catch (PreConditionNotMetException | NoLockProviderException $e) {} + } catch (PreConditionNotMetException | NoLockProviderException $e) { + } } /** @@ -837,7 +850,8 @@ private function unlock($file) { * * @throws LockedException */ - private function retryOperation(callable $operation) { + private function retryOperation(callable $operation) + { $i = 0; while (true) { try { diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index e78796b7..0334f21f 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -57,7 +57,8 @@ /** * Controller with the main functions */ -class EditorApiController extends OCSController { +class EditorApiController extends OCSController +{ /** * Current user session @@ -171,21 +172,22 @@ class EditorApiController extends OCSController { * @param ITagManager $tagManager - Tag manager * @param ILockManager $lockManager - Lock manager */ - public function __construct($AppName, - IRequest $request, - IRootFolder $root, - IUserSession $userSession, - IUserManager $userManager, - IURLGenerator $urlGenerator, - IL10N $trans, - ILogger $logger, - AppConfig $config, - Crypt $crypt, - IManager $shareManager, - ISession $session, - ITagManager $tagManager, - ILockManager $lockManager - ) { + public function __construct( + $AppName, + IRequest $request, + IRootFolder $root, + IUserSession $userSession, + IUserManager $userManager, + IURLGenerator $urlGenerator, + IL10N $trans, + ILogger $logger, + AppConfig $config, + Crypt $crypt, + IManager $shareManager, + ISession $session, + ITagManager $tagManager, + ILockManager $lockManager + ) { parent::__construct($AppName, $request); $this->userSession = $userSession; @@ -235,10 +237,11 @@ public function __construct($AppName, * @NoAdminRequired * @PublicPage */ - public function config($fileId, $filePath = null, $shareToken = null, $directToken = null, $version = 0, $inframe = false, $inviewer = false, $desktop = false, $guestName = null, $template = false, $anchor = null) { + public function config($fileId, $filePath = null, $shareToken = null, $directToken = null, $version = 0, $inframe = false, $inviewer = false, $desktop = false, $guestName = null, $template = false, $anchor = null) + { if (!empty($directToken)) { - list ($directData, $error) = $this->crypt->ReadHash($directToken); + list($directData, $error) = $this->crypt->ReadHash($directToken); if ($directData === null) { $this->logger->error("Config for directEditor with empty or not correct hash: $error", ["app" => $this->appName]); return new JSONResponse(["error" => $this->trans->t("Not permitted")]); @@ -252,11 +255,13 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $userId = $directData->userId; if ($this->userSession->isLoggedIn() && $userId === $this->userSession->getUser()->getUID()) { - $redirectUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".editor.index", + $redirectUrl = $this->urlGenerator->linkToRouteAbsolute( + $this->appName . ".editor.index", [ "fileId" => $fileId, "filePath" => $filePath - ]); + ] + ); return new JSONResponse(["redirectUrl" => $redirectUrl]); } @@ -269,7 +274,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok } } - list ($file, $error, $share) = empty($shareToken) ? $this->getFile($userId, $fileId, $filePath, $template) : $this->fileUtility->getFileByToken($fileId, $shareToken); + list($file, $error, $share) = empty($shareToken) ? $this->getFile($userId, $fileId, $filePath, $template) : $this->fileUtility->getFileByToken($fileId, $shareToken); if (isset($error)) { $this->logger->error("Config: $fileId $error", ["app" => $this->appName]); @@ -404,7 +409,8 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $this->logger->debug("File" . $file->getId() . "is locked by $lockOwner", ["app" => $this->appName]); } } - } catch (PreConditionNotMetException | NoLockProviderException $e) {} + } catch (PreConditionNotMetException | NoLockProviderException $e) { + } } $canEdit = isset($format["edit"]) && $format["edit"]; @@ -461,7 +467,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok "id" => $this->buildUserId($userId), "name" => $user->getDisplayName() ]; - } else if (!empty($guestName)) { + } elseif (!empty($guestName)) { $params["editorConfig"]["user"] = [ "name" => $guestName ]; @@ -487,7 +493,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $folderLink = $this->urlGenerator->linkToRouteAbsolute("files_sharing.sharecontroller.showShare", $linkAttr); } } - } else if (!empty($userId)) { + } elseif (!empty($userId)) { $userFolder = $this->root->getUserFolder($userId); $folderPath = $userFolder->getRelativePath($file->getParent()->getPath()); if (!empty($folderPath)) { @@ -613,7 +619,8 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok * * @return array */ - private function getFile($userId, $fileId, $filePath = null, $template = false) { + private function getFile($userId, $fileId, $filePath = null, $template = false) + { if (empty($fileId)) { return [null, $this->trans->t("FileId is empty"), null]; } @@ -662,7 +669,8 @@ private function getFile($userId, $fileId, $filePath = null, $template = false) * * @return string */ - private function getUrl($file, $user = null, $shareToken = null, $version = 0, $changes = false, $template = false) { + private function getUrl($file, $user = null, $shareToken = null, $version = 0, $changes = false, $template = false) + { $data = [ "action" => "download", @@ -705,7 +713,8 @@ private function getUrl($file, $user = null, $shareToken = null, $version = 0, $ * * @return string */ - private function buildUserId($userId) { + private function buildUserId($userId) + { $instanceId = $this->config->GetSystemValue("instanceid", true); $userId = $instanceId . "_" . $userId; return $userId; @@ -718,7 +727,8 @@ private function buildUserId($userId) { * * @return array */ - private function setCustomization($params) { + private function setCustomization($params) + { //default is true if ($this->config->GetCustomizationChat() === false) { $params["editorConfig"]["customization"]["chat"] = false; @@ -815,10 +825,15 @@ private function setCustomization($params) { * * @return array */ - private function setWatermark($params, $isPublic, $userId, $file) { - $watermarkTemplate = $this->getWatermarkText($isPublic, $userId, $file, + private function setWatermark($params, $isPublic, $userId, $file) + { + $watermarkTemplate = $this->getWatermarkText( + $isPublic, + $userId, + $file, $params["document"]["permissions"]["edit"] !== false, - !array_key_exists("download", $params["document"]["permissions"]) || $params["document"]["permissions"]["download"] !== false); + !array_key_exists("download", $params["document"]["permissions"]) || $params["document"]["permissions"]["download"] !== false + ); if ($watermarkTemplate !== false) { $replacements = [ @@ -826,10 +841,9 @@ private function setWatermark($params, $isPublic, $userId, $file) { "date" => (new \DateTime())->format("Y-m-d H:i:s"), "themingName" => \OC::$server->getThemingDefaults()->getName() ]; - $watermarkTemplate = preg_replace_callback("/{(.+?)}/", function ($matches) use ($replacements) - { - return $replacements[$matches[1]]; - }, $watermarkTemplate); + $watermarkTemplate = preg_replace_callback("/{(.+?)}/", function ($matches) use ($replacements) { + return $replacements[$matches[1]]; + }, $watermarkTemplate); $params["document"]["options"] = [ "watermark_on_draw" => [ @@ -863,7 +877,8 @@ private function setWatermark($params, $isPublic, $userId, $file) { * * @return bool|string */ - private function getWatermarkText($isPublic, $userId, $file, $canEdit, $canDownload) { + private function getWatermarkText($isPublic, $userId, $file, $canEdit, $canDownload) + { $watermarkSettings = $this->config->GetWatermarkSettings(); if (!$watermarkSettings["enabled"]) { return false; @@ -930,7 +945,8 @@ private function getWatermarkText($isPublic, $userId, $file, $canEdit, $canDownl * * @return bool */ - private function isFavorite($fileId, $userId = null) { + private function isFavorite($fileId, $userId = null) + { $currentTags = $this->tagManager->load("files", [], false, $userId)->getTagsForObjects([$fileId]); if ($currentTags) { return in_array(ITags::TAG_FAVORITE, $currentTags[$fileId]); diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 2bc09ae5..61fc61fa 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -55,7 +55,8 @@ /** * Controller with the main functions */ -class EditorController extends Controller { +class EditorController extends Controller +{ /** * Current user session @@ -156,20 +157,21 @@ class EditorController extends Controller { * @param ISession $session - Session * @param IGroupManager $groupManager - group Manager */ - public function __construct($AppName, - IRequest $request, - IRootFolder $root, - IUserSession $userSession, - IUserManager $userManager, - IURLGenerator $urlGenerator, - IL10N $trans, - ILogger $logger, - AppConfig $config, - Crypt $crypt, - IManager $shareManager, - ISession $session, - IGroupManager $groupManager - ) { + public function __construct( + $AppName, + IRequest $request, + IRootFolder $root, + IUserSession $userSession, + IUserManager $userManager, + IURLGenerator $urlGenerator, + IL10N $trans, + ILogger $logger, + AppConfig $config, + Crypt $crypt, + IManager $shareManager, + ISession $session, + IGroupManager $groupManager + ) { parent::__construct($AppName, $request); $this->userSession = $userSession; @@ -208,7 +210,8 @@ public function __construct($AppName, * @NoAdminRequired * @PublicPage */ - public function create($name, $dir, $templateId = null, $targetId = 0, $shareToken = null) { + public function create($name, $dir, $templateId = null, $targetId = 0, $shareToken = null) + { $this->logger->debug("Create: $name", ["app" => $this->appName]); if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { @@ -226,7 +229,7 @@ public function create($name, $dir, $templateId = null, $targetId = 0, $shareTok $userId = $user->getUID(); $userFolder = $this->root->getUserFolder($userId); } else { - list ($userFolder, $error, $share) = $this->fileUtility->getNodeByToken($shareToken); + list($userFolder, $error, $share) = $this->fileUtility->getNodeByToken($shareToken); if (isset($error)) { $this->logger->error("Create: $error", ["app" => $this->appName]); @@ -319,7 +322,8 @@ public function create($name, $dir, $templateId = null, $targetId = 0, $shareTok * @NoAdminRequired * @NoCSRFRequired */ - public function createNew($name, $dir, $templateId = null) { + public function createNew($name, $dir, $templateId = null) + { $this->logger->debug("Create from editor: $name in $dir", ["app" => $this->appName]); $result = $this->create($name, $dir, $templateId); @@ -341,7 +345,8 @@ public function createNew($name, $dir, $templateId = null) { * @NoAdminRequired * @NoCSRFRequired */ - public function users($fileId) { + public function users($fileId) + { $this->logger->debug("Search users", ["app" => $this->appName]); $result = []; $currentUserGroups = []; @@ -370,7 +375,7 @@ public function users($fileId) { $isMemberExcludedGroups = false; } - list ($file, $error, $share) = $this->getFile($currentUserId, $fileId); + list($file, $error, $share) = $this->getFile($currentUserId, $fileId); if (isset($error)) { $this->logger->error("Users: $fileId $error", ["app" => $this->appName]); return $result; @@ -435,7 +440,8 @@ public function users($fileId) { * @NoAdminRequired * @NoCSRFRequired */ - public function mention($fileId, $anchor, $comment, $emails) { + public function mention($fileId, $anchor, $comment, $emails) + { $this->logger->debug("mention: from $fileId to " . json_encode($emails), ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -450,7 +456,7 @@ public function mention($fileId, $anchor, $comment, $emails) { foreach ($emails as $email) { $recipients = $this->userManager->getByEmail($email); foreach ($recipients as $recipient) { - $recipientId = $recipient->getUID(); + $recipientId = $recipient->getUID(); if (!in_array($recipientId, $recipientIds)) { array_push($recipientIds, $recipientId); } @@ -471,7 +477,7 @@ public function mention($fileId, $anchor, $comment, $emails) { $isMemberExcludedGroups = false; } - list ($file, $error, $share) = $this->getFile($userId, $fileId); + list($file, $error, $share) = $this->getFile($userId, $fileId); if (isset($error)) { $this->logger->error("Mention: $fileId $error", ["app" => $this->appName]); return ["error" => $this->trans->t("Failed to send notification")]; @@ -565,7 +571,8 @@ public function mention($fileId, $anchor, $comment, $emails) { * @NoAdminRequired * @PublicPage */ - public function reference($referenceData, $path = null) { + public function reference($referenceData, $path = null) + { $this->logger->debug("reference: " . json_encode($referenceData) . " $path", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -583,7 +590,7 @@ public function reference($referenceData, $path = null) { $fileId = (integer)($referenceData["fileKey"] ?? 0); if (!empty($fileId) && $referenceData["instanceId"] === $this->config->GetSystemValue("instanceid", true)) { - list ($file, $error, $share) = $this->getFile($userId, $fileId); + list($file, $error, $share) = $this->getFile($userId, $fileId); } $userFolder = $this->root->getUserFolder($userId); @@ -634,7 +641,8 @@ public function reference($referenceData, $path = null) { * @NoAdminRequired * @PublicPage */ - public function convert($fileId, $shareToken = null) { + public function convert($fileId, $shareToken = null) + { $this->logger->debug("Convert: $fileId", ["app" => $this->appName]); if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { @@ -647,7 +655,7 @@ public function convert($fileId, $shareToken = null) { $userId = $user->getUID(); } - list ($file, $error, $share) = empty($shareToken) ? $this->getFile($userId, $fileId) : $this->fileUtility->getFileByToken($fileId, $shareToken); + list($file, $error, $share) = empty($shareToken) ? $this->getFile($userId, $fileId) : $this->fileUtility->getFileByToken($fileId, $shareToken); if (isset($error)) { $this->logger->error("Convertion: $fileId $error", ["app" => $this->appName]); @@ -735,7 +743,8 @@ public function convert($fileId, $shareToken = null) { * * @NoAdminRequired */ - public function save($name, $dir, $url) { + public function save($name, $dir, $url) + { $this->logger->debug("Save: $name", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -792,7 +801,8 @@ public function save($name, $dir, $url) { * * @NoAdminRequired */ - public function history($fileId) { + public function history($fileId) + { $this->logger->debug("Request history for: $fileId", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -807,7 +817,7 @@ public function history($fileId) { $userId = $user->getUID(); } - list ($file, $error, $share) = $this->getFile($userId, $fileId); + list($file, $error, $share) = $this->getFile($userId, $fileId); if (isset($error)) { $this->logger->error("History: $fileId $error", ["app" => $this->appName]); @@ -883,7 +893,7 @@ public function history($fileId) { "id" => $this->buildUserId($author["id"]), "name" => $author["name"] ]; - } else if ($owner !== null) { + } elseif ($owner !== null) { $historyItem["user"] = [ "id" => $this->buildUserId($ownerId), "name" => $owner->getDisplayName() @@ -910,7 +920,8 @@ public function history($fileId) { * * @NoAdminRequired */ - public function version($fileId, $version) { + public function version($fileId, $version) + { $this->logger->debug("Request version for: $fileId ($version)", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -925,7 +936,7 @@ public function version($fileId, $version) { $userId = $user->getUID(); } - list ($file, $error, $share) = $this->getFile($userId, $fileId); + list($file, $error, $share) = $this->getFile($userId, $fileId); if (isset($error)) { $this->logger->error("History: $fileId $error", ["app" => $this->appName]); @@ -1012,7 +1023,8 @@ public function version($fileId, $version) { * * @NoAdminRequired */ - public function restore($fileId, $version) { + public function restore($fileId, $version) + { $this->logger->debug("Request restore version for: $fileId ($version)", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -1027,7 +1039,7 @@ public function restore($fileId, $version) { $userId = $user->getUID(); } - list ($file, $error, $share) = $this->getFile($userId, $fileId); + list($file, $error, $share) = $this->getFile($userId, $fileId); if (isset($error)) { $this->logger->error("Restore: $fileId $error", ["app" => $this->appName]); @@ -1064,7 +1076,8 @@ public function restore($fileId, $version) { * * @NoAdminRequired */ - public function url($filePath) { + public function url($filePath) + { $this->logger->debug("Request url for: $filePath", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -1115,7 +1128,8 @@ public function url($filePath) { * @NoAdminRequired * @NoCSRFRequired */ - public function download($fileId, $toExtension = null, $template = false) { + public function download($fileId, $toExtension = null, $template = false) + { $this->logger->debug("Download: $fileId $toExtension", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -1137,7 +1151,7 @@ public function download($fileId, $toExtension = null, $template = false) { $userId = $user->getUID(); } - list ($file, $error, $share) = $this->getFile($userId, $fileId); + list($file, $error, $share) = $this->getFile($userId, $fileId); if (isset($error)) { $this->logger->error("Download: $fileId $error", ["app" => $this->appName]); @@ -1210,7 +1224,8 @@ public function download($fileId, $toExtension = null, $template = false) { * @NoAdminRequired * @NoCSRFRequired */ - public function index($fileId, $filePath = null, $shareToken = null, $version = 0, $inframe = false, $inviewer = false, $template = false, $anchor = null) { + public function index($fileId, $filePath = null, $shareToken = null, $version = 0, $inframe = false, $inviewer = false, $template = false, $anchor = null) + { $this->logger->debug("Open: $fileId ($version) $filePath ", ["app" => $this->appName]); $isLoggedIn = $this->userSession->isLoggedIn(); @@ -1223,7 +1238,7 @@ public function index($fileId, $filePath = null, $shareToken = null, $version = $shareBy = null; if (!empty($shareToken) && !$isLoggedIn) { - list ($share, $error) = $this->fileUtility->getShare($shareToken); + list($share, $error) = $this->fileUtility->getShare($shareToken); if (!empty($share)) { $shareBy = $share->getSharedBy(); } @@ -1263,7 +1278,7 @@ public function index($fileId, $filePath = null, $shareToken = null, $version = } else { $response = new PublicTemplateResponse($this->appName, "editor", $params); - list ($file, $error, $share) = $this->fileUtility->getFileByToken($fileId, $shareToken); + list($file, $error, $share) = $this->fileUtility->getFileByToken($fileId, $shareToken); if (!isset($error)) { $response->setHeaderTitle($file->getName()); } @@ -1300,7 +1315,8 @@ public function index($fileId, $filePath = null, $shareToken = null, $version = * @NoCSRFRequired * @PublicPage */ - public function PublicPage($fileId, $shareToken, $version = 0, $inframe = false) { + public function PublicPage($fileId, $shareToken, $version = 0, $inframe = false) + { return $this->index($fileId, null, $shareToken, $version, $inframe); } @@ -1314,7 +1330,8 @@ public function PublicPage($fileId, $shareToken, $version = 0, $inframe = false) * * @return array */ - private function getFile($userId, $fileId, $filePath = null, $template = false) { + private function getFile($userId, $fileId, $filePath = null, $template = false) + { if (empty($fileId)) { return [null, $this->trans->t("FileId is empty"), null]; } @@ -1363,7 +1380,8 @@ private function getFile($userId, $fileId, $filePath = null, $template = false) * * @return string */ - private function getUrl($file, $user = null, $shareToken = null, $version = 0, $changes = false, $template = false) { + private function getUrl($file, $user = null, $shareToken = null, $version = 0, $changes = false, $template = false) + { $data = [ "action" => "download", @@ -1404,7 +1422,8 @@ private function getUrl($file, $user = null, $shareToken = null, $version = 0, $ * * @return array */ - private function getShareExcludedGroups() { + private function getShareExcludedGroups() + { $excludedGroups = []; if (\OC::$server->getConfig()->getAppValue("core", "shareapi_exclude_groups", "no") === "yes") { @@ -1421,7 +1440,8 @@ private function getShareExcludedGroups() { * * @return string */ - private function buildUserId($userId) { + private function buildUserId($userId) + { $instanceId = $this->config->GetSystemValue("instanceid", true); $userId = $instanceId . "_" . $userId; return $userId; @@ -1435,7 +1455,8 @@ private function buildUserId($userId) { * * @return TemplateResponse */ - private function renderError($error, $hint = "") { + private function renderError($error, $hint = "") + { return new TemplateResponse("", "error", [ "errors" => [ [ diff --git a/controller/federationcontroller.php b/controller/federationcontroller.php index 5cbc3ed2..37fbc929 100644 --- a/controller/federationcontroller.php +++ b/controller/federationcontroller.php @@ -36,7 +36,8 @@ /** * OCS handler */ -class FederationController extends OCSController { +class FederationController extends OCSController +{ /** * Logger @@ -67,13 +68,14 @@ class FederationController extends OCSController { * @param IManager $shareManager - Share manager * @param IManager $ISession - Session */ - public function __construct($AppName, - IRequest $request, - IL10N $trans, - ILogger $logger, - IManager $shareManager, - ISession $session - ) { + public function __construct( + $AppName, + IRequest $request, + IL10N $trans, + ILogger $logger, + IManager $shareManager, + ISession $session + ) { parent::__construct($AppName, $request); $this->logger = $logger; @@ -94,8 +96,9 @@ public function __construct($AppName, * @NoCSRFRequired * @PublicPage */ - public function key($shareToken, $path) { - list ($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path); + public function key($shareToken, $path) + { + list($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path); if (isset($error)) { $this->logger->error("Federated getFileByToken: $error", ["app" => $this->appName]); @@ -125,8 +128,9 @@ public function key($shareToken, $path) { * @NoCSRFRequired * @PublicPage */ - public function keylock($shareToken, $path, $lock, $fs) { - list ($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path); + public function keylock($shareToken, $path, $lock, $fs) + { + list($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path); if (isset($error)) { $this->logger->error("Federated getFileByToken: $error", ["app" => $this->appName]); @@ -160,7 +164,8 @@ public function keylock($shareToken, $path, $lock, $fs) { * @NoCSRFRequired * @PublicPage */ - public function healthcheck() { + public function healthcheck() + { $this->logger->debug("Federated healthcheck", ["app" => $this->appName]); return new DataResponse(["alive" => true]); diff --git a/controller/joblistcontroller.php b/controller/joblistcontroller.php index d4c9e321..94d08de8 100644 --- a/controller/joblistcontroller.php +++ b/controller/joblistcontroller.php @@ -37,11 +37,12 @@ * * @package OCA\Onlyoffice\Controller */ -class JobListController extends Controller { +class JobListController extends Controller +{ /** * Job list - * + * * @var IJobList */ private $jobList; @@ -61,7 +62,8 @@ class JobListController extends Controller { * @param AppConfig $config - application configuration * @param IJobList $jobList - job list */ - public function __construct($AppName, IRequest $request, AppConfig $config, IJobList $jobList) { + public function __construct($AppName, IRequest $request, AppConfig $config, IJobList $jobList) + { parent::__construct($AppName, $request); $this->config = $config; $this->jobList = $jobList; @@ -72,7 +74,8 @@ public function __construct($AppName, IRequest $request, AppConfig $config, IJob * * @param IJob|string $job */ - private function addJob($job) { + private function addJob($job) + { if (!$this->jobList->has($job, null)) { $this->jobList->add($job); \OC::$server->getLogger()->debug("Job '".$job."' added to JobList.", ["app" => $this->appName]); @@ -84,7 +87,8 @@ private function addJob($job) { * * @param IJob|string $job */ - private function removeJob($job) { + private function removeJob($job) + { if ($this->jobList->has($job, null)) { $this->jobList->remove($job); \OC::$server->getLogger()->debug("Job '".$job."' removed from JobList.", ["app" => $this->appName]); @@ -95,7 +99,8 @@ private function removeJob($job) { * Add or remove EditorsCheck job depending on the value of _editors_check_interval * */ - private function checkEditorsCheckJob() { + private function checkEditorsCheckJob() + { if ($this->config->GetEditorsCheckInterval() > 0) { $this->addJob(EditorsCheck::class); } else { @@ -107,7 +112,8 @@ private function checkEditorsCheckJob() { * Method for sequentially calling checks of all jobs * */ - public function checkAllJobs() { + public function checkAllJobs() + { $this->checkEditorsCheckJob(); } } diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 7f22b9fe..47fcaa65 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -35,7 +35,8 @@ /** * Settings controller for the administration page */ -class SettingsController extends Controller { +class SettingsController extends Controller +{ /** * l10n service @@ -81,14 +82,15 @@ class SettingsController extends Controller { * @param AppConfig $config - application configuration * @param Crypt $crypt - hash generator */ - public function __construct($AppName, - IRequest $request, - IURLGenerator $urlGenerator, - IL10N $trans, - ILogger $logger, - AppConfig $config, - Crypt $crypt - ) { + public function __construct( + $AppName, + IRequest $request, + IURLGenerator $urlGenerator, + IL10N $trans, + ILogger $logger, + AppConfig $config, + Crypt $crypt + ) { parent::__construct($AppName, $request); $this->urlGenerator = $urlGenerator; @@ -103,7 +105,8 @@ public function __construct($AppName, * * @return TemplateResponse */ - public function index() { + public function index() + { $data = [ "documentserver" => $this->config->GetDocumentServerUrl(true), "documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true), @@ -152,14 +155,15 @@ public function index() { * * @return array */ - public function SaveAddress($documentserver, - $documentserverInternal, - $storageUrl, - $verifyPeerOff, - $secret, - $jwtHeader, - $demo - ) { + public function SaveAddress( + $documentserver, + $documentserverInternal, + $storageUrl, + $verifyPeerOff, + $secret, + $jwtHeader, + $demo + ) { $error = null; if (!$this->config->SelectDemo($demo === true)) { $error = $this->trans->t("The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server."); @@ -178,7 +182,7 @@ public function SaveAddress($documentserver, $documentserver = $this->config->GetDocumentServerUrl(); if (!empty($documentserver)) { $documentService = new DocumentService($this->trans, $this->config); - list ($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); + list($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); $this->config->SetSettingsError($error); } } @@ -215,22 +219,23 @@ public function SaveAddress($documentserver, * * @return array */ - public function SaveCommon($defFormats, - $editFormats, - $sameTab, - $preview, - $advanced, - $versionHistory, - $limitGroups, - $chat, - $compactHeader, - $feedback, - $forcesave, - $help, - $toolbarNoTabs, - $reviewDisplay, - $theme - ) { + public function SaveCommon( + $defFormats, + $editFormats, + $sameTab, + $preview, + $advanced, + $versionHistory, + $limitGroups, + $chat, + $compactHeader, + $feedback, + $forcesave, + $help, + $toolbarNoTabs, + $reviewDisplay, + $theme + ) { $this->config->SetDefaultFormats($defFormats); $this->config->SetEditableFormats($editFormats); @@ -262,11 +267,12 @@ public function SaveCommon($defFormats, * * @return array */ - public function SaveSecurity($watermarks, - $plugins, - $macros, - $protection - ) { + public function SaveSecurity( + $watermarks, + $plugins, + $macros, + $protection + ) { if ($watermarks["enabled"] === "true") { $watermarks["text"] = trim($watermarks["text"]); @@ -289,7 +295,8 @@ public function SaveSecurity($watermarks, * * @return array */ - public function ClearHistory() { + public function ClearHistory() + { FileVersions::clearHistory(); @@ -302,7 +309,8 @@ public function ClearHistory() { * * @return array */ - private function GetGlobalTemplates() { + private function GetGlobalTemplates() + { $templates = []; $templatesList = TemplateManager::GetGlobalTemplates(); diff --git a/controller/sharingapicontroller.php b/controller/sharingapicontroller.php index ab4d3d73..9bb71bb3 100644 --- a/controller/sharingapicontroller.php +++ b/controller/sharingapicontroller.php @@ -45,7 +45,8 @@ /** * OCS handler */ -class SharingApiController extends OCSController { +class SharingApiController extends OCSController +{ /** * Current user session @@ -106,15 +107,16 @@ class SharingApiController extends OCSController { * @param IManager $shareManager - Share manager * @param AppConfig $appConfig - application configuration */ - public function __construct($AppName, - IRequest $request, - IRootFolder $root, - ILogger $logger, - IUserSession $userSession, - IUserManager $userManager, - IManager $shareManager, - AppConfig $appConfig - ) { + public function __construct( + $AppName, + IRequest $request, + IRootFolder $root, + ILogger $logger, + IUserSession $userSession, + IUserManager $userManager, + IManager $shareManager, + AppConfig $appConfig + ) { parent::__construct($AppName, $request); $this->root = $root; @@ -140,7 +142,8 @@ public function __construct($AppName, * @NoAdminRequired * @NoCSRFRequired */ - public function getShares($fileId) { + public function getShares($fileId) + { if ($this->extraPermissions === null) { $this->logger->debug("extraPermissions isn't init", ["app" => $this->appName]); return new DataResponse([], Http::STATUS_BAD_REQUEST); @@ -176,7 +179,8 @@ public function getShares($fileId) { * @NoAdminRequired * @NoCSRFRequired */ - public function setShares($extraId, $shareId, $fileId, $permissions) { + public function setShares($extraId, $shareId, $fileId, $permissions) + { if ($this->extraPermissions === null) { $this->logger->debug("extraPermissions isn't init", ["app" => $this->appName]); return new DataResponse([], Http::STATUS_BAD_REQUEST); @@ -209,7 +213,8 @@ public function setShares($extraId, $shareId, $fileId, $permissions) { * * @return File */ - private function getFile($fileId, $userId) { + private function getFile($fileId, $userId) + { try { $folder = $this->root->getUserFolder($userId); $files = $folder->getById($fileId); diff --git a/controller/templatecontroller.php b/controller/templatecontroller.php index 99aee309..df28ce09 100644 --- a/controller/templatecontroller.php +++ b/controller/templatecontroller.php @@ -34,7 +34,8 @@ /** * OCS handler */ -class TemplateController extends Controller { +class TemplateController extends Controller +{ /** * l10n service @@ -62,12 +63,13 @@ class TemplateController extends Controller { * @param ILogger $logger - logger * @param IL10N $trans - l10n service */ - public function __construct($AppName, - IRequest $request, - IL10N $trans, - ILogger $logger, - IPreview $preview - ) { + public function __construct( + $AppName, + IRequest $request, + IL10N $trans, + ILogger $logger, + IPreview $preview + ) { parent::__construct($AppName, $request); $this->trans = $trans; @@ -82,7 +84,8 @@ public function __construct($AppName, * * @NoAdminRequired */ - public function GetTemplates() { + public function GetTemplates() + { $templatesList = TemplateManager::GetGlobalTemplates(); $templates = []; @@ -103,7 +106,8 @@ public function GetTemplates() { * * @return array */ - public function AddTemplate() { + public function AddTemplate() + { $file = $this->request->getUploadedFile("file"); @@ -150,7 +154,8 @@ public function AddTemplate() { * * @return array */ - public function DeleteTemplate($templateId) { + public function DeleteTemplate($templateId) + { $templateDir = TemplateManager::GetGlobalTemplateDir(); try { @@ -189,7 +194,8 @@ public function DeleteTemplate($templateId) { * @NoAdminRequired * @NoCSRFRequired */ - public function preview($fileId, $x = 256, $y = 256, $crop = false, $mode = IPreview::MODE_FILL) { + public function preview($fileId, $x = 256, $y = 256, $crop = false, $mode = IPreview::MODE_FILL) + { if (empty($fileId) || $x === 0 || $y === 0) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } @@ -213,4 +219,4 @@ public function preview($fileId, $x = 256, $y = 256, $crop = false, $mode = IPre } } -} \ No newline at end of file +} diff --git a/lib/Migration/Version070000Date20210417111111.php b/lib/Migration/Version070000Date20210417111111.php index 66fb0d24..21394c56 100644 --- a/lib/Migration/Version070000Date20210417111111.php +++ b/lib/Migration/Version070000Date20210417111111.php @@ -12,59 +12,63 @@ /** * Auto-generated migration step: Please modify to your needs! */ -class Version070000Date20210417111111 extends SimpleMigrationStep { +class Version070000Date20210417111111 extends SimpleMigrationStep +{ - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - } + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void + { + } - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * @return null|ISchemaWrapper - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper + { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); - if (!$schema->hasTable('onlyoffice_filekey')) { - $table = $schema->createTable('onlyoffice_filekey'); - $table->addColumn('id', 'integer', [ - 'autoincrement' => true, - 'notnull' => true, - ]); - $table->addColumn('file_id', 'bigint', [ - 'notnull' => false, - 'default' => '-1', - ]); - $table->addColumn('key', 'string', [ - 'notnull' => true, - 'length' => 128, - ]); - $table->addColumn('lock', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->addColumn('fs', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['file_id'], 'file_id_index'); - } - return $schema; - } + if (!$schema->hasTable('onlyoffice_filekey')) { + $table = $schema->createTable('onlyoffice_filekey'); + $table->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('file_id', 'bigint', [ + 'notnull' => false, + 'default' => '-1', + ]); + $table->addColumn('key', 'string', [ + 'notnull' => true, + 'length' => 128, + ]); + $table->addColumn('lock', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->addColumn('fs', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['file_id'], 'file_id_index'); + } + return $schema; + } - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - } + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void + { + } } diff --git a/lib/Migration/Version070400Date20220607111111.php b/lib/Migration/Version070400Date20220607111111.php index 1ca7636b..2da68321 100644 --- a/lib/Migration/Version070400Date20220607111111.php +++ b/lib/Migration/Version070400Date20220607111111.php @@ -12,78 +12,82 @@ /** * Auto-generated migration step: Please modify to your needs! */ -class Version070400Date20220607111111 extends SimpleMigrationStep { +class Version070400Date20220607111111 extends SimpleMigrationStep +{ - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - } + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void + { + } - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * @return null|ISchemaWrapper - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper + { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); - if (!$schema->hasTable('onlyoffice_filekey')) { - $table = $schema->createTable('onlyoffice_filekey'); - $table->addColumn('id', 'integer', [ - 'autoincrement' => true, - 'notnull' => true, - ]); - $table->addColumn('file_id', 'bigint', [ - 'notnull' => false, - 'default' => '-1', - ]); - $table->addColumn('key', 'string', [ - 'notnull' => true, - 'length' => 128, - ]); - $table->addColumn('lock', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->addColumn('fs', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['file_id'], 'file_id_index'); - } + if (!$schema->hasTable('onlyoffice_filekey')) { + $table = $schema->createTable('onlyoffice_filekey'); + $table->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('file_id', 'bigint', [ + 'notnull' => false, + 'default' => '-1', + ]); + $table->addColumn('key', 'string', [ + 'notnull' => true, + 'length' => 128, + ]); + $table->addColumn('lock', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->addColumn('fs', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['file_id'], 'file_id_index'); + } - if (!$schema->hasTable('onlyoffice_permissions')) { - $table = $schema->createTable('onlyoffice_permissions'); - $table->addColumn('id', 'integer', [ - 'autoincrement' => true, - 'notnull' => true, - ]); - $table->addColumn('share_id', 'bigint', [ - 'notnull' => true, - 'default' => '-1', - ]); - $table->addColumn('permissions', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['share_id'], 'share_id_index'); - } + if (!$schema->hasTable('onlyoffice_permissions')) { + $table = $schema->createTable('onlyoffice_permissions'); + $table->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('share_id', 'bigint', [ + 'notnull' => true, + 'default' => '-1', + ]); + $table->addColumn('permissions', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['share_id'], 'share_id_index'); + } - return $schema; - } + return $schema; + } - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - } + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void + { + } } diff --git a/lib/Migration/Version070400Date20220929111111.php b/lib/Migration/Version070400Date20220929111111.php index d42b3db2..06a4ea19 100644 --- a/lib/Migration/Version070400Date20220929111111.php +++ b/lib/Migration/Version070400Date20220929111111.php @@ -12,100 +12,104 @@ /** * Auto-generated migration step: Please modify to your needs! */ -class Version070400Date20220929111111 extends SimpleMigrationStep { +class Version070400Date20220929111111 extends SimpleMigrationStep +{ - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - } + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void + { + } - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - * @return null|ISchemaWrapper - */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { - /** @var ISchemaWrapper $schema */ - $schema = $schemaClosure(); + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + */ + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper + { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); - if (!$schema->hasTable('onlyoffice_filekey')) { - $table = $schema->createTable('onlyoffice_filekey'); - $table->addColumn('id', 'integer', [ - 'autoincrement' => true, - 'notnull' => true, - ]); - $table->addColumn('file_id', 'bigint', [ - 'notnull' => false, - 'default' => '-1', - ]); - $table->addColumn('key', 'string', [ - 'notnull' => true, - 'length' => 128, - ]); - $table->addColumn('lock', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->addColumn('fs', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['file_id'], 'onlyoffice_file_id_index'); - } + if (!$schema->hasTable('onlyoffice_filekey')) { + $table = $schema->createTable('onlyoffice_filekey'); + $table->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('file_id', 'bigint', [ + 'notnull' => false, + 'default' => '-1', + ]); + $table->addColumn('key', 'string', [ + 'notnull' => true, + 'length' => 128, + ]); + $table->addColumn('lock', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->addColumn('fs', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['file_id'], 'onlyoffice_file_id_index'); + } - if (!$schema->hasTable('onlyoffice_permissions')) { - $table = $schema->createTable('onlyoffice_permissions'); - $table->addColumn('id', 'integer', [ - 'autoincrement' => true, - 'notnull' => true, - ]); - $table->addColumn('share_id', 'bigint', [ - 'notnull' => true, - 'default' => '-1', - ]); - $table->addColumn('permissions', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['share_id'], 'onlyoffice_share_id_index'); - } + if (!$schema->hasTable('onlyoffice_permissions')) { + $table = $schema->createTable('onlyoffice_permissions'); + $table->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('share_id', 'bigint', [ + 'notnull' => true, + 'default' => '-1', + ]); + $table->addColumn('permissions', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['share_id'], 'onlyoffice_share_id_index'); + } - if (!$schema->hasTable('onlyoffice_instance')) { - $table = $schema->createTable('onlyoffice_instance'); - $table->addColumn('id', 'integer', [ - 'autoincrement' => true, - 'notnull' => true, - ]); - $table->addColumn('remote', 'string', [ - 'notnull' => true, - 'length' => 128, - ]); - $table->addColumn('expire', 'bigint', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->addColumn('status', 'integer', [ - 'notnull' => true, - 'default' => 0, - ]); - $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['remote'], 'onlyoffice_remote_index'); - } + if (!$schema->hasTable('onlyoffice_instance')) { + $table = $schema->createTable('onlyoffice_instance'); + $table->addColumn('id', 'integer', [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('remote', 'string', [ + 'notnull' => true, + 'length' => 128, + ]); + $table->addColumn('expire', 'bigint', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->addColumn('status', 'integer', [ + 'notnull' => true, + 'default' => 0, + ]); + $table->setPrimaryKey(['id']); + $table->addUniqueIndex(['remote'], 'onlyoffice_remote_index'); + } - return $schema; - } + return $schema; + } - /** - * @param IOutput $output - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` - * @param array $options - */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - } + /** + * @param IOutput $output + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + */ + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void + { + } } diff --git a/lib/adminsection.php b/lib/adminsection.php index acc81e2c..962b1e29 100644 --- a/lib/adminsection.php +++ b/lib/adminsection.php @@ -25,7 +25,8 @@ /** * Settings section for the administration page */ -class AdminSection implements IIconSection { +class AdminSection implements IIconSection +{ /** @var IURLGenerator */ private $urlGenerator; @@ -33,7 +34,8 @@ class AdminSection implements IIconSection { /** * @param IURLGenerator $urlGenerator - url generator service */ - public function __construct(IURLGenerator $urlGenerator) { + public function __construct(IURLGenerator $urlGenerator) + { $this->urlGenerator = $urlGenerator; } @@ -43,7 +45,8 @@ public function __construct(IURLGenerator $urlGenerator) { * * @return strings */ - public function getIcon() { + public function getIcon() + { return $this->urlGenerator->imagePath("onlyoffice", "app-dark.svg"); } @@ -52,7 +55,8 @@ public function getIcon() { * * @returns string */ - public function getID() { + public function getID() + { return "onlyoffice"; } @@ -61,7 +65,8 @@ public function getID() { * * @return string */ - public function getName() { + public function getName() + { return "ONLYOFFICE"; } @@ -70,7 +75,8 @@ public function getName() { * * @return int */ - public function getPriority() { + public function getPriority() + { return 50; } } diff --git a/lib/adminsettings.php b/lib/adminsettings.php index d1d394e9..7a66cf58 100644 --- a/lib/adminsettings.php +++ b/lib/adminsettings.php @@ -27,9 +27,11 @@ /** * Settings controller for the administration page */ -class AdminSettings implements ISettings { +class AdminSettings implements ISettings +{ - public function __construct() { + public function __construct() + { } /** @@ -37,7 +39,8 @@ public function __construct() { * * @return TemplateResponse */ - public function getForm() { + public function getForm() + { $app = \OC::$server->query(Application::class); $container = $app->getContainer(); $response = $container->query(SettingsController::class)->index(); @@ -49,7 +52,8 @@ public function getForm() { * * @return string */ - public function getSection() { + public function getSection() + { return "onlyoffice"; } @@ -58,7 +62,8 @@ public function getSection() { * * @return int */ - public function getPriority() { + public function getPriority() + { return 50; } } diff --git a/lib/appconfig.php b/lib/appconfig.php index 06f9fbb0..1f31e981 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -30,7 +30,8 @@ * * @package OCA\Onlyoffice */ -class AppConfig { +class AppConfig +{ /** * Application name @@ -329,7 +330,8 @@ class AppConfig { /** * @param string $AppName - application name */ - public function __construct($AppName) { + public function __construct($AppName) + { $this->appName = $AppName; @@ -345,7 +347,8 @@ public function __construct($AppName) { * * @return string */ - public function GetSystemValue($key, $system = false) { + public function GetSystemValue($key, $system = false) + { if ($system) { return $this->config->getSystemValue($key); } @@ -363,7 +366,8 @@ public function GetSystemValue($key, $system = false) { * * @return bool */ - public function SelectDemo($value) { + public function SelectDemo($value) + { $this->logger->info("Select demo: " . json_encode($value), ["app" => $this->appName]); $data = $this->GetDemoData(); @@ -387,7 +391,8 @@ public function SelectDemo($value) { * * @return array */ - public function GetDemoData() { + public function GetDemoData() + { $data = $this->config->getAppValue($this->appName, $this->_demo, ""); if (empty($data)) { @@ -416,7 +421,8 @@ public function GetDemoData() { * * @return bool */ - public function UseDemo() { + public function UseDemo() + { return $this->GetDemoData()["enabled"] === true; } @@ -425,7 +431,8 @@ public function UseDemo() { * * @param string $documentServer - document service address */ - public function SetDocumentServerUrl($documentServer) { + public function SetDocumentServerUrl($documentServer) + { $documentServer = trim($documentServer); if (strlen($documentServer) > 0) { $documentServer = rtrim($documentServer, "/") . "/"; @@ -446,7 +453,8 @@ public function SetDocumentServerUrl($documentServer) { * * @return string */ - public function GetDocumentServerUrl($origin = false) { + public function GetDocumentServerUrl($origin = false) + { if (!$origin && $this->UseDemo()) { return $this->DEMO_PARAM["ADDR"]; } @@ -469,7 +477,8 @@ public function GetDocumentServerUrl($origin = false) { * * @param string $documentServerInternal - document service address */ - public function SetDocumentServerInternalUrl($documentServerInternal) { + public function SetDocumentServerInternalUrl($documentServerInternal) + { $documentServerInternal = rtrim(trim($documentServerInternal), "/"); if (strlen($documentServerInternal) > 0) { $documentServerInternal = $documentServerInternal . "/"; @@ -490,7 +499,8 @@ public function SetDocumentServerInternalUrl($documentServerInternal) { * * @return string */ - public function GetDocumentServerInternalUrl($origin = false) { + public function GetDocumentServerInternalUrl($origin = false) + { if (!$origin && $this->UseDemo()) { return $this->GetDocumentServerUrl(); } @@ -512,7 +522,8 @@ public function GetDocumentServerInternalUrl($origin = false) { * * @return string */ - public function ReplaceDocumentServerUrlToInternal($url) { + public function ReplaceDocumentServerUrlToInternal($url) + { $documentServerUrl = $this->GetDocumentServerInternalUrl(); if (!empty($documentServerUrl)) { $from = $this->GetDocumentServerUrl(); @@ -522,8 +533,7 @@ public function ReplaceDocumentServerUrlToInternal($url) { $from = $parsedUrl["scheme"] . "://" . $parsedUrl["host"] . (array_key_exists("port", $parsedUrl) ? (":" . $parsedUrl["port"]) : "") . $from; } - if ($from !== $documentServerUrl) - { + if ($from !== $documentServerUrl) { $this->logger->debug("Replace url from $from to $documentServerUrl", ["app" => $this->appName]); $url = str_replace($from, $documentServerUrl, $url); } @@ -537,7 +547,8 @@ public function ReplaceDocumentServerUrlToInternal($url) { * * @param string $documentServer - document service address */ - public function SetStorageUrl($storageUrl) { + public function SetStorageUrl($storageUrl) + { $storageUrl = rtrim(trim($storageUrl), "/"); if (strlen($storageUrl) > 0) { $storageUrl = $storageUrl . "/"; @@ -556,7 +567,8 @@ public function SetStorageUrl($storageUrl) { * * @return string */ - public function GetStorageUrl() { + public function GetStorageUrl() + { $url = $this->config->getAppValue($this->appName, $this->_storageUrl, ""); if (empty($url)) { $url = $this->GetSystemValue($this->_storageUrl); @@ -569,7 +581,8 @@ public function GetStorageUrl() { * * @param string $secret - secret key */ - public function SetDocumentServerSecret($secret) { + public function SetDocumentServerSecret($secret) + { $secret = trim($secret); if (empty($secret)) { $this->logger->info("Clear secret key", ["app" => $this->appName]); @@ -587,7 +600,8 @@ public function SetDocumentServerSecret($secret) { * * @return string */ - public function GetDocumentServerSecret($origin = false) { + public function GetDocumentServerSecret($origin = false) + { if (!$origin && $this->UseDemo()) { return $this->DEMO_PARAM["SECRET"]; } @@ -604,7 +618,8 @@ public function GetDocumentServerSecret($origin = false) { * * @return string */ - public function GetSKey() { + public function GetSKey() + { $secret = $this->GetDocumentServerSecret(); if (empty($secret)) { $secret = $this->GetSystemValue($this->_cryptSecret, true); @@ -617,7 +632,8 @@ public function GetSKey() { * * @param array $formats - formats with status */ - public function SetDefaultFormats($formats) { + public function SetDefaultFormats($formats) + { $value = json_encode($formats); $this->logger->info("Set default formats: $value", ["app" => $this->appName]); @@ -629,7 +645,8 @@ public function SetDefaultFormats($formats) { * * @return array */ - private function GetDefaultFormats() { + private function GetDefaultFormats() + { $value = $this->config->getAppValue($this->appName, $this->_defFormats, ""); if (empty($value)) { return array(); @@ -642,7 +659,8 @@ private function GetDefaultFormats() { * * @param array $formats - formats with status */ - public function SetEditableFormats($formats) { + public function SetEditableFormats($formats) + { $value = json_encode($formats); $this->logger->info("Set editing formats: $value", ["app" => $this->appName]); @@ -654,7 +672,8 @@ public function SetEditableFormats($formats) { * * @return array */ - private function GetEditableFormats() { + private function GetEditableFormats() + { $value = $this->config->getAppValue($this->appName, $this->_editFormats, ""); if (empty($value)) { return array(); @@ -667,7 +686,8 @@ private function GetEditableFormats() { * * @param bool $value - same tab */ - public function SetSameTab($value) { + public function SetSameTab($value) + { $this->logger->info("Set opening in a same tab: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_sameTab, json_encode($value)); @@ -678,7 +698,8 @@ public function SetSameTab($value) { * * @return bool */ - public function GetSameTab() { + public function GetSameTab() + { return $this->config->getAppValue($this->appName, $this->_sameTab, "true") === "true"; } @@ -687,7 +708,8 @@ public function GetSameTab() { * * @param bool $value - preview */ - public function SetPreview($value) { + public function SetPreview($value) + { $this->logger->info("Set generate preview: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_preview, json_encode($value)); @@ -698,7 +720,8 @@ public function SetPreview($value) { * * @return bool */ - public function GetAdvanced() { + public function GetAdvanced() + { return $this->config->getAppValue($this->appName, $this->_advanced, "false") === "true"; } @@ -707,7 +730,8 @@ public function GetAdvanced() { * * @param bool $value - advanced */ - public function SetAdvanced($value) { + public function SetAdvanced($value) + { $this->logger->info("Set advanced: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_advanced, json_encode($value)); @@ -718,7 +742,8 @@ public function SetAdvanced($value) { * * @return bool */ - public function GetPreview() { + public function GetPreview() + { return $this->config->getAppValue($this->appName, $this->_preview, "true") === "true"; } @@ -727,7 +752,8 @@ public function GetPreview() { * * @param bool $value - version history */ - public function SetVersionHistory($value) { + public function SetVersionHistory($value) + { $this->logger->info("Set keep versions history: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_versionHistory, json_encode($value)); @@ -738,7 +764,8 @@ public function SetVersionHistory($value) { * * @return bool */ - public function GetVersionHistory() { + public function GetVersionHistory() + { return $this->config->getAppValue($this->appName, $this->_versionHistory, "true") === "true"; } @@ -747,7 +774,8 @@ public function GetVersionHistory() { * * @param bool $value - version history */ - public function SetProtection($value) { + public function SetProtection($value) + { $this->logger->info("Set protection: " . $value, ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_protection, $value); @@ -758,7 +786,8 @@ public function SetProtection($value) { * * @return bool */ - public function GetProtection() { + public function GetProtection() + { $value = $this->config->getAppValue($this->appName, $this->_protection, "owner"); if ($value === "all") { return "all"; @@ -771,7 +800,8 @@ public function GetProtection() { * * @param bool $value - display chat */ - public function SetCustomizationChat($value) { + public function SetCustomizationChat($value) + { $this->logger->info("Set chat display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationChat, json_encode($value)); @@ -782,7 +812,8 @@ public function SetCustomizationChat($value) { * * @return bool */ - public function GetCustomizationChat() { + public function GetCustomizationChat() + { return $this->config->getAppValue($this->appName, $this->_customizationChat, "true") === "true"; } @@ -791,7 +822,8 @@ public function GetCustomizationChat() { * * @param bool $value - display compact header */ - public function SetCustomizationCompactHeader($value) { + public function SetCustomizationCompactHeader($value) + { $this->logger->info("Set compact header display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationCompactHeader, json_encode($value)); @@ -802,7 +834,8 @@ public function SetCustomizationCompactHeader($value) { * * @return bool */ - public function GetCustomizationCompactHeader() { + public function GetCustomizationCompactHeader() + { return $this->config->getAppValue($this->appName, $this->_customizationCompactHeader, "true") === "true"; } @@ -811,7 +844,8 @@ public function GetCustomizationCompactHeader() { * * @param bool $value - display feedback */ - public function SetCustomizationFeedback($value) { + public function SetCustomizationFeedback($value) + { $this->logger->info("Set feedback display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationFeedback, json_encode($value)); @@ -822,7 +856,8 @@ public function SetCustomizationFeedback($value) { * * @return bool */ - public function GetCustomizationFeedback() { + public function GetCustomizationFeedback() + { return $this->config->getAppValue($this->appName, $this->_customizationFeedback, "true") === "true"; } @@ -831,7 +866,8 @@ public function GetCustomizationFeedback() { * * @param bool $value - forcesave */ - public function SetCustomizationForcesave($value) { + public function SetCustomizationForcesave($value) + { $this->logger->info("Set forcesave: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationForcesave, json_encode($value)); @@ -842,7 +878,8 @@ public function SetCustomizationForcesave($value) { * * @return bool */ - public function GetCustomizationForcesave() { + public function GetCustomizationForcesave() + { return $this->config->getAppValue($this->appName, $this->_customizationForcesave, "false") === "true"; } @@ -851,7 +888,8 @@ public function GetCustomizationForcesave() { * * @param bool $value - display help */ - public function SetCustomizationHelp($value) { + public function SetCustomizationHelp($value) + { $this->logger->info("Set help display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationHelp, json_encode($value)); @@ -862,7 +900,8 @@ public function SetCustomizationHelp($value) { * * @return bool */ - public function GetCustomizationHelp() { + public function GetCustomizationHelp() + { return $this->config->getAppValue($this->appName, $this->_customizationHelp, "true") === "true"; } @@ -871,7 +910,8 @@ public function GetCustomizationHelp() { * * @param bool $value - without tabs */ - public function SetCustomizationToolbarNoTabs($value) { + public function SetCustomizationToolbarNoTabs($value) + { $this->logger->info("Set without tabs: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationToolbarNoTabs, json_encode($value)); @@ -882,7 +922,8 @@ public function SetCustomizationToolbarNoTabs($value) { * * @return bool */ - public function GetCustomizationToolbarNoTabs() { + public function GetCustomizationToolbarNoTabs() + { return $this->config->getAppValue($this->appName, $this->_customizationToolbarNoTabs, "true") === "true"; } @@ -891,7 +932,8 @@ public function GetCustomizationToolbarNoTabs() { * * @param string $value - review mode */ - public function SetCustomizationReviewDisplay($value) { + public function SetCustomizationReviewDisplay($value) + { $this->logger->info("Set review mode: " . $value, array("app" => $this->appName)); $this->config->setAppValue($this->appName, $this->_customizationReviewDisplay, $value); @@ -902,7 +944,8 @@ public function SetCustomizationReviewDisplay($value) { * * @return string */ - public function GetCustomizationReviewDisplay() { + public function GetCustomizationReviewDisplay() + { $value = $this->config->getAppValue($this->appName, $this->_customizationReviewDisplay, "original"); if ($value === "markup") { return "markup"; @@ -918,7 +961,8 @@ public function GetCustomizationReviewDisplay() { * * @param string $value - theme */ - public function SetCustomizationTheme($value) { + public function SetCustomizationTheme($value) + { $this->logger->info("Set theme: " . $value, array("app" => $this->appName)); $this->config->setAppValue($this->appName, $this->_customizationTheme, $value); @@ -929,7 +973,8 @@ public function SetCustomizationTheme($value) { * * @return string */ - public function GetCustomizationTheme() { + public function GetCustomizationTheme() + { $value = $this->config->getAppValue($this->appName, $this->_customizationTheme, "theme-classic-light"); if ($value === "theme-light") { return "theme-light"; @@ -945,7 +990,8 @@ public function GetCustomizationTheme() { * * @param array $settings - watermark settings */ - public function SetWatermarkSettings($settings) { + public function SetWatermarkSettings($settings) + { $this->logger->info("Set watermark enabled: " . $settings["enabled"], ["app" => $this->appName]); if ($settings["enabled"] !== "true") { @@ -993,7 +1039,8 @@ public function SetWatermarkSettings($settings) { * * @return bool|array */ - public function GetWatermarkSettings() { + public function GetWatermarkSettings() + { $result = [ "text" => $this->config->getAppValue(AppConfig::WATERMARK_APP_NAMESPACE, "watermark_text", "{userId}, {date}"), ]; @@ -1035,7 +1082,8 @@ public function GetWatermarkSettings() { * * @param array $groups - the list of groups */ - public function SetLimitGroups($groups) { + public function SetLimitGroups($groups) + { if (!is_array($groups)) { $groups = array(); } @@ -1050,7 +1098,8 @@ public function SetLimitGroups($groups) { * * @return array */ - public function GetLimitGroups() { + public function GetLimitGroups() + { $value = $this->config->getAppValue($this->appName, $this->_groups, ""); if (empty($value)) { return array(); @@ -1069,7 +1118,8 @@ public function GetLimitGroups() { * * @return bool */ - public function isUserAllowedToUse($userId = null) { + public function isUserAllowedToUse($userId = null) + { // no user -> no $userSession = \OC::$server->getUserSession(); if (is_null($userId) && ($userSession === null || !$userSession->isLoggedIn())) { @@ -1112,7 +1162,8 @@ public function isUserAllowedToUse($userId = null) { * * @param bool $verifyPeerOff - parameter verification setting */ - public function SetVerifyPeerOff($verifyPeerOff) { + public function SetVerifyPeerOff($verifyPeerOff) + { $this->logger->info("SetVerifyPeerOff " . json_encode($verifyPeerOff), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_verification, json_encode($verifyPeerOff)); @@ -1123,7 +1174,8 @@ public function SetVerifyPeerOff($verifyPeerOff) { * * @return bool */ - public function GetVerifyPeerOff() { + public function GetVerifyPeerOff() + { $turnOff = $this->config->getAppValue($this->appName, $this->_verification, ""); if (!empty($turnOff)) { @@ -1138,7 +1190,8 @@ public function GetVerifyPeerOff() { * * @return int */ - public function GetLimitThumbSize() { + public function GetLimitThumbSize() + { $limitSize = (integer)$this->GetSystemValue($this->_limitThumbSize); if (!empty($limitSize)) { @@ -1155,7 +1208,8 @@ public function GetLimitThumbSize() { * * @return string */ - public function JwtHeader($origin = false) { + public function JwtHeader($origin = false) + { if (!$origin && $this->UseDemo()) { return $this->DEMO_PARAM["HEADER"]; } @@ -1175,7 +1229,8 @@ public function JwtHeader($origin = false) { * * @param string $value - jwtHeader */ - public function SetJwtHeader($value) { + public function SetJwtHeader($value) + { $value = trim($value); if (empty($value)) { $this->logger->info("Clear header key", ["app" => $this->appName]); @@ -1191,7 +1246,8 @@ public function SetJwtHeader($value) { * * @return int */ - public function GetJwtLeeway() { + public function GetJwtLeeway() + { $jwtLeeway = (integer)$this->GetSystemValue($this->_jwtLeeway); return $jwtLeeway; @@ -1202,7 +1258,8 @@ public function GetJwtLeeway() { * * @param string $value - error */ - public function SetSettingsError($value) { + public function SetSettingsError($value) + { $this->config->setAppValue($this->appName, $this->_settingsError, $value); } @@ -1211,7 +1268,8 @@ public function SetSettingsError($value) { * * @return bool */ - public function SettingsAreSuccessful() { + public function SettingsAreSuccessful() + { return empty($this->config->getAppValue($this->appName, $this->_settingsError, "")); } @@ -1222,7 +1280,8 @@ public function SettingsAreSuccessful() { * * @NoAdminRequired */ - public function FormatsSetting() { + public function FormatsSetting() + { $result = $this->formats; $defFormats = $this->GetDefaultFormats(); @@ -1247,7 +1306,8 @@ public function FormatsSetting() { * * @param bool $value - enable macros */ - public function SetCustomizationMacros($value) { + public function SetCustomizationMacros($value) + { $this->logger->info("Set macros enabled: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationMacros, json_encode($value)); @@ -1258,7 +1318,8 @@ public function SetCustomizationMacros($value) { * * @return bool */ - public function GetCustomizationMacros() { + public function GetCustomizationMacros() + { return $this->config->getAppValue($this->appName, $this->_customizationMacros, "true") === "true"; } @@ -1267,7 +1328,8 @@ public function GetCustomizationMacros() { * * @param bool $value - enable macros */ - public function SetCustomizationPlugins($value) { + public function SetCustomizationPlugins($value) + { $this->logger->info("Set plugins enabled: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationPlugins, json_encode($value)); @@ -1278,7 +1340,8 @@ public function SetCustomizationPlugins($value) { * * @return bool */ - public function GetCustomizationPlugins() { + public function GetCustomizationPlugins() + { return $this->config->getAppValue($this->appName, $this->_customizationPlugins, "true") === "true"; } @@ -1287,7 +1350,8 @@ public function GetCustomizationPlugins() { * * @return int */ - public function GetEditorsCheckInterval() { + public function GetEditorsCheckInterval() + { $interval = $this->GetSystemValue($this->_editors_check_interval); if (empty($interval) && $interval !== 0) { @@ -1356,7 +1420,8 @@ public function GetEditorsCheckInterval() { * * @return string */ - public function GetLinkToDocs() { + public function GetLinkToDocs() + { return $this->linkToDocs; } } diff --git a/lib/command/documentserver.php b/lib/command/documentserver.php index 5abeb79b..2d942424 100644 --- a/lib/command/documentserver.php +++ b/lib/command/documentserver.php @@ -31,7 +31,8 @@ use OCA\Onlyoffice\DocumentService; use OCA\Onlyoffice\Crypt; -class DocumentServer extends Command { +class DocumentServer extends Command +{ /** * Application configuration @@ -67,10 +68,12 @@ class DocumentServer extends Command { * @param IURLGenerator $urlGenerator - url generator service * @param Crypt $crypt - hash generator */ - public function __construct(AppConfig $config, - IL10N $trans, - IURLGenerator $urlGenerator, - Crypt $crypt) { + public function __construct( + AppConfig $config, + IL10N $trans, + IURLGenerator $urlGenerator, + Crypt $crypt + ) { parent::__construct(); $this->config = $config; $this->trans = $trans; @@ -81,14 +84,17 @@ public function __construct(AppConfig $config, /** * Configures the current command. */ - protected function configure() { + protected function configure() + { $this ->setName("onlyoffice:documentserver") ->setDescription("Manage document server") - ->addOption("check", - null, - InputOption::VALUE_NONE, - "Check connection document server"); + ->addOption( + "check", + null, + InputOption::VALUE_NONE, + "Check connection document server" + ); } /** @@ -99,7 +105,8 @@ protected function configure() { * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output) + { $check = $input->getOption("check"); $documentserver = $this->config->GetDocumentServerUrl(true); @@ -111,7 +118,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { if ($check) { $documentService = new DocumentService($this->trans, $this->config); - list ($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); + list($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); $this->config->SetSettingsError($error); if (!empty($error)) { @@ -126,4 +133,4 @@ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln("The current document server: $documentserver"); return 0; } -} \ No newline at end of file +} diff --git a/lib/cron/editorscheck.php b/lib/cron/editorscheck.php index 1e4ed692..ea95dfbb 100644 --- a/lib/cron/editorscheck.php +++ b/lib/cron/editorscheck.php @@ -36,7 +36,8 @@ * Editors availability check background job * */ -class EditorsCheck extends TimedJob { +class EditorsCheck extends TimedJob +{ /** * Application name @@ -95,13 +96,15 @@ class EditorsCheck extends TimedJob { * @param IL10N $trans - l10n service * @param Crypt $crypt - crypt service */ - public function __construct(string $AppName, - IURLGenerator $urlGenerator, - ITimeFactory $time, - AppConfig $config, - IL10N $trans, - Crypt $crypt, - IGroupManager $groupManager) { + public function __construct( + string $AppName, + IURLGenerator $urlGenerator, + ITimeFactory $time, + AppConfig $config, + IL10N $trans, + Crypt $crypt, + IGroupManager $groupManager + ) { parent::__construct($time); $this->appName = $AppName; $this->urlGenerator = $urlGenerator; @@ -120,7 +123,8 @@ public function __construct(string $AppName, * * @param array $argument unused argument */ - protected function run($argument) { + protected function run($argument) + { if (empty($this->config->GetDocumentServerUrl())) { $this->logger->debug("Settings are empty", ["app" => $this->appName]); return; @@ -136,13 +140,13 @@ protected function run($argument) { $host = parse_url($fileUrl)["host"]; if ($host === "localhost" || $host === "127.0.0.1") { $this->logger->debug("Localhost is not alowed for cron editors availability check. Please provide server address for internal requests from ONLYOFFICE Docs", ["app" => $this->appName]); - return; + return; } $this->logger->debug("ONLYOFFICE check started by cron", ["app" => $this->appName]); $documentService = new DocumentService($this->trans, $this->config); - list ($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); + list($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); if (!empty($error)) { $this->logger->info("ONLYOFFICE server is not available", ["app" => $this->appName]); @@ -158,7 +162,8 @@ protected function run($argument) { * * @return string[] */ - private function getUsersToNotify() { + private function getUsersToNotify() + { $notifyGroups = ["admin"]; $notifyUsers = []; @@ -179,7 +184,8 @@ private function getUsersToNotify() { * Send notification to admins * @return void */ - private function notifyAdmins() { + private function notifyAdmins() + { $notificationManager = \OC::$server->getNotificationManager(); $notification = $notificationManager->createNotification(); $notification->setApp($this->appName) diff --git a/lib/crypt.php b/lib/crypt.php index 5b81ab40..eed600cb 100644 --- a/lib/crypt.php +++ b/lib/crypt.php @@ -26,7 +26,8 @@ * * @package OCA\Onlyoffice */ -class Crypt { +class Crypt +{ /** * Application configuration @@ -38,7 +39,8 @@ class Crypt { /** * @param AppConfig $config - application configutarion */ - public function __construct(AppConfig $appConfig) { + public function __construct(AppConfig $appConfig) + { $this->config = $appConfig; } @@ -49,7 +51,8 @@ public function __construct(AppConfig $appConfig) { * * @return string */ - public function GetHash($object) { + public function GetHash($object) + { return \Firebase\JWT\JWT::encode($object, $this->config->GetSKey(), "HS256"); } @@ -60,7 +63,8 @@ public function GetHash($object) { * * @return array */ - public function ReadHash($token) { + public function ReadHash($token) + { $result = null; $error = null; if ($token === null) { diff --git a/lib/directeditor.php b/lib/directeditor.php index d9a76157..66b2b7f3 100644 --- a/lib/directeditor.php +++ b/lib/directeditor.php @@ -37,7 +37,8 @@ * * @package OCA\Onlyoffice */ -class DirectEditor implements IEditor { +class DirectEditor implements IEditor +{ /** * Application name @@ -89,12 +90,14 @@ class DirectEditor implements IEditor { * @param AppConfig $config - application configuration * @param Crypt $crypt - hash generator */ - public function __construct($AppName, - IURLGenerator $urlGenerator, - IL10N $trans, - ILogger $logger, - AppConfig $config, - Crypt $crypt) { + public function __construct( + $AppName, + IURLGenerator $urlGenerator, + IL10N $trans, + ILogger $logger, + AppConfig $config, + Crypt $crypt + ) { $this->appName = $AppName; $this->urlGenerator = $urlGenerator; $this->trans = $trans; @@ -108,7 +111,8 @@ public function __construct($AppName, * * @return string */ - public function getId(): string { + public function getId(): string + { return $this->appName; } @@ -117,7 +121,8 @@ public function getId(): string { * * @return string */ - public function getName(): string { + public function getName(): string + { return "ONLYOFFICE"; } @@ -126,7 +131,8 @@ public function getName(): string { * * @return array */ - public function getMimetypes(): array { + public function getMimetypes(): array + { $mimes = array(); if (!$this->config->isUserAllowedToUse()) { return $mimes; @@ -148,7 +154,8 @@ public function getMimetypes(): array { * * @return array */ - public function getMimetypesOptional(): array { + public function getMimetypesOptional(): array + { $mimes = array(); if (!$this->config->isUserAllowedToUse()) { return $mimes; @@ -170,7 +177,8 @@ public function getMimetypesOptional(): array { * * @return array of ACreateFromTemplate|ACreateEmpty */ - public function getCreators(): array { + public function getCreators(): array + { if (!$this->config->isUserAllowedToUse()) { return array(); } @@ -187,7 +195,8 @@ public function getCreators(): array { * * @return bool */ - public function isSecure(): bool { + public function isSecure(): bool + { return true; } @@ -202,7 +211,8 @@ public function isSecure(): bool { * * @return Response */ - public function open(IToken $token): Response { + public function open(IToken $token): Response + { try { $token->useTokenScope(); $file = $token->getFile(); @@ -274,7 +284,8 @@ public function open(IToken $token): Response { * * @return TemplateResponse */ - private function renderError($error, $hint = "") { + private function renderError($error, $hint = "") + { return new TemplateResponse("", "error", [ "errors" => [ [ diff --git a/lib/documentservice.php b/lib/documentservice.php index 75a2b2b2..8bd2079b 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -28,7 +28,8 @@ * * @package OCA\Onlyoffice */ -class DocumentService { +class DocumentService +{ /** * Application name @@ -55,7 +56,8 @@ class DocumentService { * @param IL10N $trans - l10n service * @param AppConfig $config - application configutarion */ - public function __construct(IL10N $trans, AppConfig $appConfig) { + public function __construct(IL10N $trans, AppConfig $appConfig) + { $this->trans = $trans; $this->config = $appConfig; } @@ -67,9 +69,10 @@ public function __construct(IL10N $trans, AppConfig $appConfig) { * * @return string */ - public static function GenerateRevisionId($expected_key) { + public static function GenerateRevisionId($expected_key) + { if (strlen($expected_key) > 20) { - $expected_key = crc32( $expected_key); + $expected_key = crc32($expected_key); } $key = preg_replace("[^0-9-.a-zA-Z_=]", "_", $expected_key); $key = substr($key, 0, min(array(strlen($key), 20))); @@ -87,7 +90,8 @@ public static function GenerateRevisionId($expected_key) { * * @return string */ - function GetConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id, $region = null) { + public function GetConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id, $region = null) + { $responceFromConvertService = $this->SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, false, $region); $errorElement = $responceFromConvertService->Error; @@ -116,7 +120,8 @@ function GetConvertedUri($document_uri, $from_extension, $to_extension, $documen * * @return array */ - function SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, $region = null) { + public function SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, $region = null) + { $documentServerUrl = $this->config->GetDocumentServerInternalUrl(); if (empty($documentServerUrl)) { @@ -178,7 +183,7 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi libxml_use_internal_errors(true); if (!function_exists("simplexml_load_file")) { - throw new \Exception($this->trans->t("Server can't read xml")); + throw new \Exception($this->trans->t("Server can't read xml")); } $response_data = simplexml_load_string($response_xml_data); if (!$response_data) { @@ -186,7 +191,7 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi foreach(libxml_get_errors() as $error) { $exc = $exc . "\t" . $error->message; } - throw new \Exception ($exc); + throw new \Exception($exc); } return $response_data; @@ -199,7 +204,8 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi * * @return null */ - function ProcessConvServResponceError($errorCode) { + public function ProcessConvServResponceError($errorCode) + { $errorMessageTemplate = $this->trans->t("Error occurred in the document service"); $errorMessage = ""; @@ -246,7 +252,8 @@ function ProcessConvServResponceError($errorCode) { * * @return bool */ - function HealthcheckRequest() { + public function HealthcheckRequest() + { $documentServerUrl = $this->config->GetDocumentServerInternalUrl(); @@ -268,7 +275,8 @@ function HealthcheckRequest() { * * @return array */ - function CommandRequest($method) { + public function CommandRequest($method) + { $documentServerUrl = $this->config->GetDocumentServerInternalUrl(); @@ -317,7 +325,8 @@ function CommandRequest($method) { * * @return null */ - function ProcessCommandServResponceError($errorCode) { + public function ProcessCommandServResponceError($errorCode) + { $errorMessageTemplate = $this->trans->t("Error occurred in the document service"); $errorMessage = ""; @@ -350,7 +359,8 @@ function ProcessCommandServResponceError($errorCode) { * * @return string */ - public function Request($url, $method = "get", $opts = null) { + public function Request($url, $method = "get", $opts = null) + { $httpClientService = \OC::$server->getHTTPClientService(); $client = $httpClientService->newClient(); @@ -385,7 +395,8 @@ public function Request($url, $method = "get", $opts = null) { * * @return array */ - public function checkDocServiceUrl($urlGenerator, $crypt) { + public function checkDocServiceUrl($urlGenerator, $crypt) + { $logger = \OC::$server->getLogger(); $version = null; diff --git a/lib/extrapermissions.php b/lib/extrapermissions.php index ea9177e3..77b31c23 100644 --- a/lib/extrapermissions.php +++ b/lib/extrapermissions.php @@ -33,7 +33,8 @@ * * @package OCA\Onlyoffice */ -class ExtraPermissions { +class ExtraPermissions +{ /** * Application name @@ -85,10 +86,12 @@ class ExtraPermissions { * @param AppConfig $config - application configuration * @param IManager $shareManager - Share manager */ - public function __construct($AppName, - ILogger $logger, - IManager $shareManager, - AppConfig $config) { + public function __construct( + $AppName, + ILogger $logger, + IManager $shareManager, + AppConfig $config + ) { $this->appName = $AppName; $this->logger = $logger; $this->shareManager = $shareManager; @@ -102,7 +105,8 @@ public function __construct($AppName, * * @return array */ - public function getExtra($shareId) { + public function getExtra($shareId) + { $share = $this->getShare($shareId); if (empty($share)) { return null; @@ -145,7 +149,8 @@ public function getExtra($shareId) { * * @return array */ - public function getExtras($shares) { + public function getExtras($shares) + { $result = []; $shareIds = []; @@ -212,7 +217,8 @@ public function getExtras($shares) { * * @return bool */ - public function setExtra($shareId, $permissions, $extraId) { + public function setExtra($shareId, $permissions, $extraId) + { $result = false; $share = $this->getShare($shareId); @@ -242,7 +248,8 @@ public function setExtra($shareId, $permissions, $extraId) { * * @return bool */ - public static function delete($shareId) { + public static function delete($shareId) + { $connection = \OC::$server->getDatabaseConnection(); $delete = $connection->prepare(" DELETE FROM `*PREFIX*" . self::TableName_Key . "` @@ -258,7 +265,8 @@ public static function delete($shareId) { * * @return bool */ - public static function deleteList($shareIds) { + public static function deleteList($shareIds) + { $connection = \OC::$server->getDatabaseConnection(); $condition = ""; @@ -282,7 +290,8 @@ public static function deleteList($shareIds) { * * @return array */ - private static function get($shareId) { + private static function get($shareId) + { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT id, share_id, permissions @@ -314,7 +323,8 @@ private static function get($shareId) { * * @return array */ - private static function getList($shareIds) { + private static function getList($shareIds) + { $connection = \OC::$server->getDatabaseConnection(); $condition = ""; @@ -356,7 +366,8 @@ private static function getList($shareIds) { * * @return bool */ - private static function insert($shareId, $permissions) { + private static function insert($shareId, $permissions) + { $connection = \OC::$server->getDatabaseConnection(); $insert = $connection->prepare(" INSERT INTO `*PREFIX*" . self::TableName_Key . "` @@ -374,7 +385,8 @@ private static function insert($shareId, $permissions) { * * @return bool */ - private static function update($shareId, $permissions) { + private static function update($shareId, $permissions) + { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" UPDATE `*PREFIX*" . self::TableName_Key . "` @@ -392,7 +404,8 @@ private static function update($shareId, $permissions) { * * @return array */ - private function validation($share, $checkExtra) { + private function validation($share, $checkExtra) + { $availableExtra = self::None; $defaultExtra = self::None; @@ -437,7 +450,8 @@ private function validation($share, $checkExtra) { * * @return IShare */ - private function getShare($shareId) { + private function getShare($shareId) + { try { $share = $this->shareManager->getShareById("ocinternal:" . $shareId); } catch (ShareNotFound $e) { @@ -447,4 +461,4 @@ private function getShare($shareId) { return $share; } -} \ No newline at end of file +} diff --git a/lib/filecreator.php b/lib/filecreator.php index 8a7ac35d..428acba2 100644 --- a/lib/filecreator.php +++ b/lib/filecreator.php @@ -31,7 +31,8 @@ * * @package OCA\Onlyoffice */ -class FileCreator extends ACreateEmpty { +class FileCreator extends ACreateEmpty +{ /** * Application name @@ -65,12 +66,14 @@ class FileCreator extends ACreateEmpty { * @param string $AppName - application name * @param IL10N $trans - l10n service * @param ILogger $logger - logger - * @param string $format - format for creation + * @param string $format - format for creation */ - public function __construct($AppName, - IL10N $trans, - ILogger $logger, - $format) { + public function __construct( + $AppName, + IL10N $trans, + ILogger $logger, + $format + ) { $this->appName = $AppName; $this->trans = $trans; $this->logger = $logger; @@ -82,7 +85,8 @@ public function __construct($AppName, * * @return string */ - public function getId(): string { + public function getId(): string + { return $this->appName . "_" . $this->format; } @@ -91,7 +95,8 @@ public function getId(): string { * * @return string */ - public function getName(): string { + public function getName(): string + { switch ($this->format) { case "xlsx": return $this->trans->t("New spreadsheet"); @@ -106,7 +111,8 @@ public function getName(): string { * * @return string */ - public function getExtension(): string { + public function getExtension(): string + { return $this->format; } @@ -115,7 +121,8 @@ public function getExtension(): string { * * @return array */ - public function getMimetype(): string { + public function getMimetype(): string + { switch ($this->format) { case "xlsx": return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; @@ -132,7 +139,8 @@ public function getMimetype(): string { * @param string $creatorId - creator id * @param string $templateId - teamplate id */ - public function create(File $file, string $creatorId = null, string $templateId = null): void { + public function create(File $file, string $creatorId = null, string $templateId = null): void + { $this->logger->debug("FileCreator: " . $file->getId() . " " . $file->getName() . " $creatorId $templateId", ["app" => $this->appName]); $fileName = $file->getName(); diff --git a/lib/fileutility.php b/lib/fileutility.php index 1da46e9a..0f28b81d 100644 --- a/lib/fileutility.php +++ b/lib/fileutility.php @@ -36,7 +36,8 @@ * * @package OCA\Onlyoffice */ -class FileUtility { +class FileUtility +{ /** * Application name @@ -88,12 +89,14 @@ class FileUtility { * @param IManager $shareManager - Share manager * @param IManager $ISession - Session */ - public function __construct($AppName, - IL10N $trans, - ILogger $logger, - AppConfig $config, - IManager $shareManager, - ISession $session) { + public function __construct( + $AppName, + IL10N $trans, + ILogger $logger, + AppConfig $config, + IManager $shareManager, + ISession $session + ) { $this->appName = $AppName; $this->trans = $trans; $this->logger = $logger; @@ -111,8 +114,9 @@ public function __construct($AppName, * * @return array */ - public function getFileByToken($fileId, $shareToken, $path = null) { - list ($node, $error, $share) = $this->getNodeByToken($shareToken); + public function getFileByToken($fileId, $shareToken, $path = null) + { + list($node, $error, $share) = $this->getNodeByToken($shareToken); if (isset($error)) { return [null, $error, null]; @@ -154,8 +158,9 @@ public function getFileByToken($fileId, $shareToken, $path = null) { * * @return array */ - public function getNodeByToken($shareToken) { - list ($share, $error) = $this->getShare($shareToken); + public function getNodeByToken($shareToken) + { + list($share, $error) = $this->getShare($shareToken); if (isset($error)) { return [null, $error, null]; @@ -182,7 +187,8 @@ public function getNodeByToken($shareToken) { * * @return array */ - public function getShare($shareToken) { + public function getShare($shareToken) + { if (empty($shareToken)) { return [null, $this->trans->t("FileId is empty")]; } @@ -216,7 +222,8 @@ public function getShare($shareToken) { * * @return string */ - public function getKey($file, $origin = false) { + public function getKey($file, $origin = false) + { $fileId = $file->getId(); if ($origin @@ -230,7 +237,7 @@ public function getKey($file, $origin = false) { $key = KeyManager::get($fileId); - if (empty($key) ) { + if (empty($key)) { $instanceId = $this->config->GetSystemValue("instanceid", true); $key = $instanceId . "_" . $this->GUID(); @@ -248,8 +255,7 @@ public function getKey($file, $origin = false) { */ private function GUID() { - if (function_exists("com_create_guid") === true) - { + if (function_exists("com_create_guid") === true) { return trim(com_create_guid(), "{}"); } @@ -263,7 +269,8 @@ private function GUID() * * @return string */ - public function getVersionKey($version) { + public function getVersionKey($version) + { $instanceId = $this->config->GetSystemValue("instanceid", true); $key = $instanceId . "_" . $version->getSourceFile()->getEtag() . "_" . $version->getRevisionId(); diff --git a/lib/fileversions.php b/lib/fileversions.php index e7399df5..f866316a 100644 --- a/lib/fileversions.php +++ b/lib/fileversions.php @@ -34,7 +34,8 @@ * * @package OCA\Onlyoffice */ -class FileVersions { +class FileVersions +{ /** * Application name @@ -71,7 +72,8 @@ class FileVersions { * * @return array */ - public static function splitPathVersion($pathVersion) { + public static function splitPathVersion($pathVersion) + { if (empty($pathVersion)) { return false; } @@ -90,7 +92,8 @@ public static function splitPathVersion($pathVersion) { * * @return bool */ - private static function checkFolderExist($view, $path, $createIfNotExist = false) { + private static function checkFolderExist($view, $path, $createIfNotExist = false) + { if ($view->is_dir($path)) { return true; } @@ -110,7 +113,8 @@ private static function checkFolderExist($view, $path, $createIfNotExist = false * * @return array */ - private static function getView($userId, $fileId, $createIfNotExist = false) { + private static function getView($userId, $fileId, $createIfNotExist = false) + { $view = new View("/" . $userId); $path = self::$appName; @@ -140,14 +144,15 @@ private static function getView($userId, $fileId, $createIfNotExist = false) { * * @return array */ - public static function getHistoryData($ownerId, $fileId, $versionId, $prevVersion) { + public static function getHistoryData($ownerId, $fileId, $versionId, $prevVersion) + { $logger = \OC::$server->getLogger(); if ($ownerId === null || $fileId === null) { return null; } - list ($view, $path) = self::getView($ownerId, $fileId); + list($view, $path) = self::getView($ownerId, $fileId); if ($view === null) { return null; } @@ -192,12 +197,13 @@ public static function getHistoryData($ownerId, $fileId, $versionId, $prevVersio * * @return bool */ - public static function hasChanges($ownerId, $fileId, $versionId) { + public static function hasChanges($ownerId, $fileId, $versionId) + { if ($ownerId === null || $fileId === null) { return false; } - list ($view, $path) = self::getView($ownerId, $fileId); + list($view, $path) = self::getView($ownerId, $fileId); if ($view === null) { return false; } @@ -215,12 +221,13 @@ public static function hasChanges($ownerId, $fileId, $versionId) { * * @return File */ - public static function getChangesFile($ownerId, $fileId, $versionId) { + public static function getChangesFile($ownerId, $fileId, $versionId) + { if ($ownerId === null || $fileId === null) { return null; } - list ($view, $path) = self::getView($ownerId, $fileId); + list($view, $path) = self::getView($ownerId, $fileId); if ($view === null) { return null; } @@ -248,7 +255,8 @@ public static function getChangesFile($ownerId, $fileId, $versionId) { * @param string $changes - file changes * @param string $prevVersion - previous version for check */ - public static function saveHistory($fileInfo, $history, $changes, $prevVersion) { + public static function saveHistory($fileInfo, $history, $changes, $prevVersion) + { $logger = \OC::$server->getLogger(); if ($fileInfo === null) { @@ -272,7 +280,7 @@ public static function saveHistory($fileInfo, $history, $changes, $prevVersion) $fileId = $fileInfo->getId(); $versionId = $fileInfo->getMtime(); - list ($view, $path) = self::getView($ownerId, $fileId, true); + list($view, $path) = self::getView($ownerId, $fileId, true); try { $changesPath = $path . "/" . $versionId . self::$changesExt; @@ -296,7 +304,8 @@ public static function saveHistory($fileInfo, $history, $changes, $prevVersion) * @param string $ownerId - file owner id * @param string $fileId - file id */ - public static function deleteAllVersions($ownerId, $fileId = null) { + public static function deleteAllVersions($ownerId, $fileId = null) + { $logger = \OC::$server->getLogger(); $logger->debug("deleteAllVersions $ownerId $fileId", ["app" => self::$appName]); @@ -305,7 +314,7 @@ public static function deleteAllVersions($ownerId, $fileId = null) { return; } - list ($view, $path) = self::getView($ownerId, $fileId); + list($view, $path) = self::getView($ownerId, $fileId); if ($view === null) { return; } @@ -320,7 +329,8 @@ public static function deleteAllVersions($ownerId, $fileId = null) { * @param string $fileId - file id * @param string $versionId - file version */ - public static function deleteVersion($ownerId, $fileId, $versionId) { + public static function deleteVersion($ownerId, $fileId, $versionId) + { $logger = \OC::$server->getLogger(); $logger->debug("deleteVersion $fileId ($versionId)", ["app" => self::$appName]); @@ -332,7 +342,7 @@ public static function deleteVersion($ownerId, $fileId, $versionId) { return; } - list ($view, $path) = self::getView($ownerId, $fileId); + list($view, $path) = self::getView($ownerId, $fileId); if ($view === null) { return null; } @@ -353,7 +363,8 @@ public static function deleteVersion($ownerId, $fileId, $versionId) { /** * Clear all version history */ - public static function clearHistory() { + public static function clearHistory() + { $logger = \OC::$server->getLogger(); $userDatabase = new Database(); @@ -378,7 +389,8 @@ public static function clearHistory() { * @param FileInfo $fileInfo - file info * @param IUser $author - version author */ - public static function saveAuthor($fileInfo, $author) { + public static function saveAuthor($fileInfo, $author) + { $logger = \OC::$server->getLogger(); if ($fileInfo === null || $author === null) { @@ -398,7 +410,7 @@ public static function saveAuthor($fileInfo, $author) { $fileId = $fileInfo->getId(); $versionId = $fileInfo->getMtime(); - list ($view, $path) = self::getView($ownerId, $fileId, true); + list($view, $path) = self::getView($ownerId, $fileId, true); try { $authorPath = $path . "/" . $versionId . self::$authorExt; @@ -425,12 +437,13 @@ public static function saveAuthor($fileInfo, $author) { * * @return array */ - public static function getAuthor($ownerId, $fileId, $versionId) { + public static function getAuthor($ownerId, $fileId, $versionId) + { if ($ownerId === null || $fileId === null) { return null; } - list ($view, $path) = self::getView($ownerId, $fileId); + list($view, $path) = self::getView($ownerId, $fileId); if ($view === null) { return null; } @@ -455,7 +468,8 @@ public static function getAuthor($ownerId, $fileId, $versionId) { * @param string $fileId - file id * @param string $versionId - file version */ - public static function deleteAuthor($ownerId, $fileId, $versionId) { + public static function deleteAuthor($ownerId, $fileId, $versionId) + { $logger = \OC::$server->getLogger(); $logger->debug("deleteAuthor $fileId ($versionId)", ["app" => self::$appName]); @@ -467,7 +481,7 @@ public static function deleteAuthor($ownerId, $fileId, $versionId) { return; } - list ($view, $path) = self::getView($ownerId, $fileId); + list($view, $path) = self::getView($ownerId, $fileId); if ($view === null) { return null; } @@ -482,7 +496,8 @@ public static function deleteAuthor($ownerId, $fileId, $versionId) { /** * Get version compare with files_versions */ - public static function getFilesVersionAppInfoCompareResult () { + public static function getFilesVersionAppInfoCompareResult() + { $filesVersionAppInfo = \OC::$server->getAppManager()->getAppInfo("files_versions"); return \version_compare($filesVersionAppInfo["version"], "1.19"); } @@ -492,7 +507,8 @@ public static function getFilesVersionAppInfoCompareResult () { * * @param array $versions - versions array */ - public static function processVersionsArray($versions) { + public static function processVersionsArray($versions) + { if (self::getFilesVersionAppInfoCompareResult() === -1) { return array_reverse($versions); } else { diff --git a/lib/hooks.php b/lib/hooks.php index 0ee3274c..8ca4b770 100644 --- a/lib/hooks.php +++ b/lib/hooks.php @@ -32,7 +32,8 @@ * * @package OCA\Onlyoffice */ -class Hooks { +class Hooks +{ /** * Application name @@ -41,7 +42,8 @@ class Hooks { */ private static $appName = "onlyoffice"; - public static function connectHooks() { + public static function connectHooks() + { // Listen user deletion Util::connectHook("OC_User", "pre_deleteUser", Hooks::class, "userDelete"); @@ -66,7 +68,8 @@ public static function connectHooks() { * * @param array $params - hook params */ - public static function userDelete($params) { + public static function userDelete($params) + { $userId = $params["uid"]; FileVersions::deleteAllVersions($userId); @@ -77,7 +80,8 @@ public static function userDelete($params) { * * @param array $params - hook params */ - public static function fileUpdate($params) { + public static function fileUpdate($params) + { $filePath = $params[Filesystem::signal_param_path]; if (empty($filePath)) { return; @@ -100,7 +104,8 @@ public static function fileUpdate($params) { * * @param array $params - hook params */ - public static function fileDelete($params) { + public static function fileDelete($params) + { $filePath = $params[Filesystem::signal_param_path]; if (empty($filePath)) { return; @@ -133,14 +138,15 @@ public static function fileDelete($params) { * * @param array $params - hook param */ - public static function fileVersionDelete($params) { + public static function fileVersionDelete($params) + { $pathVersion = $params["path"]; if (empty($pathVersion)) { return; } try { - list ($filePath, $versionId) = FileVersions::splitPathVersion($pathVersion); + list($filePath, $versionId) = FileVersions::splitPathVersion($pathVersion); if (empty($filePath)) { return; } @@ -169,7 +175,8 @@ public static function fileVersionDelete($params) { * * @param array $params - hook param */ - public static function fileVersionRestore($params) { + public static function fileVersionRestore($params) + { $filePath = $params["path"]; if (empty($filePath)) { return; @@ -204,7 +211,8 @@ public static function fileVersionRestore($params) { * * @param array $params - hook param */ - public static function extraPermissionsDelete($params) { + public static function extraPermissionsDelete($params) + { $shares = $params["deletedShares"]; if (empty($shares)) { return; diff --git a/lib/keymanager.php b/lib/keymanager.php index eed738bf..07149142 100644 --- a/lib/keymanager.php +++ b/lib/keymanager.php @@ -24,7 +24,8 @@ * * @package OCA\Onlyoffice */ -class KeyManager { +class KeyManager +{ /** * Table name @@ -38,7 +39,8 @@ class KeyManager { * * @return string */ - public static function get($fileId) { + public static function get($fileId) + { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT `key` @@ -61,7 +63,8 @@ public static function get($fileId) { * * @return bool */ - public static function set($fileId, $key) { + public static function set($fileId, $key) + { $connection = \OC::$server->getDatabaseConnection(); $insert = $connection->prepare(" INSERT INTO `*PREFIX*" . self::TableName_Key . "` @@ -79,9 +82,11 @@ public static function set($fileId, $key) { * * @return bool */ - public static function delete($fileId, $unlock = false) { + public static function delete($fileId, $unlock = false) + { $connection = \OC::$server->getDatabaseConnection(); - $delete = $connection->prepare(" + $delete = $connection->prepare( + " DELETE FROM `*PREFIX*" . self::TableName_Key . "` WHERE `file_id` = ? " . ($unlock === false ? "AND `lock` != 1" : "") @@ -97,7 +102,8 @@ public static function delete($fileId, $unlock = false) { * * @return bool */ - public static function lock($fileId, $lock = true) { + public static function lock($fileId, $lock = true) + { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" UPDATE `*PREFIX*" . self::TableName_Key . "` @@ -115,7 +121,8 @@ public static function lock($fileId, $lock = true) { * * @return bool */ - public static function setForcesave($fileId, $fs = true) { + public static function setForcesave($fileId, $fs = true) + { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" UPDATE `*PREFIX*" . self::TableName_Key . "` @@ -132,7 +139,8 @@ public static function setForcesave($fileId, $fs = true) { * * @return bool */ - public static function wasForcesave($fileId) { + public static function wasForcesave($fileId) + { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT `fs` diff --git a/lib/listeners/directeditorlistener.php b/lib/listeners/directeditorlistener.php index e466913b..6083ec9e 100644 --- a/lib/listeners/directeditorlistener.php +++ b/lib/listeners/directeditorlistener.php @@ -29,7 +29,8 @@ /** * DirectEditor listener */ -class DirectEditorListener implements IEventListener { +class DirectEditorListener implements IEventListener +{ /** * Application configuration @@ -49,13 +50,16 @@ class DirectEditorListener implements IEventListener { * @param AppConfig $config - application configuration * @param DirectEditor $editor - direct editor */ - public function __construct(AppConfig $appConfig, - DirectEditor $editor) { + public function __construct( + AppConfig $appConfig, + DirectEditor $editor + ) { $this->appConfig = $appConfig; $this->editor = $editor; } - public function handle(Event $event): void { + public function handle(Event $event): void + { if (!$event instanceof RegisterDirectEditorEvent) { return; } @@ -66,4 +70,4 @@ public function handle(Event $event): void { $event->register($this->editor); } } -} \ No newline at end of file +} diff --git a/lib/listeners/filesharinglistener.php b/lib/listeners/filesharinglistener.php index 944c9e25..8a0fbb6d 100644 --- a/lib/listeners/filesharinglistener.php +++ b/lib/listeners/filesharinglistener.php @@ -33,7 +33,8 @@ /** * File Sharing listener */ -class FileSharingListener implements IEventListener { +class FileSharingListener implements IEventListener +{ /** * Application configuration @@ -61,15 +62,18 @@ class FileSharingListener implements IEventListener { * @param IInitialState $initialState - initial state * @param IServerContainer $serverContainer - server container */ - public function __construct(AppConfig $appConfig, - IInitialState $initialState, - IServerContainer $serverContainer) { + public function __construct( + AppConfig $appConfig, + IInitialState $initialState, + IServerContainer $serverContainer + ) { $this->appConfig = $appConfig; $this->initialState = $initialState; $this->serverContainer = $serverContainer; } - public function handle(Event $event): void { + public function handle(Event $event): void + { if (!$event instanceof BeforeTemplateRenderedEvent) { return; } @@ -90,4 +94,4 @@ public function handle(Event $event): void { Util::addStyle("onlyoffice", "main"); } } -} \ No newline at end of file +} diff --git a/lib/listeners/fileslistener.php b/lib/listeners/fileslistener.php index 07e02b1c..9a6e87d6 100644 --- a/lib/listeners/fileslistener.php +++ b/lib/listeners/fileslistener.php @@ -33,7 +33,8 @@ /** * File listener */ -class FilesListener implements IEventListener { +class FilesListener implements IEventListener +{ /** * Application configuration @@ -61,15 +62,18 @@ class FilesListener implements IEventListener { * @param IInitialState $initialState - initial state * @param IServerContainer $serverContainer - server container */ - public function __construct(AppConfig $appConfig, - IInitialState $initialState, - IServerContainer $serverContainer) { + public function __construct( + AppConfig $appConfig, + IInitialState $initialState, + IServerContainer $serverContainer + ) { $this->appConfig = $appConfig; $this->initialState = $initialState; $this->serverContainer = $serverContainer; } - public function handle(Event $event): void { + public function handle(Event $event): void + { if (!$event instanceof LoadAdditionalScriptsEvent) { return; } @@ -101,4 +105,4 @@ public function handle(Event $event): void { Util::addStyle("onlyoffice", "template"); } } -} \ No newline at end of file +} diff --git a/lib/listeners/viewerlistener.php b/lib/listeners/viewerlistener.php index 6aee3a83..dc03e319 100644 --- a/lib/listeners/viewerlistener.php +++ b/lib/listeners/viewerlistener.php @@ -34,7 +34,8 @@ /** * Viewer listener */ -class ViewerListener implements IEventListener { +class ViewerListener implements IEventListener +{ /** * Application configuration @@ -62,15 +63,18 @@ class ViewerListener implements IEventListener { * @param IInitialState $initialState - initial state * @param IServerContainer $serverContainer - server container */ - public function __construct(AppConfig $appConfig, - IInitialState $initialState, - IServerContainer $serverContainer) { + public function __construct( + AppConfig $appConfig, + IInitialState $initialState, + IServerContainer $serverContainer + ) { $this->appConfig = $appConfig; $this->initialState = $initialState; $this->serverContainer = $serverContainer; } - public function handle(Event $event): void { + public function handle(Event $event): void + { if (!$event instanceof LoadViewer) { return; } @@ -94,4 +98,4 @@ public function handle(Event $event): void { $cspManager->addDefaultPolicy($csp); } } -} \ No newline at end of file +} diff --git a/lib/listeners/widgetlistener.php b/lib/listeners/widgetlistener.php index 6d32d4a8..7f3a0777 100644 --- a/lib/listeners/widgetlistener.php +++ b/lib/listeners/widgetlistener.php @@ -29,7 +29,8 @@ /** * Widget listener */ -class WidgetListener implements IEventListener { +class WidgetListener implements IEventListener +{ /** * Application configuration @@ -41,11 +42,13 @@ class WidgetListener implements IEventListener { /** * @param AppConfig $config - application configuration */ - public function __construct(AppConfig $appConfig) { + public function __construct(AppConfig $appConfig) + { $this->appConfig = $appConfig; } - public function handle(Event $event): void { + public function handle(Event $event): void + { if (!$event instanceof RegisterWidgetEvent) { return; } @@ -56,4 +59,4 @@ public function handle(Event $event): void { Util::addScript("onlyoffice", "desktop"); } } -} \ No newline at end of file +} diff --git a/lib/notifier.php b/lib/notifier.php index a222c0e5..8adec58a 100644 --- a/lib/notifier.php +++ b/lib/notifier.php @@ -27,7 +27,8 @@ use OCP\Notification\INotification; use OCP\Notification\INotifier; -class Notifier implements INotifier { +class Notifier implements INotifier +{ /** * Application name @@ -71,12 +72,13 @@ class Notifier implements INotifier { * @param ILogger $logger - logger * @param IUserManager $userManager - user manager */ - public function __construct(string $appName, - IFactory $l10nFactory, - IURLGenerator $urlGenerator, - ILogger $logger, - IUserManager $userManager - ) { + public function __construct( + string $appName, + IFactory $l10nFactory, + IURLGenerator $urlGenerator, + ILogger $logger, + IUserManager $userManager + ) { $this->appName = $appName; $this->l10nFactory = $l10nFactory; $this->urlGenerator = $urlGenerator; @@ -89,7 +91,8 @@ public function __construct(string $appName, * * @return string */ - public function getID(): string { + public function getID(): string + { return $this->appName; } @@ -98,7 +101,8 @@ public function getID(): string { * * @return string */ - public function getName(): string { + public function getName(): string + { return $this->appName; } @@ -108,7 +112,8 @@ public function getName(): string { * * @return INotification */ - public function prepare(INotification $notification, string $languageCode): INotification { + public function prepare(INotification $notification, string $languageCode): INotification + { if ($notification->getApp() !== $this->appName) { throw new \InvalidArgumentException("Notification not from " . $this->appName); } @@ -160,6 +165,7 @@ public function prepare(INotification $notification, string $languageCode): INot "link" => $editorLink ] ]); + // no break default: $this->logger->info("Unsupported notification object: ".$notification->getObjectType(), ["app" => $this->appName]); } diff --git a/lib/preview.php b/lib/preview.php index b6ca7058..a6d7ced8 100644 --- a/lib/preview.php +++ b/lib/preview.php @@ -47,7 +47,8 @@ * * @package OCA\Onlyoffice */ -class Preview extends Provider { +class Preview extends Provider +{ /** * Application name @@ -166,16 +167,17 @@ class Preview extends Provider { * @param IManager $shareManager - share manager * @param ISession $session - session */ - public function __construct(string $appName, - IRootFolder $root, - ILogger $logger, - IL10N $trans, - AppConfig $config, - IURLGenerator $urlGenerator, - Crypt $crypt, - IManager $shareManager, - ISession $session - ) { + public function __construct( + string $appName, + IRootFolder $root, + ILogger $logger, + IL10N $trans, + AppConfig $config, + IURLGenerator $urlGenerator, + Crypt $crypt, + IManager $shareManager, + ISession $session + ) { $this->appName = $appName; $this->root = $root; $this->logger = $logger; @@ -198,7 +200,8 @@ public function __construct(string $appName, /** * Return mime type */ - public static function getMimeTypeRegex() { + public static function getMimeTypeRegex() + { $mimeTypeRegex = ""; foreach (self::$capabilities as $format) { if (!empty($mimeTypeRegex)) { @@ -214,7 +217,8 @@ public static function getMimeTypeRegex() { /** * Return mime type */ - public function getMimeType() { + public function getMimeType() + { $m = self::getMimeTypeRegex(); return $m; } @@ -226,11 +230,12 @@ public function getMimeType() { * * @return bool */ - public function isAvailable(FileInfo $fileInfo) { + public function isAvailable(FileInfo $fileInfo) + { if ($this->config->GetPreview() !== true) { return false; } - if (!$fileInfo + if (!$fileInfo || $fileInfo->getSize() === 0 || $fileInfo->getSize() > $this->config->GetLimitThumbSize()) { return false; @@ -255,10 +260,11 @@ public function isAvailable(FileInfo $fileInfo) { * * @return Image|bool false if no preview was generated */ - public function getThumbnail($path, $maxX, $maxY, $scalingup, $view) { + public function getThumbnail($path, $maxX, $maxY, $scalingup, $view) + { $this->logger->debug("getThumbnail $path $maxX $maxY", ["app" => $this->appName]); - list ($fileUrl, $extension, $key) = $this->getFileParam($path, $view); + list($fileUrl, $extension, $key) = $this->getFileParam($path, $view); if ($fileUrl === null || $extension === null || $key === null) { return false; } @@ -300,7 +306,8 @@ public function getThumbnail($path, $maxX, $maxY, $scalingup, $view) { * * @return string */ - private function getUrl($file, $user = null, $version = 0, $template = false) { + private function getUrl($file, $user = null, $version = 0, $template = false) + { $data = [ "action" => "download", @@ -338,7 +345,8 @@ private function getUrl($file, $user = null, $version = 0, $template = false) { * * @return array */ - private function getFileParam($path, $view) { + private function getFileParam($path, $view) + { $fileInfo = $view->getFileInfo($path); if (!$fileInfo || $fileInfo->getSize() === 0) { @@ -359,7 +367,7 @@ private function getFileParam($path, $view) { $absolutePath = $fileInfo->getPath(); $relativePath = $versionFolder->getRelativePath($absolutePath); - list ($filePath, $fileVersion) = FileVersions::splitPathVersion($relativePath); + list($filePath, $fileVersion) = FileVersions::splitPathVersion($relativePath); if ($filePath === null) { return [null, null, null]; } @@ -395,4 +403,4 @@ private function getFileParam($path, $view) { return [$fileUrl, $fileExtension, $key]; } -} \ No newline at end of file +} diff --git a/lib/remoteinstance.php b/lib/remoteinstance.php index ef80d57d..6afbec3d 100644 --- a/lib/remoteinstance.php +++ b/lib/remoteinstance.php @@ -28,7 +28,8 @@ * * @package OCA\Onlyoffice */ -class RemoteInstance { +class RemoteInstance +{ /** * App name @@ -57,7 +58,8 @@ class RemoteInstance { * * @return array */ - private static function get($remote) { + private static function get($remote) + { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT remote, expire, status @@ -79,7 +81,8 @@ private static function get($remote) { * * @return bool */ - private static function set($remote, $status) { + private static function set($remote, $status) + { $connection = \OC::$server->getDatabaseConnection(); $insert = $connection->prepare(" INSERT INTO `*PREFIX*" . self::TableName_Key . "` @@ -97,7 +100,8 @@ private static function set($remote, $status) { * * @return bool */ - private static function update($remote, $status) { + private static function update($remote, $status) + { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" UPDATE `*PREFIX*" . self::TableName_Key . "` @@ -114,7 +118,8 @@ private static function update($remote, $status) { * * @return bool */ - public static function healthCheck($remote) { + public static function healthCheck($remote) + { $logger = \OC::$server->getLogger(); $remote = rtrim($remote, "/") . "/"; @@ -168,7 +173,8 @@ public static function healthCheck($remote) { * * @return string */ - public static function getRemoteKey($file) { + public static function getRemoteKey($file) + { $logger = \OC::$server->getLogger(); $remote = rtrim($file->getStorage()->getRemote(), "/") . "/"; @@ -220,7 +226,8 @@ public static function getRemoteKey($file) { * * @return bool */ - public static function lockRemoteKey($file, $lock, $fs) { + public static function lockRemoteKey($file, $lock, $fs) + { $logger = \OC::$server->getLogger(); $action = $lock ? "lock" : "unlock"; @@ -270,7 +277,8 @@ public static function lockRemoteKey($file, $lock, $fs) { * * @return bool */ - public static function isRemoteFile($file) { + public static function isRemoteFile($file) + { $storage = $file->getStorage(); $alive = false; @@ -282,4 +290,4 @@ public static function isRemoteFile($file) { $alive = RemoteInstance::healthCheck($storage->getRemote()); return $alive; } -} \ No newline at end of file +} diff --git a/lib/settingsdata.php b/lib/settingsdata.php index d246cf02..6482d20b 100644 --- a/lib/settingsdata.php +++ b/lib/settingsdata.php @@ -21,7 +21,8 @@ use OCA\Onlyoffice\AppConfig; -class SettingsData implements \JsonSerializable { +class SettingsData implements \JsonSerializable +{ /** * Application configuration @@ -30,11 +31,13 @@ class SettingsData implements \JsonSerializable { */ private $appConfig; - public function __construct(AppConfig $appConfig) { + public function __construct(AppConfig $appConfig) + { $this->appConfig = $appConfig; } - public function jsonSerialize(): array { + public function jsonSerialize(): array + { $data = [ "formats" => $this->appConfig->FormatsSetting(), "sameTab" => $this->appConfig->GetSameTab() @@ -42,4 +45,4 @@ public function jsonSerialize(): array { return $data; } -} \ No newline at end of file +} diff --git a/lib/templatemanager.php b/lib/templatemanager.php index 7ec2bbd8..50fad250 100644 --- a/lib/templatemanager.php +++ b/lib/templatemanager.php @@ -28,7 +28,8 @@ * * @package OCA\Onlyoffice */ -class TemplateManager { +class TemplateManager +{ /** * Application name @@ -49,7 +50,8 @@ class TemplateManager { * * @return Folder */ - public static function GetGlobalTemplateDir() { + public static function GetGlobalTemplateDir() + { $dirPath = "appdata_" . \OC::$server->getConfig()->GetSystemValue("instanceid", null) . "/" . self::$appName . "/" . self::$templateFolderName; @@ -72,7 +74,8 @@ public static function GetGlobalTemplateDir() { * * @return array */ - public static function GetGlobalTemplates($mimetype = null) { + public static function GetGlobalTemplates($mimetype = null) + { $templateDir = self::GetGlobalTemplateDir(); $templatesList = $templateDir->getDirectoryListing(); @@ -91,7 +94,8 @@ public static function GetGlobalTemplates($mimetype = null) { * * @return File */ - public static function GetTemplate($templateId) { + public static function GetTemplate($templateId) + { $logger = \OC::$server->getLogger(); if (empty($templateId)) { @@ -121,7 +125,8 @@ public static function GetTemplate($templateId) { * * @return string */ - public static function GetTypeTemplate($mime) { + public static function GetTypeTemplate($mime) + { switch($mime) { case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return "document"; @@ -141,7 +146,8 @@ public static function GetTypeTemplate($mime) { * * @return string */ - public static function GetMimeTemplate($type) { + public static function GetMimeTemplate($type) + { switch($type) { case "document": return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; @@ -161,7 +167,8 @@ public static function GetMimeTemplate($type) { * * @return bool */ - public static function IsTemplateType($name) { + public static function IsTemplateType($name) + { $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); switch($ext) { case "docx": @@ -180,7 +187,8 @@ public static function IsTemplateType($name) { * * @return bool */ - public static function IsTemplate($fileId) { + public static function IsTemplate($fileId) + { $template = self::GetTemplate($fileId); if (empty($template)) { @@ -197,7 +205,8 @@ public static function IsTemplate($fileId) { * * @return string */ - public static function GetEmptyTemplate($name) { + public static function GetEmptyTemplate($name) + { $ext = strtolower("." . pathinfo($name, PATHINFO_EXTENSION)); $lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode(); @@ -219,7 +228,8 @@ public static function GetEmptyTemplate($name) { * * @return string */ - public static function GetEmptyTemplatePath($lang, $ext) { + public static function GetEmptyTemplatePath($lang, $ext) + { if (!array_key_exists($lang, self::$localPath)) { $lang = "en"; } diff --git a/lib/templateprovider.php b/lib/templateprovider.php index 7ea9124c..36526758 100644 --- a/lib/templateprovider.php +++ b/lib/templateprovider.php @@ -26,7 +26,8 @@ use OCA\Onlyoffice\TemplateManager; -class TemplateProvider implements ICustomTemplateProvider { +class TemplateProvider implements ICustomTemplateProvider +{ /** * Application name @@ -46,7 +47,8 @@ class TemplateProvider implements ICustomTemplateProvider { * @param string $AppName - application name * @param IURLGenerator $urlGenerator - url generator service */ - public function __construct($AppName, IURLGenerator $urlGenerator) { + public function __construct($AppName, IURLGenerator $urlGenerator) + { $this->appName = $AppName; $this->urlGenerator = $urlGenerator; } @@ -58,7 +60,8 @@ public function __construct($AppName, IURLGenerator $urlGenerator) { * * @return array */ - public function getCustomTemplates($mimetype) : array { + public function getCustomTemplates($mimetype) : array + { $templates = []; $templateFiles = TemplateManager::GetGlobalTemplates($mimetype); @@ -85,7 +88,8 @@ public function getCustomTemplates($mimetype) : array { * * @return File */ - public function getCustomTemplate($templateId) : File { + public function getCustomTemplate($templateId) : File + { return TemplateManager::GetTemplate($templateId); } -} \ No newline at end of file +} From 8ad1c3390bba8308d2d4a6a196a0fbda59312e22 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 4 Oct 2023 12:05:41 +0300 Subject: [PATCH 005/209] align multiline comment --- controller/callbackcontroller.php | 2 +- controller/editorapicontroller.php | 8 ++++---- controller/editorcontroller.php | 2 +- controller/sharingapicontroller.php | 4 ++-- lib/fileversions.php | 6 +++--- lib/preview.php | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index ecc547b9..89acb79b 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -130,7 +130,7 @@ class CallbackController extends Controller * Lock manager * * @var ILockManager - */ + */ private $lockManager; /** diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 0334f21f..18390064 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -127,28 +127,28 @@ class EditorApiController extends OCSController * File version manager * * @var IVersionManager - */ + */ private $versionManager; /** * Tag manager * * @var ITagManager - */ + */ private $tagManager; /** * Extra permissions * * @var ExtraPermissions - */ + */ private $extraPermissions; /** * Lock manager * * @var ILockManager - */ + */ private $lockManager; /** diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 61fc61fa..760b8668 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -125,7 +125,7 @@ class EditorController extends Controller * File version manager * * @var IVersionManager - */ + */ private $versionManager; /** diff --git a/controller/sharingapicontroller.php b/controller/sharingapicontroller.php index 9bb71bb3..26ba0e8f 100644 --- a/controller/sharingapicontroller.php +++ b/controller/sharingapicontroller.php @@ -87,14 +87,14 @@ class SharingApiController extends OCSController * Share manager * * @var IManager - */ + */ private $shareManager; /** * Extra permissions * * @var ExtraPermissions - */ + */ private $extraPermissions; /** diff --git a/lib/fileversions.php b/lib/fileversions.php index f866316a..0578791f 100644 --- a/lib/fileversions.php +++ b/lib/fileversions.php @@ -328,7 +328,7 @@ public static function deleteAllVersions($ownerId, $fileId = null) * @param string $ownerId - file owner id * @param string $fileId - file id * @param string $versionId - file version - */ + */ public static function deleteVersion($ownerId, $fileId, $versionId) { $logger = \OC::$server->getLogger(); @@ -467,7 +467,7 @@ public static function getAuthor($ownerId, $fileId, $versionId) * @param string $ownerId - file owner id * @param string $fileId - file id * @param string $versionId - file version - */ + */ public static function deleteAuthor($ownerId, $fileId, $versionId) { $logger = \OC::$server->getLogger(); @@ -506,7 +506,7 @@ public static function getFilesVersionAppInfoCompareResult() * Reverese or not versions array * * @param array $versions - versions array - */ + */ public static function processVersionsArray($versions) { if (self::getFilesVersionAppInfoCompareResult() === -1) { diff --git a/lib/preview.php b/lib/preview.php index a6d7ced8..0c385786 100644 --- a/lib/preview.php +++ b/lib/preview.php @@ -103,7 +103,7 @@ class Preview extends Provider * File version manager * * @var IVersionManager - */ + */ private $versionManager; /** From c2b4ff82be052e4edd662cc4614ac95e9b0b8be7 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 4 Oct 2023 12:06:43 +0300 Subject: [PATCH 006/209] array indentation --- controller/editorcontroller.php | 12 ++++++------ controller/settingscontroller.php | 8 ++++---- lib/directeditor.php | 12 ++++++------ lib/notifier.php | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 760b8668..d7212064 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -1458,12 +1458,12 @@ private function buildUserId($userId) private function renderError($error, $hint = "") { return new TemplateResponse("", "error", [ - "errors" => [ - [ - "error" => $error, - "hint" => $hint - ] + "errors" => [ + [ + "error" => $error, + "hint" => $hint ] - ], "error"); + ] + ], "error"); } } diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 47fcaa65..3cb09f67 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -196,7 +196,7 @@ public function SaveAddress( "jwtHeader" => $this->config->JwtHeader(true), "error" => $error, "version" => $version, - ]; + ]; } /** @@ -254,7 +254,7 @@ public function SaveCommon( $this->config->SetCustomizationTheme($theme); return [ - ]; + ]; } /** @@ -287,7 +287,7 @@ public function SaveSecurity( $this->config->SetProtection($protection); return [ - ]; + ]; } /** @@ -301,7 +301,7 @@ public function ClearHistory() FileVersions::clearHistory(); return [ - ]; + ]; } /** diff --git a/lib/directeditor.php b/lib/directeditor.php index 66b2b7f3..0a710d3c 100644 --- a/lib/directeditor.php +++ b/lib/directeditor.php @@ -287,12 +287,12 @@ public function open(IToken $token): Response private function renderError($error, $hint = "") { return new TemplateResponse("", "error", [ - "errors" => [ - [ - "error" => $error, - "hint" => $hint - ] + "errors" => [ + [ + "error" => $error, + "hint" => $hint ] - ], "error"); + ] + ], "error"); } } diff --git a/lib/notifier.php b/lib/notifier.php index 8adec58a..bd28c7bf 100644 --- a/lib/notifier.php +++ b/lib/notifier.php @@ -164,7 +164,7 @@ public function prepare(INotification $notification, string $languageCode): INot "name" => $fileName, "link" => $editorLink ] - ]); + ]); // no break default: $this->logger->info("Unsupported notification object: ".$notification->getObjectType(), ["app" => $this->appName]); From 3628f1bf2773217500b6287f90bb3a7c4797d5a5 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 4 Oct 2023 12:07:33 +0300 Subject: [PATCH 007/209] binary operator spaces --- controller/callbackcontroller.php | 2 +- controller/editorapicontroller.php | 2 +- lib/appconfig.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 89acb79b..a29b07b0 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -534,7 +534,7 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan $documentService = new DocumentService($this->trans, $this->config); if ($downloadExt !== $curExt) { - $key = DocumentService::GenerateRevisionId($fileId . $url); + $key = DocumentService::GenerateRevisionId($fileId . $url); try { $this->logger->debug("Converted from $downloadExt to $curExt", ["app" => $this->appName]); diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 18390064..13891902 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -557,7 +557,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok if ($folderLink !== null && $this->config->GetSystemValue($this->config->_customization_goback) !== false) { $params["editorConfig"]["customization"]["goback"] = [ - "url" => $folderLink + "url" => $folderLink ]; if (!$desktop && !$inviewer) { diff --git a/lib/appconfig.php b/lib/appconfig.php index 1f31e981..6e040d55 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -1198,7 +1198,7 @@ public function GetLimitThumbSize() return $limitSize; } - return 100*1024*1024; + return 100 * 1024 * 1024; } /** @@ -1355,7 +1355,7 @@ public function GetEditorsCheckInterval() $interval = $this->GetSystemValue($this->_editors_check_interval); if (empty($interval) && $interval !== 0) { - $interval = 60*60*24; + $interval = 60 * 60 * 24; } return (integer)$interval; } From deb883d6ec74ca35492ca6abeb4a60c0a8720a12 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 4 Oct 2023 12:09:30 +0300 Subject: [PATCH 008/209] curly braces position --- controller/callbackcontroller.php | 33 +-- controller/editorapicontroller.php | 27 +-- controller/editorcontroller.php | 60 ++---- controller/federationcontroller.php | 12 +- controller/joblistcontroller.php | 18 +- controller/settingscontroller.php | 12 +- controller/sharingapicontroller.php | 12 +- controller/templatecontroller.php | 15 +- .../Version070000Date20210417111111.php | 12 +- .../Version070400Date20220607111111.php | 12 +- .../Version070400Date20220929111111.php | 12 +- lib/adminsection.php | 18 +- lib/adminsettings.php | 15 +- lib/appconfig.php | 198 ++++++------------ lib/command/documentserver.php | 9 +- lib/cron/editorscheck.php | 12 +- lib/crypt.php | 12 +- lib/directeditor.php | 27 +-- lib/documentservice.php | 33 +-- lib/extrapermissions.php | 36 ++-- lib/filecreator.php | 18 +- lib/fileutility.php | 21 +- lib/fileversions.php | 48 ++--- lib/hooks.php | 24 +-- lib/keymanager.php | 21 +- lib/listeners/directeditorlistener.php | 6 +- lib/listeners/filesharinglistener.php | 6 +- lib/listeners/fileslistener.php | 6 +- lib/listeners/viewerlistener.php | 6 +- lib/listeners/widgetlistener.php | 9 +- lib/notifier.php | 12 +- lib/preview.php | 21 +- lib/remoteinstance.php | 24 +-- lib/settingsdata.php | 9 +- lib/templatemanager.php | 30 +-- lib/templateprovider.php | 12 +- 36 files changed, 286 insertions(+), 572 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index a29b07b0..da8138da 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -60,8 +60,7 @@ * Download the file without authentication. * Save the file without authentication. */ -class CallbackController extends Controller -{ +class CallbackController extends Controller { /** * Root folder @@ -203,8 +202,7 @@ public function __construct( * @PublicPage * @CORS */ - public function download($doc) - { + public function download($doc) { list($hashData, $error) = $this->crypt->ReadHash($doc); if ($hashData === null) { @@ -328,8 +326,7 @@ public function download($doc) * @PublicPage * @CORS */ - public function emptyfile($doc) - { + public function emptyfile($doc) { $this->logger->debug("Download empty", ["app" => $this->appName]); list($hashData, $error) = $this->crypt->ReadHash($doc); @@ -398,8 +395,7 @@ public function emptyfile($doc) * @PublicPage * @CORS */ - public function track($doc, $users, $key, $status, $url, $token, $history, $changesurl, $forcesavetype, $actions, $filetype) - { + public function track($doc, $users, $key, $status, $url, $token, $history, $changesurl, $forcesavetype, $actions, $filetype) { list($hashData, $error) = $this->crypt->ReadHash($doc); if ($hashData === null) { @@ -637,8 +633,7 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan * * @return array */ - private function getFile($userId, $fileId, $filePath = null, $version = 0, $template = false) - { + private function getFile($userId, $fileId, $filePath = null, $version = 0, $template = false) { if (empty($fileId)) { return [null, new JSONResponse(["message" => $this->trans->t("FileId is empty")], Http::STATUS_BAD_REQUEST)]; } @@ -705,8 +700,7 @@ private function getFile($userId, $fileId, $filePath = null, $version = 0, $temp * * @return array */ - private function getFileByToken($fileId, $shareToken, $version = 0) - { + private function getFileByToken($fileId, $shareToken, $version = 0) { list($share, $error) = $this->getShare($shareToken); if (isset($error)) { @@ -758,8 +752,7 @@ private function getFileByToken($fileId, $shareToken, $version = 0) * * @return array */ - private function getShare($shareToken) - { + private function getShare($shareToken) { if (empty($shareToken)) { return [null, new JSONResponse(["message" => $this->trans->t("FileId is empty")], Http::STATUS_BAD_REQUEST)]; } @@ -786,8 +779,7 @@ private function getShare($shareToken) * * @return string */ - private function parseUserId($userId) - { + private function parseUserId($userId) { $instanceId = $this->config->GetSystemValue("instanceid", true); $instanceId = $instanceId . "_"; @@ -803,8 +795,7 @@ private function parseUserId($userId) * * @param File $file - file */ - private function lock($file) - { + private function lock($file) { if (!$this->lockManager->isLockProviderAvailable()) { return; } @@ -826,8 +817,7 @@ private function lock($file) * * @param File $file - file */ - private function unlock($file) - { + private function unlock($file) { if (!$this->lockManager->isLockProviderAvailable()) { return; } @@ -850,8 +840,7 @@ private function unlock($file) * * @throws LockedException */ - private function retryOperation(callable $operation) - { + private function retryOperation(callable $operation) { $i = 0; while (true) { try { diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 13891902..5a956501 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -57,8 +57,7 @@ /** * Controller with the main functions */ -class EditorApiController extends OCSController -{ +class EditorApiController extends OCSController { /** * Current user session @@ -237,8 +236,7 @@ public function __construct( * @NoAdminRequired * @PublicPage */ - public function config($fileId, $filePath = null, $shareToken = null, $directToken = null, $version = 0, $inframe = false, $inviewer = false, $desktop = false, $guestName = null, $template = false, $anchor = null) - { + public function config($fileId, $filePath = null, $shareToken = null, $directToken = null, $version = 0, $inframe = false, $inviewer = false, $desktop = false, $guestName = null, $template = false, $anchor = null) { if (!empty($directToken)) { list($directData, $error) = $this->crypt->ReadHash($directToken); @@ -619,8 +617,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok * * @return array */ - private function getFile($userId, $fileId, $filePath = null, $template = false) - { + private function getFile($userId, $fileId, $filePath = null, $template = false) { if (empty($fileId)) { return [null, $this->trans->t("FileId is empty"), null]; } @@ -669,8 +666,7 @@ private function getFile($userId, $fileId, $filePath = null, $template = false) * * @return string */ - private function getUrl($file, $user = null, $shareToken = null, $version = 0, $changes = false, $template = false) - { + private function getUrl($file, $user = null, $shareToken = null, $version = 0, $changes = false, $template = false) { $data = [ "action" => "download", @@ -713,8 +709,7 @@ private function getUrl($file, $user = null, $shareToken = null, $version = 0, $ * * @return string */ - private function buildUserId($userId) - { + private function buildUserId($userId) { $instanceId = $this->config->GetSystemValue("instanceid", true); $userId = $instanceId . "_" . $userId; return $userId; @@ -727,8 +722,7 @@ private function buildUserId($userId) * * @return array */ - private function setCustomization($params) - { + private function setCustomization($params) { //default is true if ($this->config->GetCustomizationChat() === false) { $params["editorConfig"]["customization"]["chat"] = false; @@ -825,8 +819,7 @@ private function setCustomization($params) * * @return array */ - private function setWatermark($params, $isPublic, $userId, $file) - { + private function setWatermark($params, $isPublic, $userId, $file) { $watermarkTemplate = $this->getWatermarkText( $isPublic, $userId, @@ -877,8 +870,7 @@ private function setWatermark($params, $isPublic, $userId, $file) * * @return bool|string */ - private function getWatermarkText($isPublic, $userId, $file, $canEdit, $canDownload) - { + private function getWatermarkText($isPublic, $userId, $file, $canEdit, $canDownload) { $watermarkSettings = $this->config->GetWatermarkSettings(); if (!$watermarkSettings["enabled"]) { return false; @@ -945,8 +937,7 @@ private function getWatermarkText($isPublic, $userId, $file, $canEdit, $canDownl * * @return bool */ - private function isFavorite($fileId, $userId = null) - { + private function isFavorite($fileId, $userId = null) { $currentTags = $this->tagManager->load("files", [], false, $userId)->getTagsForObjects([$fileId]); if ($currentTags) { return in_array(ITags::TAG_FAVORITE, $currentTags[$fileId]); diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index d7212064..385171a6 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -55,8 +55,7 @@ /** * Controller with the main functions */ -class EditorController extends Controller -{ +class EditorController extends Controller { /** * Current user session @@ -210,8 +209,7 @@ public function __construct( * @NoAdminRequired * @PublicPage */ - public function create($name, $dir, $templateId = null, $targetId = 0, $shareToken = null) - { + public function create($name, $dir, $templateId = null, $targetId = 0, $shareToken = null) { $this->logger->debug("Create: $name", ["app" => $this->appName]); if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { @@ -322,8 +320,7 @@ public function create($name, $dir, $templateId = null, $targetId = 0, $shareTok * @NoAdminRequired * @NoCSRFRequired */ - public function createNew($name, $dir, $templateId = null) - { + public function createNew($name, $dir, $templateId = null) { $this->logger->debug("Create from editor: $name in $dir", ["app" => $this->appName]); $result = $this->create($name, $dir, $templateId); @@ -345,8 +342,7 @@ public function createNew($name, $dir, $templateId = null) * @NoAdminRequired * @NoCSRFRequired */ - public function users($fileId) - { + public function users($fileId) { $this->logger->debug("Search users", ["app" => $this->appName]); $result = []; $currentUserGroups = []; @@ -440,8 +436,7 @@ public function users($fileId) * @NoAdminRequired * @NoCSRFRequired */ - public function mention($fileId, $anchor, $comment, $emails) - { + public function mention($fileId, $anchor, $comment, $emails) { $this->logger->debug("mention: from $fileId to " . json_encode($emails), ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -571,8 +566,7 @@ public function mention($fileId, $anchor, $comment, $emails) * @NoAdminRequired * @PublicPage */ - public function reference($referenceData, $path = null) - { + public function reference($referenceData, $path = null) { $this->logger->debug("reference: " . json_encode($referenceData) . " $path", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -641,8 +635,7 @@ public function reference($referenceData, $path = null) * @NoAdminRequired * @PublicPage */ - public function convert($fileId, $shareToken = null) - { + public function convert($fileId, $shareToken = null) { $this->logger->debug("Convert: $fileId", ["app" => $this->appName]); if (empty($shareToken) && !$this->config->isUserAllowedToUse()) { @@ -743,8 +736,7 @@ public function convert($fileId, $shareToken = null) * * @NoAdminRequired */ - public function save($name, $dir, $url) - { + public function save($name, $dir, $url) { $this->logger->debug("Save: $name", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -801,8 +793,7 @@ public function save($name, $dir, $url) * * @NoAdminRequired */ - public function history($fileId) - { + public function history($fileId) { $this->logger->debug("Request history for: $fileId", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -920,8 +911,7 @@ public function history($fileId) * * @NoAdminRequired */ - public function version($fileId, $version) - { + public function version($fileId, $version) { $this->logger->debug("Request version for: $fileId ($version)", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -1023,8 +1013,7 @@ public function version($fileId, $version) * * @NoAdminRequired */ - public function restore($fileId, $version) - { + public function restore($fileId, $version) { $this->logger->debug("Request restore version for: $fileId ($version)", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -1076,8 +1065,7 @@ public function restore($fileId, $version) * * @NoAdminRequired */ - public function url($filePath) - { + public function url($filePath) { $this->logger->debug("Request url for: $filePath", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -1128,8 +1116,7 @@ public function url($filePath) * @NoAdminRequired * @NoCSRFRequired */ - public function download($fileId, $toExtension = null, $template = false) - { + public function download($fileId, $toExtension = null, $template = false) { $this->logger->debug("Download: $fileId $toExtension", ["app" => $this->appName]); if (!$this->config->isUserAllowedToUse()) { @@ -1224,8 +1211,7 @@ public function download($fileId, $toExtension = null, $template = false) * @NoAdminRequired * @NoCSRFRequired */ - public function index($fileId, $filePath = null, $shareToken = null, $version = 0, $inframe = false, $inviewer = false, $template = false, $anchor = null) - { + public function index($fileId, $filePath = null, $shareToken = null, $version = 0, $inframe = false, $inviewer = false, $template = false, $anchor = null) { $this->logger->debug("Open: $fileId ($version) $filePath ", ["app" => $this->appName]); $isLoggedIn = $this->userSession->isLoggedIn(); @@ -1315,8 +1301,7 @@ public function index($fileId, $filePath = null, $shareToken = null, $version = * @NoCSRFRequired * @PublicPage */ - public function PublicPage($fileId, $shareToken, $version = 0, $inframe = false) - { + public function PublicPage($fileId, $shareToken, $version = 0, $inframe = false) { return $this->index($fileId, null, $shareToken, $version, $inframe); } @@ -1330,8 +1315,7 @@ public function PublicPage($fileId, $shareToken, $version = 0, $inframe = false) * * @return array */ - private function getFile($userId, $fileId, $filePath = null, $template = false) - { + private function getFile($userId, $fileId, $filePath = null, $template = false) { if (empty($fileId)) { return [null, $this->trans->t("FileId is empty"), null]; } @@ -1380,8 +1364,7 @@ private function getFile($userId, $fileId, $filePath = null, $template = false) * * @return string */ - private function getUrl($file, $user = null, $shareToken = null, $version = 0, $changes = false, $template = false) - { + private function getUrl($file, $user = null, $shareToken = null, $version = 0, $changes = false, $template = false) { $data = [ "action" => "download", @@ -1422,8 +1405,7 @@ private function getUrl($file, $user = null, $shareToken = null, $version = 0, $ * * @return array */ - private function getShareExcludedGroups() - { + private function getShareExcludedGroups() { $excludedGroups = []; if (\OC::$server->getConfig()->getAppValue("core", "shareapi_exclude_groups", "no") === "yes") { @@ -1440,8 +1422,7 @@ private function getShareExcludedGroups() * * @return string */ - private function buildUserId($userId) - { + private function buildUserId($userId) { $instanceId = $this->config->GetSystemValue("instanceid", true); $userId = $instanceId . "_" . $userId; return $userId; @@ -1455,8 +1436,7 @@ private function buildUserId($userId) * * @return TemplateResponse */ - private function renderError($error, $hint = "") - { + private function renderError($error, $hint = "") { return new TemplateResponse("", "error", [ "errors" => [ [ diff --git a/controller/federationcontroller.php b/controller/federationcontroller.php index 37fbc929..55ec234b 100644 --- a/controller/federationcontroller.php +++ b/controller/federationcontroller.php @@ -36,8 +36,7 @@ /** * OCS handler */ -class FederationController extends OCSController -{ +class FederationController extends OCSController { /** * Logger @@ -96,8 +95,7 @@ public function __construct( * @NoCSRFRequired * @PublicPage */ - public function key($shareToken, $path) - { + public function key($shareToken, $path) { list($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path); if (isset($error)) { @@ -128,8 +126,7 @@ public function key($shareToken, $path) * @NoCSRFRequired * @PublicPage */ - public function keylock($shareToken, $path, $lock, $fs) - { + public function keylock($shareToken, $path, $lock, $fs) { list($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path); if (isset($error)) { @@ -164,8 +161,7 @@ public function keylock($shareToken, $path, $lock, $fs) * @NoCSRFRequired * @PublicPage */ - public function healthcheck() - { + public function healthcheck() { $this->logger->debug("Federated healthcheck", ["app" => $this->appName]); return new DataResponse(["alive" => true]); diff --git a/controller/joblistcontroller.php b/controller/joblistcontroller.php index 94d08de8..33cc9d3f 100644 --- a/controller/joblistcontroller.php +++ b/controller/joblistcontroller.php @@ -37,8 +37,7 @@ * * @package OCA\Onlyoffice\Controller */ -class JobListController extends Controller -{ +class JobListController extends Controller { /** * Job list @@ -62,8 +61,7 @@ class JobListController extends Controller * @param AppConfig $config - application configuration * @param IJobList $jobList - job list */ - public function __construct($AppName, IRequest $request, AppConfig $config, IJobList $jobList) - { + public function __construct($AppName, IRequest $request, AppConfig $config, IJobList $jobList) { parent::__construct($AppName, $request); $this->config = $config; $this->jobList = $jobList; @@ -74,8 +72,7 @@ public function __construct($AppName, IRequest $request, AppConfig $config, IJob * * @param IJob|string $job */ - private function addJob($job) - { + private function addJob($job) { if (!$this->jobList->has($job, null)) { $this->jobList->add($job); \OC::$server->getLogger()->debug("Job '".$job."' added to JobList.", ["app" => $this->appName]); @@ -87,8 +84,7 @@ private function addJob($job) * * @param IJob|string $job */ - private function removeJob($job) - { + private function removeJob($job) { if ($this->jobList->has($job, null)) { $this->jobList->remove($job); \OC::$server->getLogger()->debug("Job '".$job."' removed from JobList.", ["app" => $this->appName]); @@ -99,8 +95,7 @@ private function removeJob($job) * Add or remove EditorsCheck job depending on the value of _editors_check_interval * */ - private function checkEditorsCheckJob() - { + private function checkEditorsCheckJob() { if ($this->config->GetEditorsCheckInterval() > 0) { $this->addJob(EditorsCheck::class); } else { @@ -112,8 +107,7 @@ private function checkEditorsCheckJob() * Method for sequentially calling checks of all jobs * */ - public function checkAllJobs() - { + public function checkAllJobs() { $this->checkEditorsCheckJob(); } } diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 3cb09f67..b1660482 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -35,8 +35,7 @@ /** * Settings controller for the administration page */ -class SettingsController extends Controller -{ +class SettingsController extends Controller { /** * l10n service @@ -105,8 +104,7 @@ public function __construct( * * @return TemplateResponse */ - public function index() - { + public function index() { $data = [ "documentserver" => $this->config->GetDocumentServerUrl(true), "documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true), @@ -295,8 +293,7 @@ public function SaveSecurity( * * @return array */ - public function ClearHistory() - { + public function ClearHistory() { FileVersions::clearHistory(); @@ -309,8 +306,7 @@ public function ClearHistory() * * @return array */ - private function GetGlobalTemplates() - { + private function GetGlobalTemplates() { $templates = []; $templatesList = TemplateManager::GetGlobalTemplates(); diff --git a/controller/sharingapicontroller.php b/controller/sharingapicontroller.php index 26ba0e8f..74c63a73 100644 --- a/controller/sharingapicontroller.php +++ b/controller/sharingapicontroller.php @@ -45,8 +45,7 @@ /** * OCS handler */ -class SharingApiController extends OCSController -{ +class SharingApiController extends OCSController { /** * Current user session @@ -142,8 +141,7 @@ public function __construct( * @NoAdminRequired * @NoCSRFRequired */ - public function getShares($fileId) - { + public function getShares($fileId) { if ($this->extraPermissions === null) { $this->logger->debug("extraPermissions isn't init", ["app" => $this->appName]); return new DataResponse([], Http::STATUS_BAD_REQUEST); @@ -179,8 +177,7 @@ public function getShares($fileId) * @NoAdminRequired * @NoCSRFRequired */ - public function setShares($extraId, $shareId, $fileId, $permissions) - { + public function setShares($extraId, $shareId, $fileId, $permissions) { if ($this->extraPermissions === null) { $this->logger->debug("extraPermissions isn't init", ["app" => $this->appName]); return new DataResponse([], Http::STATUS_BAD_REQUEST); @@ -213,8 +210,7 @@ public function setShares($extraId, $shareId, $fileId, $permissions) * * @return File */ - private function getFile($fileId, $userId) - { + private function getFile($fileId, $userId) { try { $folder = $this->root->getUserFolder($userId); $files = $folder->getById($fileId); diff --git a/controller/templatecontroller.php b/controller/templatecontroller.php index df28ce09..dcde80ff 100644 --- a/controller/templatecontroller.php +++ b/controller/templatecontroller.php @@ -34,8 +34,7 @@ /** * OCS handler */ -class TemplateController extends Controller -{ +class TemplateController extends Controller { /** * l10n service @@ -84,8 +83,7 @@ public function __construct( * * @NoAdminRequired */ - public function GetTemplates() - { + public function GetTemplates() { $templatesList = TemplateManager::GetGlobalTemplates(); $templates = []; @@ -106,8 +104,7 @@ public function GetTemplates() * * @return array */ - public function AddTemplate() - { + public function AddTemplate() { $file = $this->request->getUploadedFile("file"); @@ -154,8 +151,7 @@ public function AddTemplate() * * @return array */ - public function DeleteTemplate($templateId) - { + public function DeleteTemplate($templateId) { $templateDir = TemplateManager::GetGlobalTemplateDir(); try { @@ -194,8 +190,7 @@ public function DeleteTemplate($templateId) * @NoAdminRequired * @NoCSRFRequired */ - public function preview($fileId, $x = 256, $y = 256, $crop = false, $mode = IPreview::MODE_FILL) - { + public function preview($fileId, $x = 256, $y = 256, $crop = false, $mode = IPreview::MODE_FILL) { if (empty($fileId) || $x === 0 || $y === 0) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } diff --git a/lib/Migration/Version070000Date20210417111111.php b/lib/Migration/Version070000Date20210417111111.php index 21394c56..047a8308 100644 --- a/lib/Migration/Version070000Date20210417111111.php +++ b/lib/Migration/Version070000Date20210417111111.php @@ -12,16 +12,14 @@ /** * Auto-generated migration step: Please modify to your needs! */ -class Version070000Date20210417111111 extends SimpleMigrationStep -{ +class Version070000Date20210417111111 extends SimpleMigrationStep { /** * @param IOutput $output * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options */ - public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void - { + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { } /** @@ -30,8 +28,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $ * @param array $options * @return null|ISchemaWrapper */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper - { + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); @@ -68,7 +65,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void - { + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { } } diff --git a/lib/Migration/Version070400Date20220607111111.php b/lib/Migration/Version070400Date20220607111111.php index 2da68321..1ad8abf3 100644 --- a/lib/Migration/Version070400Date20220607111111.php +++ b/lib/Migration/Version070400Date20220607111111.php @@ -12,16 +12,14 @@ /** * Auto-generated migration step: Please modify to your needs! */ -class Version070400Date20220607111111 extends SimpleMigrationStep -{ +class Version070400Date20220607111111 extends SimpleMigrationStep { /** * @param IOutput $output * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options */ - public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void - { + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { } /** @@ -30,8 +28,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $ * @param array $options * @return null|ISchemaWrapper */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper - { + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); @@ -87,7 +84,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void - { + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { } } diff --git a/lib/Migration/Version070400Date20220929111111.php b/lib/Migration/Version070400Date20220929111111.php index 06a4ea19..ca841026 100644 --- a/lib/Migration/Version070400Date20220929111111.php +++ b/lib/Migration/Version070400Date20220929111111.php @@ -12,16 +12,14 @@ /** * Auto-generated migration step: Please modify to your needs! */ -class Version070400Date20220929111111 extends SimpleMigrationStep -{ +class Version070400Date20220929111111 extends SimpleMigrationStep { /** * @param IOutput $output * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options */ - public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void - { + public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { } /** @@ -30,8 +28,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $ * @param array $options * @return null|ISchemaWrapper */ - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper - { + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); @@ -109,7 +106,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` * @param array $options */ - public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void - { + public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { } } diff --git a/lib/adminsection.php b/lib/adminsection.php index 962b1e29..acc81e2c 100644 --- a/lib/adminsection.php +++ b/lib/adminsection.php @@ -25,8 +25,7 @@ /** * Settings section for the administration page */ -class AdminSection implements IIconSection -{ +class AdminSection implements IIconSection { /** @var IURLGenerator */ private $urlGenerator; @@ -34,8 +33,7 @@ class AdminSection implements IIconSection /** * @param IURLGenerator $urlGenerator - url generator service */ - public function __construct(IURLGenerator $urlGenerator) - { + public function __construct(IURLGenerator $urlGenerator) { $this->urlGenerator = $urlGenerator; } @@ -45,8 +43,7 @@ public function __construct(IURLGenerator $urlGenerator) * * @return strings */ - public function getIcon() - { + public function getIcon() { return $this->urlGenerator->imagePath("onlyoffice", "app-dark.svg"); } @@ -55,8 +52,7 @@ public function getIcon() * * @returns string */ - public function getID() - { + public function getID() { return "onlyoffice"; } @@ -65,8 +61,7 @@ public function getID() * * @return string */ - public function getName() - { + public function getName() { return "ONLYOFFICE"; } @@ -75,8 +70,7 @@ public function getName() * * @return int */ - public function getPriority() - { + public function getPriority() { return 50; } } diff --git a/lib/adminsettings.php b/lib/adminsettings.php index 7a66cf58..d1d394e9 100644 --- a/lib/adminsettings.php +++ b/lib/adminsettings.php @@ -27,11 +27,9 @@ /** * Settings controller for the administration page */ -class AdminSettings implements ISettings -{ +class AdminSettings implements ISettings { - public function __construct() - { + public function __construct() { } /** @@ -39,8 +37,7 @@ public function __construct() * * @return TemplateResponse */ - public function getForm() - { + public function getForm() { $app = \OC::$server->query(Application::class); $container = $app->getContainer(); $response = $container->query(SettingsController::class)->index(); @@ -52,8 +49,7 @@ public function getForm() * * @return string */ - public function getSection() - { + public function getSection() { return "onlyoffice"; } @@ -62,8 +58,7 @@ public function getSection() * * @return int */ - public function getPriority() - { + public function getPriority() { return 50; } } diff --git a/lib/appconfig.php b/lib/appconfig.php index 6e040d55..ac6d1ac3 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -30,8 +30,7 @@ * * @package OCA\Onlyoffice */ -class AppConfig -{ +class AppConfig { /** * Application name @@ -330,8 +329,7 @@ class AppConfig /** * @param string $AppName - application name */ - public function __construct($AppName) - { + public function __construct($AppName) { $this->appName = $AppName; @@ -347,8 +345,7 @@ public function __construct($AppName) * * @return string */ - public function GetSystemValue($key, $system = false) - { + public function GetSystemValue($key, $system = false) { if ($system) { return $this->config->getSystemValue($key); } @@ -366,8 +363,7 @@ public function GetSystemValue($key, $system = false) * * @return bool */ - public function SelectDemo($value) - { + public function SelectDemo($value) { $this->logger->info("Select demo: " . json_encode($value), ["app" => $this->appName]); $data = $this->GetDemoData(); @@ -391,8 +387,7 @@ public function SelectDemo($value) * * @return array */ - public function GetDemoData() - { + public function GetDemoData() { $data = $this->config->getAppValue($this->appName, $this->_demo, ""); if (empty($data)) { @@ -421,8 +416,7 @@ public function GetDemoData() * * @return bool */ - public function UseDemo() - { + public function UseDemo() { return $this->GetDemoData()["enabled"] === true; } @@ -431,8 +425,7 @@ public function UseDemo() * * @param string $documentServer - document service address */ - public function SetDocumentServerUrl($documentServer) - { + public function SetDocumentServerUrl($documentServer) { $documentServer = trim($documentServer); if (strlen($documentServer) > 0) { $documentServer = rtrim($documentServer, "/") . "/"; @@ -453,8 +446,7 @@ public function SetDocumentServerUrl($documentServer) * * @return string */ - public function GetDocumentServerUrl($origin = false) - { + public function GetDocumentServerUrl($origin = false) { if (!$origin && $this->UseDemo()) { return $this->DEMO_PARAM["ADDR"]; } @@ -477,8 +469,7 @@ public function GetDocumentServerUrl($origin = false) * * @param string $documentServerInternal - document service address */ - public function SetDocumentServerInternalUrl($documentServerInternal) - { + public function SetDocumentServerInternalUrl($documentServerInternal) { $documentServerInternal = rtrim(trim($documentServerInternal), "/"); if (strlen($documentServerInternal) > 0) { $documentServerInternal = $documentServerInternal . "/"; @@ -499,8 +490,7 @@ public function SetDocumentServerInternalUrl($documentServerInternal) * * @return string */ - public function GetDocumentServerInternalUrl($origin = false) - { + public function GetDocumentServerInternalUrl($origin = false) { if (!$origin && $this->UseDemo()) { return $this->GetDocumentServerUrl(); } @@ -522,8 +512,7 @@ public function GetDocumentServerInternalUrl($origin = false) * * @return string */ - public function ReplaceDocumentServerUrlToInternal($url) - { + public function ReplaceDocumentServerUrlToInternal($url) { $documentServerUrl = $this->GetDocumentServerInternalUrl(); if (!empty($documentServerUrl)) { $from = $this->GetDocumentServerUrl(); @@ -547,8 +536,7 @@ public function ReplaceDocumentServerUrlToInternal($url) * * @param string $documentServer - document service address */ - public function SetStorageUrl($storageUrl) - { + public function SetStorageUrl($storageUrl) { $storageUrl = rtrim(trim($storageUrl), "/"); if (strlen($storageUrl) > 0) { $storageUrl = $storageUrl . "/"; @@ -567,8 +555,7 @@ public function SetStorageUrl($storageUrl) * * @return string */ - public function GetStorageUrl() - { + public function GetStorageUrl() { $url = $this->config->getAppValue($this->appName, $this->_storageUrl, ""); if (empty($url)) { $url = $this->GetSystemValue($this->_storageUrl); @@ -581,8 +568,7 @@ public function GetStorageUrl() * * @param string $secret - secret key */ - public function SetDocumentServerSecret($secret) - { + public function SetDocumentServerSecret($secret) { $secret = trim($secret); if (empty($secret)) { $this->logger->info("Clear secret key", ["app" => $this->appName]); @@ -600,8 +586,7 @@ public function SetDocumentServerSecret($secret) * * @return string */ - public function GetDocumentServerSecret($origin = false) - { + public function GetDocumentServerSecret($origin = false) { if (!$origin && $this->UseDemo()) { return $this->DEMO_PARAM["SECRET"]; } @@ -618,8 +603,7 @@ public function GetDocumentServerSecret($origin = false) * * @return string */ - public function GetSKey() - { + public function GetSKey() { $secret = $this->GetDocumentServerSecret(); if (empty($secret)) { $secret = $this->GetSystemValue($this->_cryptSecret, true); @@ -632,8 +616,7 @@ public function GetSKey() * * @param array $formats - formats with status */ - public function SetDefaultFormats($formats) - { + public function SetDefaultFormats($formats) { $value = json_encode($formats); $this->logger->info("Set default formats: $value", ["app" => $this->appName]); @@ -645,8 +628,7 @@ public function SetDefaultFormats($formats) * * @return array */ - private function GetDefaultFormats() - { + private function GetDefaultFormats() { $value = $this->config->getAppValue($this->appName, $this->_defFormats, ""); if (empty($value)) { return array(); @@ -659,8 +641,7 @@ private function GetDefaultFormats() * * @param array $formats - formats with status */ - public function SetEditableFormats($formats) - { + public function SetEditableFormats($formats) { $value = json_encode($formats); $this->logger->info("Set editing formats: $value", ["app" => $this->appName]); @@ -672,8 +653,7 @@ public function SetEditableFormats($formats) * * @return array */ - private function GetEditableFormats() - { + private function GetEditableFormats() { $value = $this->config->getAppValue($this->appName, $this->_editFormats, ""); if (empty($value)) { return array(); @@ -686,8 +666,7 @@ private function GetEditableFormats() * * @param bool $value - same tab */ - public function SetSameTab($value) - { + public function SetSameTab($value) { $this->logger->info("Set opening in a same tab: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_sameTab, json_encode($value)); @@ -698,8 +677,7 @@ public function SetSameTab($value) * * @return bool */ - public function GetSameTab() - { + public function GetSameTab() { return $this->config->getAppValue($this->appName, $this->_sameTab, "true") === "true"; } @@ -708,8 +686,7 @@ public function GetSameTab() * * @param bool $value - preview */ - public function SetPreview($value) - { + public function SetPreview($value) { $this->logger->info("Set generate preview: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_preview, json_encode($value)); @@ -720,8 +697,7 @@ public function SetPreview($value) * * @return bool */ - public function GetAdvanced() - { + public function GetAdvanced() { return $this->config->getAppValue($this->appName, $this->_advanced, "false") === "true"; } @@ -730,8 +706,7 @@ public function GetAdvanced() * * @param bool $value - advanced */ - public function SetAdvanced($value) - { + public function SetAdvanced($value) { $this->logger->info("Set advanced: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_advanced, json_encode($value)); @@ -742,8 +717,7 @@ public function SetAdvanced($value) * * @return bool */ - public function GetPreview() - { + public function GetPreview() { return $this->config->getAppValue($this->appName, $this->_preview, "true") === "true"; } @@ -752,8 +726,7 @@ public function GetPreview() * * @param bool $value - version history */ - public function SetVersionHistory($value) - { + public function SetVersionHistory($value) { $this->logger->info("Set keep versions history: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_versionHistory, json_encode($value)); @@ -764,8 +737,7 @@ public function SetVersionHistory($value) * * @return bool */ - public function GetVersionHistory() - { + public function GetVersionHistory() { return $this->config->getAppValue($this->appName, $this->_versionHistory, "true") === "true"; } @@ -774,8 +746,7 @@ public function GetVersionHistory() * * @param bool $value - version history */ - public function SetProtection($value) - { + public function SetProtection($value) { $this->logger->info("Set protection: " . $value, ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_protection, $value); @@ -786,8 +757,7 @@ public function SetProtection($value) * * @return bool */ - public function GetProtection() - { + public function GetProtection() { $value = $this->config->getAppValue($this->appName, $this->_protection, "owner"); if ($value === "all") { return "all"; @@ -800,8 +770,7 @@ public function GetProtection() * * @param bool $value - display chat */ - public function SetCustomizationChat($value) - { + public function SetCustomizationChat($value) { $this->logger->info("Set chat display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationChat, json_encode($value)); @@ -812,8 +781,7 @@ public function SetCustomizationChat($value) * * @return bool */ - public function GetCustomizationChat() - { + public function GetCustomizationChat() { return $this->config->getAppValue($this->appName, $this->_customizationChat, "true") === "true"; } @@ -822,8 +790,7 @@ public function GetCustomizationChat() * * @param bool $value - display compact header */ - public function SetCustomizationCompactHeader($value) - { + public function SetCustomizationCompactHeader($value) { $this->logger->info("Set compact header display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationCompactHeader, json_encode($value)); @@ -834,8 +801,7 @@ public function SetCustomizationCompactHeader($value) * * @return bool */ - public function GetCustomizationCompactHeader() - { + public function GetCustomizationCompactHeader() { return $this->config->getAppValue($this->appName, $this->_customizationCompactHeader, "true") === "true"; } @@ -844,8 +810,7 @@ public function GetCustomizationCompactHeader() * * @param bool $value - display feedback */ - public function SetCustomizationFeedback($value) - { + public function SetCustomizationFeedback($value) { $this->logger->info("Set feedback display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationFeedback, json_encode($value)); @@ -856,8 +821,7 @@ public function SetCustomizationFeedback($value) * * @return bool */ - public function GetCustomizationFeedback() - { + public function GetCustomizationFeedback() { return $this->config->getAppValue($this->appName, $this->_customizationFeedback, "true") === "true"; } @@ -866,8 +830,7 @@ public function GetCustomizationFeedback() * * @param bool $value - forcesave */ - public function SetCustomizationForcesave($value) - { + public function SetCustomizationForcesave($value) { $this->logger->info("Set forcesave: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationForcesave, json_encode($value)); @@ -878,8 +841,7 @@ public function SetCustomizationForcesave($value) * * @return bool */ - public function GetCustomizationForcesave() - { + public function GetCustomizationForcesave() { return $this->config->getAppValue($this->appName, $this->_customizationForcesave, "false") === "true"; } @@ -888,8 +850,7 @@ public function GetCustomizationForcesave() * * @param bool $value - display help */ - public function SetCustomizationHelp($value) - { + public function SetCustomizationHelp($value) { $this->logger->info("Set help display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationHelp, json_encode($value)); @@ -900,8 +861,7 @@ public function SetCustomizationHelp($value) * * @return bool */ - public function GetCustomizationHelp() - { + public function GetCustomizationHelp() { return $this->config->getAppValue($this->appName, $this->_customizationHelp, "true") === "true"; } @@ -910,8 +870,7 @@ public function GetCustomizationHelp() * * @param bool $value - without tabs */ - public function SetCustomizationToolbarNoTabs($value) - { + public function SetCustomizationToolbarNoTabs($value) { $this->logger->info("Set without tabs: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationToolbarNoTabs, json_encode($value)); @@ -922,8 +881,7 @@ public function SetCustomizationToolbarNoTabs($value) * * @return bool */ - public function GetCustomizationToolbarNoTabs() - { + public function GetCustomizationToolbarNoTabs() { return $this->config->getAppValue($this->appName, $this->_customizationToolbarNoTabs, "true") === "true"; } @@ -932,8 +890,7 @@ public function GetCustomizationToolbarNoTabs() * * @param string $value - review mode */ - public function SetCustomizationReviewDisplay($value) - { + public function SetCustomizationReviewDisplay($value) { $this->logger->info("Set review mode: " . $value, array("app" => $this->appName)); $this->config->setAppValue($this->appName, $this->_customizationReviewDisplay, $value); @@ -944,8 +901,7 @@ public function SetCustomizationReviewDisplay($value) * * @return string */ - public function GetCustomizationReviewDisplay() - { + public function GetCustomizationReviewDisplay() { $value = $this->config->getAppValue($this->appName, $this->_customizationReviewDisplay, "original"); if ($value === "markup") { return "markup"; @@ -961,8 +917,7 @@ public function GetCustomizationReviewDisplay() * * @param string $value - theme */ - public function SetCustomizationTheme($value) - { + public function SetCustomizationTheme($value) { $this->logger->info("Set theme: " . $value, array("app" => $this->appName)); $this->config->setAppValue($this->appName, $this->_customizationTheme, $value); @@ -973,8 +928,7 @@ public function SetCustomizationTheme($value) * * @return string */ - public function GetCustomizationTheme() - { + public function GetCustomizationTheme() { $value = $this->config->getAppValue($this->appName, $this->_customizationTheme, "theme-classic-light"); if ($value === "theme-light") { return "theme-light"; @@ -990,8 +944,7 @@ public function GetCustomizationTheme() * * @param array $settings - watermark settings */ - public function SetWatermarkSettings($settings) - { + public function SetWatermarkSettings($settings) { $this->logger->info("Set watermark enabled: " . $settings["enabled"], ["app" => $this->appName]); if ($settings["enabled"] !== "true") { @@ -1039,8 +992,7 @@ public function SetWatermarkSettings($settings) * * @return bool|array */ - public function GetWatermarkSettings() - { + public function GetWatermarkSettings() { $result = [ "text" => $this->config->getAppValue(AppConfig::WATERMARK_APP_NAMESPACE, "watermark_text", "{userId}, {date}"), ]; @@ -1082,8 +1034,7 @@ public function GetWatermarkSettings() * * @param array $groups - the list of groups */ - public function SetLimitGroups($groups) - { + public function SetLimitGroups($groups) { if (!is_array($groups)) { $groups = array(); } @@ -1098,8 +1049,7 @@ public function SetLimitGroups($groups) * * @return array */ - public function GetLimitGroups() - { + public function GetLimitGroups() { $value = $this->config->getAppValue($this->appName, $this->_groups, ""); if (empty($value)) { return array(); @@ -1118,8 +1068,7 @@ public function GetLimitGroups() * * @return bool */ - public function isUserAllowedToUse($userId = null) - { + public function isUserAllowedToUse($userId = null) { // no user -> no $userSession = \OC::$server->getUserSession(); if (is_null($userId) && ($userSession === null || !$userSession->isLoggedIn())) { @@ -1162,8 +1111,7 @@ public function isUserAllowedToUse($userId = null) * * @param bool $verifyPeerOff - parameter verification setting */ - public function SetVerifyPeerOff($verifyPeerOff) - { + public function SetVerifyPeerOff($verifyPeerOff) { $this->logger->info("SetVerifyPeerOff " . json_encode($verifyPeerOff), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_verification, json_encode($verifyPeerOff)); @@ -1174,8 +1122,7 @@ public function SetVerifyPeerOff($verifyPeerOff) * * @return bool */ - public function GetVerifyPeerOff() - { + public function GetVerifyPeerOff() { $turnOff = $this->config->getAppValue($this->appName, $this->_verification, ""); if (!empty($turnOff)) { @@ -1190,8 +1137,7 @@ public function GetVerifyPeerOff() * * @return int */ - public function GetLimitThumbSize() - { + public function GetLimitThumbSize() { $limitSize = (integer)$this->GetSystemValue($this->_limitThumbSize); if (!empty($limitSize)) { @@ -1208,8 +1154,7 @@ public function GetLimitThumbSize() * * @return string */ - public function JwtHeader($origin = false) - { + public function JwtHeader($origin = false) { if (!$origin && $this->UseDemo()) { return $this->DEMO_PARAM["HEADER"]; } @@ -1229,8 +1174,7 @@ public function JwtHeader($origin = false) * * @param string $value - jwtHeader */ - public function SetJwtHeader($value) - { + public function SetJwtHeader($value) { $value = trim($value); if (empty($value)) { $this->logger->info("Clear header key", ["app" => $this->appName]); @@ -1246,8 +1190,7 @@ public function SetJwtHeader($value) * * @return int */ - public function GetJwtLeeway() - { + public function GetJwtLeeway() { $jwtLeeway = (integer)$this->GetSystemValue($this->_jwtLeeway); return $jwtLeeway; @@ -1258,8 +1201,7 @@ public function GetJwtLeeway() * * @param string $value - error */ - public function SetSettingsError($value) - { + public function SetSettingsError($value) { $this->config->setAppValue($this->appName, $this->_settingsError, $value); } @@ -1268,8 +1210,7 @@ public function SetSettingsError($value) * * @return bool */ - public function SettingsAreSuccessful() - { + public function SettingsAreSuccessful() { return empty($this->config->getAppValue($this->appName, $this->_settingsError, "")); } @@ -1280,8 +1221,7 @@ public function SettingsAreSuccessful() * * @NoAdminRequired */ - public function FormatsSetting() - { + public function FormatsSetting() { $result = $this->formats; $defFormats = $this->GetDefaultFormats(); @@ -1306,8 +1246,7 @@ public function FormatsSetting() * * @param bool $value - enable macros */ - public function SetCustomizationMacros($value) - { + public function SetCustomizationMacros($value) { $this->logger->info("Set macros enabled: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationMacros, json_encode($value)); @@ -1318,8 +1257,7 @@ public function SetCustomizationMacros($value) * * @return bool */ - public function GetCustomizationMacros() - { + public function GetCustomizationMacros() { return $this->config->getAppValue($this->appName, $this->_customizationMacros, "true") === "true"; } @@ -1328,8 +1266,7 @@ public function GetCustomizationMacros() * * @param bool $value - enable macros */ - public function SetCustomizationPlugins($value) - { + public function SetCustomizationPlugins($value) { $this->logger->info("Set plugins enabled: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationPlugins, json_encode($value)); @@ -1340,8 +1277,7 @@ public function SetCustomizationPlugins($value) * * @return bool */ - public function GetCustomizationPlugins() - { + public function GetCustomizationPlugins() { return $this->config->getAppValue($this->appName, $this->_customizationPlugins, "true") === "true"; } @@ -1350,8 +1286,7 @@ public function GetCustomizationPlugins() * * @return int */ - public function GetEditorsCheckInterval() - { + public function GetEditorsCheckInterval() { $interval = $this->GetSystemValue($this->_editors_check_interval); if (empty($interval) && $interval !== 0) { @@ -1420,8 +1355,7 @@ public function GetEditorsCheckInterval() * * @return string */ - public function GetLinkToDocs() - { + public function GetLinkToDocs() { return $this->linkToDocs; } } diff --git a/lib/command/documentserver.php b/lib/command/documentserver.php index 2d942424..96cd8795 100644 --- a/lib/command/documentserver.php +++ b/lib/command/documentserver.php @@ -31,8 +31,7 @@ use OCA\Onlyoffice\DocumentService; use OCA\Onlyoffice\Crypt; -class DocumentServer extends Command -{ +class DocumentServer extends Command { /** * Application configuration @@ -84,8 +83,7 @@ public function __construct( /** * Configures the current command. */ - protected function configure() - { + protected function configure() { $this ->setName("onlyoffice:documentserver") ->setDescription("Manage document server") @@ -105,8 +103,7 @@ protected function configure() * * @return int 0 if everything went fine, or an exit code */ - protected function execute(InputInterface $input, OutputInterface $output) - { + protected function execute(InputInterface $input, OutputInterface $output) { $check = $input->getOption("check"); $documentserver = $this->config->GetDocumentServerUrl(true); diff --git a/lib/cron/editorscheck.php b/lib/cron/editorscheck.php index ea95dfbb..5024df12 100644 --- a/lib/cron/editorscheck.php +++ b/lib/cron/editorscheck.php @@ -36,8 +36,7 @@ * Editors availability check background job * */ -class EditorsCheck extends TimedJob -{ +class EditorsCheck extends TimedJob { /** * Application name @@ -123,8 +122,7 @@ public function __construct( * * @param array $argument unused argument */ - protected function run($argument) - { + protected function run($argument) { if (empty($this->config->GetDocumentServerUrl())) { $this->logger->debug("Settings are empty", ["app" => $this->appName]); return; @@ -162,8 +160,7 @@ protected function run($argument) * * @return string[] */ - private function getUsersToNotify() - { + private function getUsersToNotify() { $notifyGroups = ["admin"]; $notifyUsers = []; @@ -184,8 +181,7 @@ private function getUsersToNotify() * Send notification to admins * @return void */ - private function notifyAdmins() - { + private function notifyAdmins() { $notificationManager = \OC::$server->getNotificationManager(); $notification = $notificationManager->createNotification(); $notification->setApp($this->appName) diff --git a/lib/crypt.php b/lib/crypt.php index eed600cb..5b81ab40 100644 --- a/lib/crypt.php +++ b/lib/crypt.php @@ -26,8 +26,7 @@ * * @package OCA\Onlyoffice */ -class Crypt -{ +class Crypt { /** * Application configuration @@ -39,8 +38,7 @@ class Crypt /** * @param AppConfig $config - application configutarion */ - public function __construct(AppConfig $appConfig) - { + public function __construct(AppConfig $appConfig) { $this->config = $appConfig; } @@ -51,8 +49,7 @@ public function __construct(AppConfig $appConfig) * * @return string */ - public function GetHash($object) - { + public function GetHash($object) { return \Firebase\JWT\JWT::encode($object, $this->config->GetSKey(), "HS256"); } @@ -63,8 +60,7 @@ public function GetHash($object) * * @return array */ - public function ReadHash($token) - { + public function ReadHash($token) { $result = null; $error = null; if ($token === null) { diff --git a/lib/directeditor.php b/lib/directeditor.php index 0a710d3c..bec14dc3 100644 --- a/lib/directeditor.php +++ b/lib/directeditor.php @@ -37,8 +37,7 @@ * * @package OCA\Onlyoffice */ -class DirectEditor implements IEditor -{ +class DirectEditor implements IEditor { /** * Application name @@ -111,8 +110,7 @@ public function __construct( * * @return string */ - public function getId(): string - { + public function getId(): string { return $this->appName; } @@ -121,8 +119,7 @@ public function getId(): string * * @return string */ - public function getName(): string - { + public function getName(): string { return "ONLYOFFICE"; } @@ -131,8 +128,7 @@ public function getName(): string * * @return array */ - public function getMimetypes(): array - { + public function getMimetypes(): array { $mimes = array(); if (!$this->config->isUserAllowedToUse()) { return $mimes; @@ -154,8 +150,7 @@ public function getMimetypes(): array * * @return array */ - public function getMimetypesOptional(): array - { + public function getMimetypesOptional(): array { $mimes = array(); if (!$this->config->isUserAllowedToUse()) { return $mimes; @@ -177,8 +172,7 @@ public function getMimetypesOptional(): array * * @return array of ACreateFromTemplate|ACreateEmpty */ - public function getCreators(): array - { + public function getCreators(): array { if (!$this->config->isUserAllowedToUse()) { return array(); } @@ -195,8 +189,7 @@ public function getCreators(): array * * @return bool */ - public function isSecure(): bool - { + public function isSecure(): bool { return true; } @@ -211,8 +204,7 @@ public function isSecure(): bool * * @return Response */ - public function open(IToken $token): Response - { + public function open(IToken $token): Response { try { $token->useTokenScope(); $file = $token->getFile(); @@ -284,8 +276,7 @@ public function open(IToken $token): Response * * @return TemplateResponse */ - private function renderError($error, $hint = "") - { + private function renderError($error, $hint = "") { return new TemplateResponse("", "error", [ "errors" => [ [ diff --git a/lib/documentservice.php b/lib/documentservice.php index 8bd2079b..4ccec2d2 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -28,8 +28,7 @@ * * @package OCA\Onlyoffice */ -class DocumentService -{ +class DocumentService { /** * Application name @@ -56,8 +55,7 @@ class DocumentService * @param IL10N $trans - l10n service * @param AppConfig $config - application configutarion */ - public function __construct(IL10N $trans, AppConfig $appConfig) - { + public function __construct(IL10N $trans, AppConfig $appConfig) { $this->trans = $trans; $this->config = $appConfig; } @@ -69,8 +67,7 @@ public function __construct(IL10N $trans, AppConfig $appConfig) * * @return string */ - public static function GenerateRevisionId($expected_key) - { + public static function GenerateRevisionId($expected_key) { if (strlen($expected_key) > 20) { $expected_key = crc32($expected_key); } @@ -90,8 +87,7 @@ public static function GenerateRevisionId($expected_key) * * @return string */ - public function GetConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id, $region = null) - { + public function GetConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id, $region = null) { $responceFromConvertService = $this->SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, false, $region); $errorElement = $responceFromConvertService->Error; @@ -120,8 +116,7 @@ public function GetConvertedUri($document_uri, $from_extension, $to_extension, $ * * @return array */ - public function SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, $region = null) - { + public function SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, $region = null) { $documentServerUrl = $this->config->GetDocumentServerInternalUrl(); if (empty($documentServerUrl)) { @@ -204,8 +199,7 @@ public function SendRequestToConvertService($document_uri, $from_extension, $to_ * * @return null */ - public function ProcessConvServResponceError($errorCode) - { + public function ProcessConvServResponceError($errorCode) { $errorMessageTemplate = $this->trans->t("Error occurred in the document service"); $errorMessage = ""; @@ -252,8 +246,7 @@ public function ProcessConvServResponceError($errorCode) * * @return bool */ - public function HealthcheckRequest() - { + public function HealthcheckRequest() { $documentServerUrl = $this->config->GetDocumentServerInternalUrl(); @@ -275,8 +268,7 @@ public function HealthcheckRequest() * * @return array */ - public function CommandRequest($method) - { + public function CommandRequest($method) { $documentServerUrl = $this->config->GetDocumentServerInternalUrl(); @@ -325,8 +317,7 @@ public function CommandRequest($method) * * @return null */ - public function ProcessCommandServResponceError($errorCode) - { + public function ProcessCommandServResponceError($errorCode) { $errorMessageTemplate = $this->trans->t("Error occurred in the document service"); $errorMessage = ""; @@ -359,8 +350,7 @@ public function ProcessCommandServResponceError($errorCode) * * @return string */ - public function Request($url, $method = "get", $opts = null) - { + public function Request($url, $method = "get", $opts = null) { $httpClientService = \OC::$server->getHTTPClientService(); $client = $httpClientService->newClient(); @@ -395,8 +385,7 @@ public function Request($url, $method = "get", $opts = null) * * @return array */ - public function checkDocServiceUrl($urlGenerator, $crypt) - { + public function checkDocServiceUrl($urlGenerator, $crypt) { $logger = \OC::$server->getLogger(); $version = null; diff --git a/lib/extrapermissions.php b/lib/extrapermissions.php index 77b31c23..ff8071b2 100644 --- a/lib/extrapermissions.php +++ b/lib/extrapermissions.php @@ -33,8 +33,7 @@ * * @package OCA\Onlyoffice */ -class ExtraPermissions -{ +class ExtraPermissions { /** * Application name @@ -105,8 +104,7 @@ public function __construct( * * @return array */ - public function getExtra($shareId) - { + public function getExtra($shareId) { $share = $this->getShare($shareId); if (empty($share)) { return null; @@ -149,8 +147,7 @@ public function getExtra($shareId) * * @return array */ - public function getExtras($shares) - { + public function getExtras($shares) { $result = []; $shareIds = []; @@ -217,8 +214,7 @@ public function getExtras($shares) * * @return bool */ - public function setExtra($shareId, $permissions, $extraId) - { + public function setExtra($shareId, $permissions, $extraId) { $result = false; $share = $this->getShare($shareId); @@ -248,8 +244,7 @@ public function setExtra($shareId, $permissions, $extraId) * * @return bool */ - public static function delete($shareId) - { + public static function delete($shareId) { $connection = \OC::$server->getDatabaseConnection(); $delete = $connection->prepare(" DELETE FROM `*PREFIX*" . self::TableName_Key . "` @@ -265,8 +260,7 @@ public static function delete($shareId) * * @return bool */ - public static function deleteList($shareIds) - { + public static function deleteList($shareIds) { $connection = \OC::$server->getDatabaseConnection(); $condition = ""; @@ -290,8 +284,7 @@ public static function deleteList($shareIds) * * @return array */ - private static function get($shareId) - { + private static function get($shareId) { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT id, share_id, permissions @@ -323,8 +316,7 @@ private static function get($shareId) * * @return array */ - private static function getList($shareIds) - { + private static function getList($shareIds) { $connection = \OC::$server->getDatabaseConnection(); $condition = ""; @@ -366,8 +358,7 @@ private static function getList($shareIds) * * @return bool */ - private static function insert($shareId, $permissions) - { + private static function insert($shareId, $permissions) { $connection = \OC::$server->getDatabaseConnection(); $insert = $connection->prepare(" INSERT INTO `*PREFIX*" . self::TableName_Key . "` @@ -385,8 +376,7 @@ private static function insert($shareId, $permissions) * * @return bool */ - private static function update($shareId, $permissions) - { + private static function update($shareId, $permissions) { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" UPDATE `*PREFIX*" . self::TableName_Key . "` @@ -404,8 +394,7 @@ private static function update($shareId, $permissions) * * @return array */ - private function validation($share, $checkExtra) - { + private function validation($share, $checkExtra) { $availableExtra = self::None; $defaultExtra = self::None; @@ -450,8 +439,7 @@ private function validation($share, $checkExtra) * * @return IShare */ - private function getShare($shareId) - { + private function getShare($shareId) { try { $share = $this->shareManager->getShareById("ocinternal:" . $shareId); } catch (ShareNotFound $e) { diff --git a/lib/filecreator.php b/lib/filecreator.php index 428acba2..e88d67d8 100644 --- a/lib/filecreator.php +++ b/lib/filecreator.php @@ -31,8 +31,7 @@ * * @package OCA\Onlyoffice */ -class FileCreator extends ACreateEmpty -{ +class FileCreator extends ACreateEmpty { /** * Application name @@ -85,8 +84,7 @@ public function __construct( * * @return string */ - public function getId(): string - { + public function getId(): string { return $this->appName . "_" . $this->format; } @@ -95,8 +93,7 @@ public function getId(): string * * @return string */ - public function getName(): string - { + public function getName(): string { switch ($this->format) { case "xlsx": return $this->trans->t("New spreadsheet"); @@ -111,8 +108,7 @@ public function getName(): string * * @return string */ - public function getExtension(): string - { + public function getExtension(): string { return $this->format; } @@ -121,8 +117,7 @@ public function getExtension(): string * * @return array */ - public function getMimetype(): string - { + public function getMimetype(): string { switch ($this->format) { case "xlsx": return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; @@ -139,8 +134,7 @@ public function getMimetype(): string * @param string $creatorId - creator id * @param string $templateId - teamplate id */ - public function create(File $file, string $creatorId = null, string $templateId = null): void - { + public function create(File $file, string $creatorId = null, string $templateId = null): void { $this->logger->debug("FileCreator: " . $file->getId() . " " . $file->getName() . " $creatorId $templateId", ["app" => $this->appName]); $fileName = $file->getName(); diff --git a/lib/fileutility.php b/lib/fileutility.php index 0f28b81d..a3b0efae 100644 --- a/lib/fileutility.php +++ b/lib/fileutility.php @@ -36,8 +36,7 @@ * * @package OCA\Onlyoffice */ -class FileUtility -{ +class FileUtility { /** * Application name @@ -114,8 +113,7 @@ public function __construct( * * @return array */ - public function getFileByToken($fileId, $shareToken, $path = null) - { + public function getFileByToken($fileId, $shareToken, $path = null) { list($node, $error, $share) = $this->getNodeByToken($shareToken); if (isset($error)) { @@ -158,8 +156,7 @@ public function getFileByToken($fileId, $shareToken, $path = null) * * @return array */ - public function getNodeByToken($shareToken) - { + public function getNodeByToken($shareToken) { list($share, $error) = $this->getShare($shareToken); if (isset($error)) { @@ -187,8 +184,7 @@ public function getNodeByToken($shareToken) * * @return array */ - public function getShare($shareToken) - { + public function getShare($shareToken) { if (empty($shareToken)) { return [null, $this->trans->t("FileId is empty")]; } @@ -222,8 +218,7 @@ public function getShare($shareToken) * * @return string */ - public function getKey($file, $origin = false) - { + public function getKey($file, $origin = false) { $fileId = $file->getId(); if ($origin @@ -253,8 +248,7 @@ public function getKey($file, $origin = false) * * @return string */ - private function GUID() - { + private function GUID() { if (function_exists("com_create_guid") === true) { return trim(com_create_guid(), "{}"); } @@ -269,8 +263,7 @@ private function GUID() * * @return string */ - public function getVersionKey($version) - { + public function getVersionKey($version) { $instanceId = $this->config->GetSystemValue("instanceid", true); $key = $instanceId . "_" . $version->getSourceFile()->getEtag() . "_" . $version->getRevisionId(); diff --git a/lib/fileversions.php b/lib/fileversions.php index 0578791f..b065455f 100644 --- a/lib/fileversions.php +++ b/lib/fileversions.php @@ -34,8 +34,7 @@ * * @package OCA\Onlyoffice */ -class FileVersions -{ +class FileVersions { /** * Application name @@ -72,8 +71,7 @@ class FileVersions * * @return array */ - public static function splitPathVersion($pathVersion) - { + public static function splitPathVersion($pathVersion) { if (empty($pathVersion)) { return false; } @@ -92,8 +90,7 @@ public static function splitPathVersion($pathVersion) * * @return bool */ - private static function checkFolderExist($view, $path, $createIfNotExist = false) - { + private static function checkFolderExist($view, $path, $createIfNotExist = false) { if ($view->is_dir($path)) { return true; } @@ -113,8 +110,7 @@ private static function checkFolderExist($view, $path, $createIfNotExist = false * * @return array */ - private static function getView($userId, $fileId, $createIfNotExist = false) - { + private static function getView($userId, $fileId, $createIfNotExist = false) { $view = new View("/" . $userId); $path = self::$appName; @@ -144,8 +140,7 @@ private static function getView($userId, $fileId, $createIfNotExist = false) * * @return array */ - public static function getHistoryData($ownerId, $fileId, $versionId, $prevVersion) - { + public static function getHistoryData($ownerId, $fileId, $versionId, $prevVersion) { $logger = \OC::$server->getLogger(); if ($ownerId === null || $fileId === null) { @@ -197,8 +192,7 @@ public static function getHistoryData($ownerId, $fileId, $versionId, $prevVersio * * @return bool */ - public static function hasChanges($ownerId, $fileId, $versionId) - { + public static function hasChanges($ownerId, $fileId, $versionId) { if ($ownerId === null || $fileId === null) { return false; } @@ -221,8 +215,7 @@ public static function hasChanges($ownerId, $fileId, $versionId) * * @return File */ - public static function getChangesFile($ownerId, $fileId, $versionId) - { + public static function getChangesFile($ownerId, $fileId, $versionId) { if ($ownerId === null || $fileId === null) { return null; } @@ -255,8 +248,7 @@ public static function getChangesFile($ownerId, $fileId, $versionId) * @param string $changes - file changes * @param string $prevVersion - previous version for check */ - public static function saveHistory($fileInfo, $history, $changes, $prevVersion) - { + public static function saveHistory($fileInfo, $history, $changes, $prevVersion) { $logger = \OC::$server->getLogger(); if ($fileInfo === null) { @@ -304,8 +296,7 @@ public static function saveHistory($fileInfo, $history, $changes, $prevVersion) * @param string $ownerId - file owner id * @param string $fileId - file id */ - public static function deleteAllVersions($ownerId, $fileId = null) - { + public static function deleteAllVersions($ownerId, $fileId = null) { $logger = \OC::$server->getLogger(); $logger->debug("deleteAllVersions $ownerId $fileId", ["app" => self::$appName]); @@ -329,8 +320,7 @@ public static function deleteAllVersions($ownerId, $fileId = null) * @param string $fileId - file id * @param string $versionId - file version */ - public static function deleteVersion($ownerId, $fileId, $versionId) - { + public static function deleteVersion($ownerId, $fileId, $versionId) { $logger = \OC::$server->getLogger(); $logger->debug("deleteVersion $fileId ($versionId)", ["app" => self::$appName]); @@ -363,8 +353,7 @@ public static function deleteVersion($ownerId, $fileId, $versionId) /** * Clear all version history */ - public static function clearHistory() - { + public static function clearHistory() { $logger = \OC::$server->getLogger(); $userDatabase = new Database(); @@ -389,8 +378,7 @@ public static function clearHistory() * @param FileInfo $fileInfo - file info * @param IUser $author - version author */ - public static function saveAuthor($fileInfo, $author) - { + public static function saveAuthor($fileInfo, $author) { $logger = \OC::$server->getLogger(); if ($fileInfo === null || $author === null) { @@ -437,8 +425,7 @@ public static function saveAuthor($fileInfo, $author) * * @return array */ - public static function getAuthor($ownerId, $fileId, $versionId) - { + public static function getAuthor($ownerId, $fileId, $versionId) { if ($ownerId === null || $fileId === null) { return null; } @@ -468,8 +455,7 @@ public static function getAuthor($ownerId, $fileId, $versionId) * @param string $fileId - file id * @param string $versionId - file version */ - public static function deleteAuthor($ownerId, $fileId, $versionId) - { + public static function deleteAuthor($ownerId, $fileId, $versionId) { $logger = \OC::$server->getLogger(); $logger->debug("deleteAuthor $fileId ($versionId)", ["app" => self::$appName]); @@ -496,8 +482,7 @@ public static function deleteAuthor($ownerId, $fileId, $versionId) /** * Get version compare with files_versions */ - public static function getFilesVersionAppInfoCompareResult() - { + public static function getFilesVersionAppInfoCompareResult() { $filesVersionAppInfo = \OC::$server->getAppManager()->getAppInfo("files_versions"); return \version_compare($filesVersionAppInfo["version"], "1.19"); } @@ -507,8 +492,7 @@ public static function getFilesVersionAppInfoCompareResult() * * @param array $versions - versions array */ - public static function processVersionsArray($versions) - { + public static function processVersionsArray($versions) { if (self::getFilesVersionAppInfoCompareResult() === -1) { return array_reverse($versions); } else { diff --git a/lib/hooks.php b/lib/hooks.php index 8ca4b770..928b8beb 100644 --- a/lib/hooks.php +++ b/lib/hooks.php @@ -32,8 +32,7 @@ * * @package OCA\Onlyoffice */ -class Hooks -{ +class Hooks { /** * Application name @@ -42,8 +41,7 @@ class Hooks */ private static $appName = "onlyoffice"; - public static function connectHooks() - { + public static function connectHooks() { // Listen user deletion Util::connectHook("OC_User", "pre_deleteUser", Hooks::class, "userDelete"); @@ -68,8 +66,7 @@ public static function connectHooks() * * @param array $params - hook params */ - public static function userDelete($params) - { + public static function userDelete($params) { $userId = $params["uid"]; FileVersions::deleteAllVersions($userId); @@ -80,8 +77,7 @@ public static function userDelete($params) * * @param array $params - hook params */ - public static function fileUpdate($params) - { + public static function fileUpdate($params) { $filePath = $params[Filesystem::signal_param_path]; if (empty($filePath)) { return; @@ -104,8 +100,7 @@ public static function fileUpdate($params) * * @param array $params - hook params */ - public static function fileDelete($params) - { + public static function fileDelete($params) { $filePath = $params[Filesystem::signal_param_path]; if (empty($filePath)) { return; @@ -138,8 +133,7 @@ public static function fileDelete($params) * * @param array $params - hook param */ - public static function fileVersionDelete($params) - { + public static function fileVersionDelete($params) { $pathVersion = $params["path"]; if (empty($pathVersion)) { return; @@ -175,8 +169,7 @@ public static function fileVersionDelete($params) * * @param array $params - hook param */ - public static function fileVersionRestore($params) - { + public static function fileVersionRestore($params) { $filePath = $params["path"]; if (empty($filePath)) { return; @@ -211,8 +204,7 @@ public static function fileVersionRestore($params) * * @param array $params - hook param */ - public static function extraPermissionsDelete($params) - { + public static function extraPermissionsDelete($params) { $shares = $params["deletedShares"]; if (empty($shares)) { return; diff --git a/lib/keymanager.php b/lib/keymanager.php index 07149142..6bb148c2 100644 --- a/lib/keymanager.php +++ b/lib/keymanager.php @@ -24,8 +24,7 @@ * * @package OCA\Onlyoffice */ -class KeyManager -{ +class KeyManager { /** * Table name @@ -39,8 +38,7 @@ class KeyManager * * @return string */ - public static function get($fileId) - { + public static function get($fileId) { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT `key` @@ -63,8 +61,7 @@ public static function get($fileId) * * @return bool */ - public static function set($fileId, $key) - { + public static function set($fileId, $key) { $connection = \OC::$server->getDatabaseConnection(); $insert = $connection->prepare(" INSERT INTO `*PREFIX*" . self::TableName_Key . "` @@ -82,8 +79,7 @@ public static function set($fileId, $key) * * @return bool */ - public static function delete($fileId, $unlock = false) - { + public static function delete($fileId, $unlock = false) { $connection = \OC::$server->getDatabaseConnection(); $delete = $connection->prepare( " @@ -102,8 +98,7 @@ public static function delete($fileId, $unlock = false) * * @return bool */ - public static function lock($fileId, $lock = true) - { + public static function lock($fileId, $lock = true) { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" UPDATE `*PREFIX*" . self::TableName_Key . "` @@ -121,8 +116,7 @@ public static function lock($fileId, $lock = true) * * @return bool */ - public static function setForcesave($fileId, $fs = true) - { + public static function setForcesave($fileId, $fs = true) { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" UPDATE `*PREFIX*" . self::TableName_Key . "` @@ -139,8 +133,7 @@ public static function setForcesave($fileId, $fs = true) * * @return bool */ - public static function wasForcesave($fileId) - { + public static function wasForcesave($fileId) { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT `fs` diff --git a/lib/listeners/directeditorlistener.php b/lib/listeners/directeditorlistener.php index 6083ec9e..4898c120 100644 --- a/lib/listeners/directeditorlistener.php +++ b/lib/listeners/directeditorlistener.php @@ -29,8 +29,7 @@ /** * DirectEditor listener */ -class DirectEditorListener implements IEventListener -{ +class DirectEditorListener implements IEventListener { /** * Application configuration @@ -58,8 +57,7 @@ public function __construct( $this->editor = $editor; } - public function handle(Event $event): void - { + public function handle(Event $event): void { if (!$event instanceof RegisterDirectEditorEvent) { return; } diff --git a/lib/listeners/filesharinglistener.php b/lib/listeners/filesharinglistener.php index 8a0fbb6d..d3ec0e2f 100644 --- a/lib/listeners/filesharinglistener.php +++ b/lib/listeners/filesharinglistener.php @@ -33,8 +33,7 @@ /** * File Sharing listener */ -class FileSharingListener implements IEventListener -{ +class FileSharingListener implements IEventListener { /** * Application configuration @@ -72,8 +71,7 @@ public function __construct( $this->serverContainer = $serverContainer; } - public function handle(Event $event): void - { + public function handle(Event $event): void { if (!$event instanceof BeforeTemplateRenderedEvent) { return; } diff --git a/lib/listeners/fileslistener.php b/lib/listeners/fileslistener.php index 9a6e87d6..a68dbb07 100644 --- a/lib/listeners/fileslistener.php +++ b/lib/listeners/fileslistener.php @@ -33,8 +33,7 @@ /** * File listener */ -class FilesListener implements IEventListener -{ +class FilesListener implements IEventListener { /** * Application configuration @@ -72,8 +71,7 @@ public function __construct( $this->serverContainer = $serverContainer; } - public function handle(Event $event): void - { + public function handle(Event $event): void { if (!$event instanceof LoadAdditionalScriptsEvent) { return; } diff --git a/lib/listeners/viewerlistener.php b/lib/listeners/viewerlistener.php index dc03e319..8d824daa 100644 --- a/lib/listeners/viewerlistener.php +++ b/lib/listeners/viewerlistener.php @@ -34,8 +34,7 @@ /** * Viewer listener */ -class ViewerListener implements IEventListener -{ +class ViewerListener implements IEventListener { /** * Application configuration @@ -73,8 +72,7 @@ public function __construct( $this->serverContainer = $serverContainer; } - public function handle(Event $event): void - { + public function handle(Event $event): void { if (!$event instanceof LoadViewer) { return; } diff --git a/lib/listeners/widgetlistener.php b/lib/listeners/widgetlistener.php index 7f3a0777..31693f0c 100644 --- a/lib/listeners/widgetlistener.php +++ b/lib/listeners/widgetlistener.php @@ -29,8 +29,7 @@ /** * Widget listener */ -class WidgetListener implements IEventListener -{ +class WidgetListener implements IEventListener { /** * Application configuration @@ -42,13 +41,11 @@ class WidgetListener implements IEventListener /** * @param AppConfig $config - application configuration */ - public function __construct(AppConfig $appConfig) - { + public function __construct(AppConfig $appConfig) { $this->appConfig = $appConfig; } - public function handle(Event $event): void - { + public function handle(Event $event): void { if (!$event instanceof RegisterWidgetEvent) { return; } diff --git a/lib/notifier.php b/lib/notifier.php index bd28c7bf..4b424814 100644 --- a/lib/notifier.php +++ b/lib/notifier.php @@ -27,8 +27,7 @@ use OCP\Notification\INotification; use OCP\Notification\INotifier; -class Notifier implements INotifier -{ +class Notifier implements INotifier { /** * Application name @@ -91,8 +90,7 @@ public function __construct( * * @return string */ - public function getID(): string - { + public function getID(): string { return $this->appName; } @@ -101,8 +99,7 @@ public function getID(): string * * @return string */ - public function getName(): string - { + public function getName(): string { return $this->appName; } @@ -112,8 +109,7 @@ public function getName(): string * * @return INotification */ - public function prepare(INotification $notification, string $languageCode): INotification - { + public function prepare(INotification $notification, string $languageCode): INotification { if ($notification->getApp() !== $this->appName) { throw new \InvalidArgumentException("Notification not from " . $this->appName); } diff --git a/lib/preview.php b/lib/preview.php index 0c385786..0fb2878e 100644 --- a/lib/preview.php +++ b/lib/preview.php @@ -47,8 +47,7 @@ * * @package OCA\Onlyoffice */ -class Preview extends Provider -{ +class Preview extends Provider { /** * Application name @@ -200,8 +199,7 @@ public function __construct( /** * Return mime type */ - public static function getMimeTypeRegex() - { + public static function getMimeTypeRegex() { $mimeTypeRegex = ""; foreach (self::$capabilities as $format) { if (!empty($mimeTypeRegex)) { @@ -217,8 +215,7 @@ public static function getMimeTypeRegex() /** * Return mime type */ - public function getMimeType() - { + public function getMimeType() { $m = self::getMimeTypeRegex(); return $m; } @@ -230,8 +227,7 @@ public function getMimeType() * * @return bool */ - public function isAvailable(FileInfo $fileInfo) - { + public function isAvailable(FileInfo $fileInfo) { if ($this->config->GetPreview() !== true) { return false; } @@ -260,8 +256,7 @@ public function isAvailable(FileInfo $fileInfo) * * @return Image|bool false if no preview was generated */ - public function getThumbnail($path, $maxX, $maxY, $scalingup, $view) - { + public function getThumbnail($path, $maxX, $maxY, $scalingup, $view) { $this->logger->debug("getThumbnail $path $maxX $maxY", ["app" => $this->appName]); list($fileUrl, $extension, $key) = $this->getFileParam($path, $view); @@ -306,8 +301,7 @@ public function getThumbnail($path, $maxX, $maxY, $scalingup, $view) * * @return string */ - private function getUrl($file, $user = null, $version = 0, $template = false) - { + private function getUrl($file, $user = null, $version = 0, $template = false) { $data = [ "action" => "download", @@ -345,8 +339,7 @@ private function getUrl($file, $user = null, $version = 0, $template = false) * * @return array */ - private function getFileParam($path, $view) - { + private function getFileParam($path, $view) { $fileInfo = $view->getFileInfo($path); if (!$fileInfo || $fileInfo->getSize() === 0) { diff --git a/lib/remoteinstance.php b/lib/remoteinstance.php index 6afbec3d..8c74b8b6 100644 --- a/lib/remoteinstance.php +++ b/lib/remoteinstance.php @@ -28,8 +28,7 @@ * * @package OCA\Onlyoffice */ -class RemoteInstance -{ +class RemoteInstance { /** * App name @@ -58,8 +57,7 @@ class RemoteInstance * * @return array */ - private static function get($remote) - { + private static function get($remote) { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT remote, expire, status @@ -81,8 +79,7 @@ private static function get($remote) * * @return bool */ - private static function set($remote, $status) - { + private static function set($remote, $status) { $connection = \OC::$server->getDatabaseConnection(); $insert = $connection->prepare(" INSERT INTO `*PREFIX*" . self::TableName_Key . "` @@ -100,8 +97,7 @@ private static function set($remote, $status) * * @return bool */ - private static function update($remote, $status) - { + private static function update($remote, $status) { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" UPDATE `*PREFIX*" . self::TableName_Key . "` @@ -118,8 +114,7 @@ private static function update($remote, $status) * * @return bool */ - public static function healthCheck($remote) - { + public static function healthCheck($remote) { $logger = \OC::$server->getLogger(); $remote = rtrim($remote, "/") . "/"; @@ -173,8 +168,7 @@ public static function healthCheck($remote) * * @return string */ - public static function getRemoteKey($file) - { + public static function getRemoteKey($file) { $logger = \OC::$server->getLogger(); $remote = rtrim($file->getStorage()->getRemote(), "/") . "/"; @@ -226,8 +220,7 @@ public static function getRemoteKey($file) * * @return bool */ - public static function lockRemoteKey($file, $lock, $fs) - { + public static function lockRemoteKey($file, $lock, $fs) { $logger = \OC::$server->getLogger(); $action = $lock ? "lock" : "unlock"; @@ -277,8 +270,7 @@ public static function lockRemoteKey($file, $lock, $fs) * * @return bool */ - public static function isRemoteFile($file) - { + public static function isRemoteFile($file) { $storage = $file->getStorage(); $alive = false; diff --git a/lib/settingsdata.php b/lib/settingsdata.php index 6482d20b..afec0244 100644 --- a/lib/settingsdata.php +++ b/lib/settingsdata.php @@ -21,8 +21,7 @@ use OCA\Onlyoffice\AppConfig; -class SettingsData implements \JsonSerializable -{ +class SettingsData implements \JsonSerializable { /** * Application configuration @@ -31,13 +30,11 @@ class SettingsData implements \JsonSerializable */ private $appConfig; - public function __construct(AppConfig $appConfig) - { + public function __construct(AppConfig $appConfig) { $this->appConfig = $appConfig; } - public function jsonSerialize(): array - { + public function jsonSerialize(): array { $data = [ "formats" => $this->appConfig->FormatsSetting(), "sameTab" => $this->appConfig->GetSameTab() diff --git a/lib/templatemanager.php b/lib/templatemanager.php index 50fad250..7ec2bbd8 100644 --- a/lib/templatemanager.php +++ b/lib/templatemanager.php @@ -28,8 +28,7 @@ * * @package OCA\Onlyoffice */ -class TemplateManager -{ +class TemplateManager { /** * Application name @@ -50,8 +49,7 @@ class TemplateManager * * @return Folder */ - public static function GetGlobalTemplateDir() - { + public static function GetGlobalTemplateDir() { $dirPath = "appdata_" . \OC::$server->getConfig()->GetSystemValue("instanceid", null) . "/" . self::$appName . "/" . self::$templateFolderName; @@ -74,8 +72,7 @@ public static function GetGlobalTemplateDir() * * @return array */ - public static function GetGlobalTemplates($mimetype = null) - { + public static function GetGlobalTemplates($mimetype = null) { $templateDir = self::GetGlobalTemplateDir(); $templatesList = $templateDir->getDirectoryListing(); @@ -94,8 +91,7 @@ public static function GetGlobalTemplates($mimetype = null) * * @return File */ - public static function GetTemplate($templateId) - { + public static function GetTemplate($templateId) { $logger = \OC::$server->getLogger(); if (empty($templateId)) { @@ -125,8 +121,7 @@ public static function GetTemplate($templateId) * * @return string */ - public static function GetTypeTemplate($mime) - { + public static function GetTypeTemplate($mime) { switch($mime) { case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return "document"; @@ -146,8 +141,7 @@ public static function GetTypeTemplate($mime) * * @return string */ - public static function GetMimeTemplate($type) - { + public static function GetMimeTemplate($type) { switch($type) { case "document": return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; @@ -167,8 +161,7 @@ public static function GetMimeTemplate($type) * * @return bool */ - public static function IsTemplateType($name) - { + public static function IsTemplateType($name) { $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); switch($ext) { case "docx": @@ -187,8 +180,7 @@ public static function IsTemplateType($name) * * @return bool */ - public static function IsTemplate($fileId) - { + public static function IsTemplate($fileId) { $template = self::GetTemplate($fileId); if (empty($template)) { @@ -205,8 +197,7 @@ public static function IsTemplate($fileId) * * @return string */ - public static function GetEmptyTemplate($name) - { + public static function GetEmptyTemplate($name) { $ext = strtolower("." . pathinfo($name, PATHINFO_EXTENSION)); $lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode(); @@ -228,8 +219,7 @@ public static function GetEmptyTemplate($name) * * @return string */ - public static function GetEmptyTemplatePath($lang, $ext) - { + public static function GetEmptyTemplatePath($lang, $ext) { if (!array_key_exists($lang, self::$localPath)) { $lang = "en"; } diff --git a/lib/templateprovider.php b/lib/templateprovider.php index 36526758..7cac06a1 100644 --- a/lib/templateprovider.php +++ b/lib/templateprovider.php @@ -26,8 +26,7 @@ use OCA\Onlyoffice\TemplateManager; -class TemplateProvider implements ICustomTemplateProvider -{ +class TemplateProvider implements ICustomTemplateProvider { /** * Application name @@ -47,8 +46,7 @@ class TemplateProvider implements ICustomTemplateProvider * @param string $AppName - application name * @param IURLGenerator $urlGenerator - url generator service */ - public function __construct($AppName, IURLGenerator $urlGenerator) - { + public function __construct($AppName, IURLGenerator $urlGenerator) { $this->appName = $AppName; $this->urlGenerator = $urlGenerator; } @@ -60,8 +58,7 @@ public function __construct($AppName, IURLGenerator $urlGenerator) * * @return array */ - public function getCustomTemplates($mimetype) : array - { + public function getCustomTemplates($mimetype) : array { $templates = []; $templateFiles = TemplateManager::GetGlobalTemplates($mimetype); @@ -88,8 +85,7 @@ public function getCustomTemplates($mimetype) : array * * @return File */ - public function getCustomTemplate($templateId) : File - { + public function getCustomTemplate($templateId) : File { return TemplateManager::GetTemplate($templateId); } } From 9744db057ff21231c5ac54ead264512c504c9d22 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 4 Oct 2023 12:13:54 +0300 Subject: [PATCH 009/209] no unused imports --- controller/editorapicontroller.php | 1 - controller/joblistcontroller.php | 5 ----- controller/sharingapicontroller.php | 7 ------- lib/cron/editorscheck.php | 1 - lib/crypt.php | 2 -- lib/directeditor.php | 4 ---- lib/documentservice.php | 2 -- lib/extrapermissions.php | 2 -- lib/filecreator.php | 2 -- lib/fileutility.php | 4 ---- lib/hooks.php | 4 ---- lib/preview.php | 7 ------- lib/settingsdata.php | 2 -- lib/templateprovider.php | 2 -- 14 files changed, 45 deletions(-) diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 5a956501..533fbb1e 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -29,7 +29,6 @@ use OCP\Files\Lock\ILock; use OCP\Files\Lock\ILockManager; use OCP\Files\Lock\NoLockProviderException; -use OCP\Files\Lock\OwnerLockedException; use OCP\PreConditionNotMetException; use OCP\IL10N; use OCP\ILogger; diff --git a/controller/joblistcontroller.php b/controller/joblistcontroller.php index 33cc9d3f..bc32203b 100644 --- a/controller/joblistcontroller.php +++ b/controller/joblistcontroller.php @@ -19,12 +19,7 @@ namespace OCA\Onlyoffice\Controller; -use OC\AppFramework\Http; -use OC\BackgroundJob\TimedJob; use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\DataDisplayResponse; -use OCP\AppFramework\Http\DataResponse; -use OCP\AppFramework\Http\Response; use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\IJobList; use OCP\IRequest; diff --git a/controller/sharingapicontroller.php b/controller/sharingapicontroller.php index 74c63a73..688d3c20 100644 --- a/controller/sharingapicontroller.php +++ b/controller/sharingapicontroller.php @@ -22,24 +22,17 @@ use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; -use OCP\IL10N; use OCP\ILogger; use OCP\IRequest; -use OCP\ISession; -use OCP\Constants; use OCP\Share\IManager; use OCP\Files\IRootFolder; use OCP\IUserManager; use OCP\IUserSession; use OCP\Files\File; use OCP\Share\IShare; -use OCP\Share\Exceptions\ShareNotFound; use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\DocumentService; -use OCA\Onlyoffice\FileUtility; -use OCA\Onlyoffice\KeyManager; use OCA\Onlyoffice\ExtraPermissions; /** diff --git a/lib/cron/editorscheck.php b/lib/cron/editorscheck.php index 5024df12..191df7e3 100644 --- a/lib/cron/editorscheck.php +++ b/lib/cron/editorscheck.php @@ -25,7 +25,6 @@ use OCP\IGroup; use OCP\IGroupManager; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCA\Onlyoffice\AppConfig; diff --git a/lib/crypt.php b/lib/crypt.php index 5b81ab40..f55259bd 100644 --- a/lib/crypt.php +++ b/lib/crypt.php @@ -19,8 +19,6 @@ namespace OCA\Onlyoffice; -use OCA\Onlyoffice\AppConfig; - /** * Token generator * diff --git a/lib/directeditor.php b/lib/directeditor.php index bec14dc3..90389d0f 100644 --- a/lib/directeditor.php +++ b/lib/directeditor.php @@ -28,10 +28,6 @@ use OCP\ILogger; use OCP\IURLGenerator; -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\Crypt; -use OCA\Onlyoffice\FileCreator; - /** * Direct Editor * diff --git a/lib/documentservice.php b/lib/documentservice.php index 4ccec2d2..fd27abab 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -21,8 +21,6 @@ use OCP\IL10N; -use OCA\Onlyoffice\AppConfig; - /** * Class service connector to Document Service * diff --git a/lib/extrapermissions.php b/lib/extrapermissions.php index ff8071b2..63ca4de6 100644 --- a/lib/extrapermissions.php +++ b/lib/extrapermissions.php @@ -26,8 +26,6 @@ use OCP\Share\IManager; use OCP\Share\Exceptions\ShareNotFound; -use OCA\Onlyoffice\AppConfig; - /** * Class expands base permissions * diff --git a/lib/filecreator.php b/lib/filecreator.php index e88d67d8..732ef332 100644 --- a/lib/filecreator.php +++ b/lib/filecreator.php @@ -24,8 +24,6 @@ use OCP\IL10N; use OCP\ILogger; -use OCA\Onlyoffice\TemplateManager; - /** * File creator * diff --git a/lib/fileutility.php b/lib/fileutility.php index a3b0efae..390f5dca 100644 --- a/lib/fileutility.php +++ b/lib/fileutility.php @@ -27,10 +27,6 @@ use OCP\ISession; use OCP\Share\IManager; -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\KeyManager; -use OCA\Onlyoffice\RemoteInstance; - /** * File utility * diff --git a/lib/hooks.php b/lib/hooks.php index 928b8beb..b4906d75 100644 --- a/lib/hooks.php +++ b/lib/hooks.php @@ -23,10 +23,6 @@ use OCP\Util; -use OCA\Onlyoffice\FileVersions; -use OCA\Onlyoffice\KeyManager; -use OCA\Onlyoffice\ExtraPermissions; - /** * The class to handle the filesystem hooks * diff --git a/lib/preview.php b/lib/preview.php index 0fb2878e..16d6297d 100644 --- a/lib/preview.php +++ b/lib/preview.php @@ -35,13 +35,6 @@ use OCA\Files_Sharing\External\Storage as SharingExternalStorage; use OCA\Files_Versions\Versions\IVersionManager; -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\Crypt; -use OCA\Onlyoffice\DocumentService; -use OCA\Onlyoffice\FileUtility; -use OCA\Onlyoffice\FileVersions; -use OCA\Onlyoffice\TemplateManager; - /** * Preview provider * diff --git a/lib/settingsdata.php b/lib/settingsdata.php index afec0244..506627c7 100644 --- a/lib/settingsdata.php +++ b/lib/settingsdata.php @@ -19,8 +19,6 @@ namespace OCA\Onlyoffice; -use OCA\Onlyoffice\AppConfig; - class SettingsData implements \JsonSerializable { /** diff --git a/lib/templateprovider.php b/lib/templateprovider.php index 7cac06a1..fd80ec8a 100644 --- a/lib/templateprovider.php +++ b/lib/templateprovider.php @@ -24,8 +24,6 @@ use OCP\Files\Template\Template; use OCP\IURLGenerator; -use OCA\Onlyoffice\TemplateManager; - class TemplateProvider implements ICustomTemplateProvider { /** From 162e78b5f38326f339be63ebcdf12ff68f4319fa Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 4 Oct 2023 12:15:11 +0300 Subject: [PATCH 010/209] ordered imports --- controller/callbackcontroller.php | 26 +++++++++++++------------- controller/editorapicontroller.php | 26 +++++++++++++------------- controller/editorcontroller.php | 24 ++++++++++++------------ controller/federationcontroller.php | 12 ++++++------ controller/joblistcontroller.php | 6 +++--- controller/settingscontroller.php | 12 ++++++------ controller/sharingapicontroller.php | 12 ++++++------ controller/templatecontroller.php | 4 ++-- lib/adminsettings.php | 4 ++-- lib/command/documentserver.php | 14 +++++++------- lib/cron/editorscheck.php | 8 ++++---- lib/extrapermissions.php | 6 +++--- lib/fileversions.php | 4 ++-- lib/listeners/directeditorlistener.php | 8 ++++---- lib/listeners/filesharinglistener.php | 14 +++++++------- lib/listeners/fileslistener.php | 14 +++++++------- lib/listeners/viewerlistener.php | 14 +++++++------- lib/listeners/widgetlistener.php | 6 +++--- lib/preview.php | 6 +++--- lib/remoteinstance.php | 4 ++-- lib/templatemanager.php | 4 ++-- 21 files changed, 114 insertions(+), 114 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index da8138da..eec61d17 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -19,6 +19,14 @@ namespace OCA\Onlyoffice\Controller; +use OCA\Files_Versions\Versions\IVersionManager; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\Crypt; +use OCA\Onlyoffice\DocumentService; +use OCA\Onlyoffice\FileVersions; +use OCA\Onlyoffice\KeyManager; +use OCA\Onlyoffice\RemoteInstance; +use OCA\Onlyoffice\TemplateManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataDownloadResponse; @@ -28,33 +36,25 @@ use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; -use OCP\Files\NotFoundException; -use OCP\Files\NotPermittedException; use OCP\Files\Lock\ILock; use OCP\Files\Lock\ILockManager; use OCP\Files\Lock\LockContext; use OCP\Files\Lock\NoLockProviderException; use OCP\Files\Lock\OwnerLockedException; -use OCP\PreConditionNotMetException; +use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\IL10N; + use OCP\ILogger; + use OCP\IRequest; use OCP\IUserManager; use OCP\IUserSession; use OCP\Lock\LockedException; +use OCP\PreConditionNotMetException; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; -use OCA\Files_Versions\Versions\IVersionManager; - -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\Crypt; -use OCA\Onlyoffice\DocumentService; -use OCA\Onlyoffice\FileVersions; -use OCA\Onlyoffice\KeyManager; -use OCA\Onlyoffice\RemoteInstance; -use OCA\Onlyoffice\TemplateManager; - /** * Callback handler for the document server. * Download the file without authentication. diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 533fbb1e..04af4d21 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -19,8 +19,16 @@ namespace OCA\Onlyoffice\Controller; -use OCP\AppFramework\OCSController; +use OCA\Files_Versions\Versions\IVersionManager; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\Crypt; +use OCA\Onlyoffice\DocumentService; +use OCA\Onlyoffice\ExtraPermissions; +use OCA\Onlyoffice\FileUtility; +use OCA\Onlyoffice\FileVersions; +use OCA\Onlyoffice\TemplateManager; use OCP\AppFramework\Http\JSONResponse; +use OCP\AppFramework\OCSController; use OCP\AppFramework\QueryException; use OCP\Constants; use OCP\Files\File; @@ -29,30 +37,22 @@ use OCP\Files\Lock\ILock; use OCP\Files\Lock\ILockManager; use OCP\Files\Lock\NoLockProviderException; -use OCP\PreConditionNotMetException; use OCP\IL10N; use OCP\ILogger; use OCP\IRequest; use OCP\ISession; -use OCP\ITags; use OCP\ITagManager; + +use OCP\ITags; + use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; +use OCP\PreConditionNotMetException; use OCP\Share\IManager; use OCP\Share\IShare; -use OCA\Files_Versions\Versions\IVersionManager; - -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\Crypt; -use OCA\Onlyoffice\DocumentService; -use OCA\Onlyoffice\FileVersions; -use OCA\Onlyoffice\FileUtility; -use OCA\Onlyoffice\TemplateManager; -use OCA\Onlyoffice\ExtraPermissions; - /** * Controller with the main functions */ diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 385171a6..d947560a 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -19,39 +19,39 @@ namespace OCA\Onlyoffice\Controller; +use OCA\Files\Helper; +use OCA\Files_Versions\Versions\IVersionManager; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\Crypt; +use OCA\Onlyoffice\DocumentService; +use OCA\Onlyoffice\FileUtility; +use OCA\Onlyoffice\FileVersions; +use OCA\Onlyoffice\TemplateManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\DataDownloadResponse; use OCP\AppFramework\Http\RedirectResponse; -use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\Template\PublicTemplateResponse; +use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\QueryException; use OCP\Constants; use OCP\Files\File; use OCP\Files\IRootFolder; use OCP\Files\NotPermittedException; +use OCP\IGroupManager; use OCP\IL10N; use OCP\ILogger; + use OCP\IRequest; use OCP\ISession; + use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; -use OCP\IGroupManager; use OCP\Share\IManager; use OCP\Share\IShare; -use OCA\Files\Helper; -use OCA\Files_Versions\Versions\IVersionManager; - -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\Crypt; -use OCA\Onlyoffice\DocumentService; -use OCA\Onlyoffice\FileUtility; -use OCA\Onlyoffice\TemplateManager; -use OCA\Onlyoffice\FileVersions; - /** * Controller with the main functions */ diff --git a/controller/federationcontroller.php b/controller/federationcontroller.php index 55ec234b..c06af242 100644 --- a/controller/federationcontroller.php +++ b/controller/federationcontroller.php @@ -19,20 +19,20 @@ namespace OCA\Onlyoffice\Controller; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\DocumentService; +use OCA\Onlyoffice\FileUtility; +use OCA\Onlyoffice\KeyManager; +use OCA\Onlyoffice\RemoteInstance; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; + use OCP\IL10N; use OCP\ILogger; use OCP\IRequest; use OCP\ISession; use OCP\Share\IManager; -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\DocumentService; -use OCA\Onlyoffice\FileUtility; -use OCA\Onlyoffice\KeyManager; -use OCA\Onlyoffice\RemoteInstance; - /** * OCS handler */ diff --git a/controller/joblistcontroller.php b/controller/joblistcontroller.php index bc32203b..ee5f4752 100644 --- a/controller/joblistcontroller.php +++ b/controller/joblistcontroller.php @@ -19,14 +19,14 @@ namespace OCA\Onlyoffice\Controller; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\Cron\EditorsCheck; use OCP\AppFramework\Controller; use OCP\BackgroundJob\IJob; + use OCP\BackgroundJob\IJobList; use OCP\IRequest; -use OCA\Onlyoffice\Cron\EditorsCheck; -use OCA\Onlyoffice\AppConfig; - /** * Class JobListController * diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index b1660482..0e181196 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -19,19 +19,19 @@ namespace OCA\Onlyoffice\Controller; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\Crypt; +use OCA\Onlyoffice\DocumentService; +use OCA\Onlyoffice\FileVersions; +use OCA\Onlyoffice\TemplateManager; use OCP\AppFramework\Controller; + use OCP\AppFramework\Http\TemplateResponse; use OCP\IL10N; use OCP\ILogger; use OCP\IRequest; use OCP\IURLGenerator; -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\Crypt; -use OCA\Onlyoffice\DocumentService; -use OCA\Onlyoffice\FileVersions; -use OCA\Onlyoffice\TemplateManager; - /** * Settings controller for the administration page */ diff --git a/controller/sharingapicontroller.php b/controller/sharingapicontroller.php index 688d3c20..e4693a46 100644 --- a/controller/sharingapicontroller.php +++ b/controller/sharingapicontroller.php @@ -19,21 +19,21 @@ namespace OCA\Onlyoffice\Controller; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\ExtraPermissions; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; +use OCP\Files\File; +use OCP\Files\IRootFolder; use OCP\ILogger; use OCP\IRequest; -use OCP\Share\IManager; -use OCP\Files\IRootFolder; use OCP\IUserManager; use OCP\IUserSession; -use OCP\Files\File; -use OCP\Share\IShare; -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\ExtraPermissions; +use OCP\Share\IManager; +use OCP\Share\IShare; /** * OCS handler diff --git a/controller/templatecontroller.php b/controller/templatecontroller.php index dcde80ff..8f902ec9 100644 --- a/controller/templatecontroller.php +++ b/controller/templatecontroller.php @@ -19,6 +19,7 @@ namespace OCA\Onlyoffice\Controller; +use OCA\Onlyoffice\TemplateManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; @@ -27,9 +28,8 @@ use OCP\IL10N; use OCP\ILogger; use OCP\IPreview; -use OCP\IRequest; -use OCA\Onlyoffice\TemplateManager; +use OCP\IRequest; /** * OCS handler diff --git a/lib/adminsettings.php b/lib/adminsettings.php index d1d394e9..a79af0e3 100644 --- a/lib/adminsettings.php +++ b/lib/adminsettings.php @@ -19,10 +19,10 @@ namespace OCA\Onlyoffice; -use OCP\Settings\ISettings; - use OCA\Onlyoffice\AppInfo\Application; + use OCA\Onlyoffice\Controller\SettingsController; +use OCP\Settings\ISettings; /** * Settings controller for the administration page diff --git a/lib/command/documentserver.php b/lib/command/documentserver.php index 96cd8795..9ba0ae80 100644 --- a/lib/command/documentserver.php +++ b/lib/command/documentserver.php @@ -19,18 +19,18 @@ namespace OCA\Onlyoffice\Command; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\Crypt; +use OCA\Onlyoffice\DocumentService; +use OCP\IL10N; + +use OCP\IURLGenerator; use Symfony\Component\Console\Command\Command; + use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use OCP\IURLGenerator; -use OCP\IL10N; - -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\DocumentService; -use OCA\Onlyoffice\Crypt; - class DocumentServer extends Command { /** diff --git a/lib/cron/editorscheck.php b/lib/cron/editorscheck.php index 191df7e3..b4b6060d 100644 --- a/lib/cron/editorscheck.php +++ b/lib/cron/editorscheck.php @@ -19,18 +19,18 @@ namespace OCA\Onlyoffice\Cron; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\Crypt; +use OCA\Onlyoffice\DocumentService; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\TimedJob; use OCP\IGroup; + use OCP\IGroupManager; use OCP\IL10N; use OCP\IURLGenerator; -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\Crypt; -use OCA\Onlyoffice\DocumentService; - /** * Editors availability check background job * diff --git a/lib/extrapermissions.php b/lib/extrapermissions.php index 63ca4de6..d4c2a5aa 100644 --- a/lib/extrapermissions.php +++ b/lib/extrapermissions.php @@ -20,11 +20,11 @@ namespace OCA\Onlyoffice; use OCP\Constants; -use OCP\ILogger; use OCP\Files\File; -use OCP\Share\IShare; -use OCP\Share\IManager; +use OCP\ILogger; use OCP\Share\Exceptions\ShareNotFound; +use OCP\Share\IManager; +use OCP\Share\IShare; /** * Class expands base permissions diff --git a/lib/fileversions.php b/lib/fileversions.php index b065455f..66c31d56 100644 --- a/lib/fileversions.php +++ b/lib/fileversions.php @@ -23,11 +23,11 @@ use OC\Files\View; use OC\User\Database; +use OCA\Files_Sharing\External\Storage as SharingExternalStorage; use OCP\Files\FileInfo; use OCP\Files\IRootFolder; -use OCP\IUser; -use OCA\Files_Sharing\External\Storage as SharingExternalStorage; +use OCP\IUser; /** * File versions diff --git a/lib/listeners/directeditorlistener.php b/lib/listeners/directeditorlistener.php index 4898c120..f9718435 100644 --- a/lib/listeners/directeditorlistener.php +++ b/lib/listeners/directeditorlistener.php @@ -19,12 +19,12 @@ namespace OCA\Onlyoffice\Listeners; -use OCP\EventDispatcher\Event; -use OCP\EventDispatcher\IEventListener; -use OCP\DirectEditing\RegisterDirectEditorEvent; - use OCA\Onlyoffice\AppConfig; use OCA\Onlyoffice\DirectEditor; +use OCP\DirectEditing\RegisterDirectEditorEvent; + +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; /** * DirectEditor listener diff --git a/lib/listeners/filesharinglistener.php b/lib/listeners/filesharinglistener.php index d3ec0e2f..a2273788 100644 --- a/lib/listeners/filesharinglistener.php +++ b/lib/listeners/filesharinglistener.php @@ -19,16 +19,16 @@ namespace OCA\Onlyoffice\Listeners; -use OCP\EventDispatcher\Event; -use OCP\EventDispatcher\IEventListener; -use OCP\Util; -use OCP\AppFramework\Services\IInitialState; -use OCP\IServerContainer; - use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; - use OCA\Onlyoffice\AppConfig; use OCA\Onlyoffice\SettingsData; +use OCP\AppFramework\Services\IInitialState; +use OCP\EventDispatcher\Event; + +use OCP\EventDispatcher\IEventListener; + +use OCP\IServerContainer; +use OCP\Util; /** * File Sharing listener diff --git a/lib/listeners/fileslistener.php b/lib/listeners/fileslistener.php index a68dbb07..7173aa2e 100644 --- a/lib/listeners/fileslistener.php +++ b/lib/listeners/fileslistener.php @@ -19,16 +19,16 @@ namespace OCA\Onlyoffice\Listeners; -use OCP\EventDispatcher\Event; -use OCP\EventDispatcher\IEventListener; -use OCP\Util; -use OCP\AppFramework\Services\IInitialState; -use OCP\IServerContainer; - use OCA\Files\Event\LoadAdditionalScriptsEvent; - use OCA\Onlyoffice\AppConfig; use OCA\Onlyoffice\SettingsData; +use OCP\AppFramework\Services\IInitialState; +use OCP\EventDispatcher\Event; + +use OCP\EventDispatcher\IEventListener; + +use OCP\IServerContainer; +use OCP\Util; /** * File listener diff --git a/lib/listeners/viewerlistener.php b/lib/listeners/viewerlistener.php index 8d824daa..c04b4b69 100644 --- a/lib/listeners/viewerlistener.php +++ b/lib/listeners/viewerlistener.php @@ -19,17 +19,17 @@ namespace OCA\Onlyoffice\Listeners; -use OCP\EventDispatcher\Event; -use OCP\EventDispatcher\IEventListener; -use OCP\Util; +use OCA\Onlyoffice\AppConfig; +use OCA\Onlyoffice\SettingsData; +use OCA\Viewer\Event\LoadViewer; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Services\IInitialState; -use OCP\IServerContainer; +use OCP\EventDispatcher\Event; -use OCA\Viewer\Event\LoadViewer; +use OCP\EventDispatcher\IEventListener; -use OCA\Onlyoffice\AppConfig; -use OCA\Onlyoffice\SettingsData; +use OCP\IServerContainer; +use OCP\Util; /** * Viewer listener diff --git a/lib/listeners/widgetlistener.php b/lib/listeners/widgetlistener.php index 31693f0c..ccd80ebe 100644 --- a/lib/listeners/widgetlistener.php +++ b/lib/listeners/widgetlistener.php @@ -19,12 +19,12 @@ namespace OCA\Onlyoffice\Listeners; +use OCA\Onlyoffice\AppConfig; +use OCP\Dashboard\RegisterWidgetEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\Util; -use OCP\Dashboard\RegisterWidgetEvent; -use OCA\Onlyoffice\AppConfig; +use OCP\Util; /** * Widget listener diff --git a/lib/preview.php b/lib/preview.php index 16d6297d..d29ac650 100644 --- a/lib/preview.php +++ b/lib/preview.php @@ -22,6 +22,8 @@ use OC\Files\View; use OC\Preview\Provider; +use OCA\Files_Sharing\External\Storage as SharingExternalStorage; +use OCA\Files_Versions\Versions\IVersionManager; use OCP\AppFramework\QueryException; use OCP\Files\FileInfo; use OCP\Files\IRootFolder; @@ -29,12 +31,10 @@ use OCP\ILogger; use OCP\Image; use OCP\ISession; + use OCP\IURLGenerator; use OCP\Share\IManager; -use OCA\Files_Sharing\External\Storage as SharingExternalStorage; -use OCA\Files_Versions\Versions\IVersionManager; - /** * Preview provider * diff --git a/lib/remoteinstance.php b/lib/remoteinstance.php index 8c74b8b6..f4578175 100644 --- a/lib/remoteinstance.php +++ b/lib/remoteinstance.php @@ -19,10 +19,10 @@ namespace OCA\Onlyoffice; -use OCP\Files\File; - use OCA\Files_Sharing\External\Storage as SharingExternalStorage; +use OCP\Files\File; + /** * Remote instance manager * diff --git a/lib/templatemanager.php b/lib/templatemanager.php index 7ec2bbd8..59a5b815 100644 --- a/lib/templatemanager.php +++ b/lib/templatemanager.php @@ -19,10 +19,10 @@ namespace OCA\Onlyoffice; -use OCP\Files\NotFoundException; - use OCP\Files\File; +use OCP\Files\NotFoundException; + /** * Template manager * From df129c476059be82ecdf5cd229c73d5ccd20e7c5 Mon Sep 17 00:00:00 2001 From: rivexe Date: Wed, 4 Oct 2023 12:16:44 +0300 Subject: [PATCH 011/209] visibility required --- controller/editorapicontroller.php | 2 +- lib/appconfig.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 04af4d21..9852aae1 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -152,7 +152,7 @@ class EditorApiController extends OCSController { /** * Mobile regex from https://github.com/ONLYOFFICE/CommunityServer/blob/v9.1.1/web/studio/ASC.Web.Studio/web.appsettings.config#L35 */ - const USER_AGENT_MOBILE = "/android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i"; + public const USER_AGENT_MOBILE = "/android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i"; /** * @param string $AppName - application name diff --git a/lib/appconfig.php b/lib/appconfig.php index ac6d1ac3..01707fcb 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -240,7 +240,7 @@ class AppConfig { * * @var string */ - const WATERMARK_APP_NAMESPACE = "files"; + public const WATERMARK_APP_NAMESPACE = "files"; /** * The config key for limit thumbnail size From b16d1920d7c78a3ea6c4fe20e203f634a7c8a17f Mon Sep 17 00:00:00 2001 From: Stepan Mayorov Date: Thu, 5 Oct 2023 14:29:24 +0300 Subject: [PATCH 012/209] Update lint-phpcs.yml --- .github/workflows/lint-phpcs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-phpcs.yml b/.github/workflows/lint-phpcs.yml index 098f0e0c..f897cdae 100644 --- a/.github/workflows/lint-phpcs.yml +++ b/.github/workflows/lint-phpcs.yml @@ -3,7 +3,7 @@ name: Lint on: push: pull_request: - branches: [master] + branches: [refactor/linter-formatting] permissions: contents: read @@ -23,4 +23,4 @@ jobs: tools: composer, cs2pr, phpcs - name: Run phpcs run: | - phpcs --standard=PSR2 --extensions=php,module,inc,install --ignore=node_modules,bower_components,vendor,3rdparty,Migration --warning-severity=0 ./ \ No newline at end of file + phpcs --standard=PSR2 --extensions=php,module,inc,install --ignore=node_modules,bower_components,vendor,3rdparty,Migration --warning-severity=0 ./ From 380a8ba11fd7abc92ab85965b450fc5544505ac9 Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 5 Oct 2023 14:39:54 +0300 Subject: [PATCH 013/209] added ruleset.xml --- ruleset.xml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 ruleset.xml diff --git a/ruleset.xml b/ruleset.xml new file mode 100644 index 00000000..ddc80189 --- /dev/null +++ b/ruleset.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 16803ee91a84d0c9682492af5729455492e6f0fa Mon Sep 17 00:00:00 2001 From: Stepan Mayorov Date: Thu, 5 Oct 2023 14:40:55 +0300 Subject: [PATCH 014/209] Update lint-phpcs.yml --- .github/workflows/lint-phpcs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-phpcs.yml b/.github/workflows/lint-phpcs.yml index f897cdae..082af8ed 100644 --- a/.github/workflows/lint-phpcs.yml +++ b/.github/workflows/lint-phpcs.yml @@ -23,4 +23,4 @@ jobs: tools: composer, cs2pr, phpcs - name: Run phpcs run: | - phpcs --standard=PSR2 --extensions=php,module,inc,install --ignore=node_modules,bower_components,vendor,3rdparty,Migration --warning-severity=0 ./ + phpcs --standard=./ruleset.xml --extensions=php,module,inc,install --ignore=node_modules,bower_components,vendor,3rdparty,Migration --warning-severity=0 ./ From edc292cbf835ab50e2128953c889c735a8c53322 Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 5 Oct 2023 14:52:10 +0300 Subject: [PATCH 015/209] exclude BraceOnSameLine rule --- ruleset.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ruleset.xml b/ruleset.xml index ddc80189..ef068679 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -1,5 +1,8 @@ - + + + + \ No newline at end of file From 1d4a147f023f0ac45c0574695a9a3423e6da6848 Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 5 Oct 2023 14:54:29 +0300 Subject: [PATCH 016/209] exclude OpenBraceNewLine rule --- ruleset.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/ruleset.xml b/ruleset.xml index ef068679..54cc447a 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -3,6 +3,7 @@ + \ No newline at end of file From e37c42175789d26151b9c4e4048fb96e72edafef Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 5 Oct 2023 15:00:35 +0300 Subject: [PATCH 017/209] braces rules excluded --- ruleset.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ruleset.xml b/ruleset.xml index 54cc447a..3bb6ef3c 100644 --- a/ruleset.xml +++ b/ruleset.xml @@ -4,6 +4,10 @@ + + + + \ No newline at end of file From 866ed928bf2004b96e49588a1bf0246186049f7a Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 5 Oct 2023 15:08:05 +0300 Subject: [PATCH 018/209] line indent fix --- appinfo/application.php | 18 +++++++++--------- templates/editor.php | 6 +++--- templates/settings.php | 10 +++++----- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/appinfo/application.php b/appinfo/application.php index 6f150467..26712261 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -284,16 +284,16 @@ public function boot(IBootContext $context): void { if (class_exists("OCP\Files\Template\FileCreatedFromTemplateEvent")) { $eventDispatcher->addListener(FileCreatedFromTemplateEvent::class, - function (FileCreatedFromTemplateEvent $event) { - $template = $event->getTemplate(); - if ($template === null) { - $targetFile = $event->getTarget(); - $templateEmpty = TemplateManager::GetEmptyTemplate($targetFile->getName()); - if ($templateEmpty) { - $targetFile->putContent($templateEmpty); - } + function (FileCreatedFromTemplateEvent $event) { + $template = $event->getTemplate(); + if ($template === null) { + $targetFile = $event->getTarget(); + $templateEmpty = TemplateManager::GetEmptyTemplate($targetFile->getName()); + if ($templateEmpty) { + $targetFile->putContent($templateEmpty); } - }); + } + }); } }); diff --git a/templates/editor.php b/templates/editor.php index de3d9b89..112dc071 100644 --- a/templates/editor.php +++ b/templates/editor.php @@ -20,9 +20,9 @@ style("onlyoffice", "editor"); script("onlyoffice", "desktop"); script("onlyoffice", "editor"); - if (!empty($_["directToken"])) { - script("onlyoffice", "directeditor"); - } +if (!empty($_["directToken"])) { + script("onlyoffice", "directeditor"); +} ?>

From 5a8591215d7146539964c9cb3079801ca7dae47a Mon Sep 17 00:00:00 2001 From: rivexe Date: Thu, 5 Oct 2023 15:12:34 +0300 Subject: [PATCH 019/209] single blank line at eof --- appinfo/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appinfo/routes.php b/appinfo/routes.php index 8f646e2d..62b7e4b0 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -53,4 +53,4 @@ ["name" => "sharingapi#get_shares", "url" => "/api/v1/shares/{fileId}", "verb" => "GET"], ["name" => "sharingapi#set_shares", "url" => "/api/v1/shares", "verb" => "PUT"] ] -]; \ No newline at end of file +]; From 48bc5d9a49fc9baedbaa058496ec63da4c39deb3 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 6 Oct 2023 10:02:50 +0300 Subject: [PATCH 020/209] no blank line before closing braces --- controller/templatecontroller.php | 1 - lib/cron/editorscheck.php | 1 - 2 files changed, 2 deletions(-) diff --git a/controller/templatecontroller.php b/controller/templatecontroller.php index 8f902ec9..84f9b577 100644 --- a/controller/templatecontroller.php +++ b/controller/templatecontroller.php @@ -212,6 +212,5 @@ public function preview($fileId, $x = 256, $y = 256, $crop = false, $mode = IPre } catch (\InvalidArgumentException $e) { return new DataResponse([], Http::STATUS_BAD_REQUEST); } - } } diff --git a/lib/cron/editorscheck.php b/lib/cron/editorscheck.php index b4b6060d..a82a6273 100644 --- a/lib/cron/editorscheck.php +++ b/lib/cron/editorscheck.php @@ -192,5 +192,4 @@ private function notifyAdmins() { $notificationManager->notify($notification); } } - } From af8ed78e927e79a15897e7a7b513dafccfa1b435 Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 6 Oct 2023 10:15:17 +0300 Subject: [PATCH 021/209] spaces after construct + unix eol --- controller/editorapicontroller.php | 6 +++--- controller/templatecontroller.php | 2 +- lib/documentservice.php | 2 +- lib/templatemanager.php | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 9852aae1..27f8b9ad 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -531,7 +531,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $templatesList = TemplateManager::GetGlobalTemplates($file->getMimeType()); if (!empty($templatesList)) { $templates = []; - foreach($templatesList as $templateItem) { + foreach ($templatesList as $templateItem) { $createParam["templateId"] = $templateItem->getId(); $createParam["name"] = $templateItem->getName(); @@ -764,12 +764,12 @@ private function setCustomization($params) { } //default is true - if($this->config->GetCustomizationMacros() === false) { + if ($this->config->GetCustomizationMacros() === false) { $params["editorConfig"]["customization"]["macros"] = false; } //default is true - if($this->config->GetCustomizationPlugins() === false) { + if ($this->config->GetCustomizationPlugins() === false) { $params["editorConfig"]["customization"]["plugins"] = false; } diff --git a/controller/templatecontroller.php b/controller/templatecontroller.php index 84f9b577..d4e94f73 100644 --- a/controller/templatecontroller.php +++ b/controller/templatecontroller.php @@ -156,7 +156,7 @@ public function DeleteTemplate($templateId) { try { $templates = $templateDir->getById($templateId); - } catch(\Exception $e) { + } catch (\Exception $e) { $this->logger->logException($e, ["message" => "DeleteTemplate: $templateId", "app" => $this->AppName]); return [ "error" => $this->trans->t("Failed to delete template") diff --git a/lib/documentservice.php b/lib/documentservice.php index fd27abab..ec7a3ac3 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -181,7 +181,7 @@ public function SendRequestToConvertService($document_uri, $from_extension, $to_ $response_data = simplexml_load_string($response_xml_data); if (!$response_data) { $exc = $this->trans->t("Bad Response. Errors: "); - foreach(libxml_get_errors() as $error) { + foreach (libxml_get_errors() as $error) { $exc = $exc . "\t" . $error->message; } throw new \Exception($exc); diff --git a/lib/templatemanager.php b/lib/templatemanager.php index 59a5b815..000b9a2e 100644 --- a/lib/templatemanager.php +++ b/lib/templatemanager.php @@ -122,7 +122,7 @@ public static function GetTemplate($templateId) { * @return string */ public static function GetTypeTemplate($mime) { - switch($mime) { + switch ($mime) { case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return "document"; case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": @@ -142,7 +142,7 @@ public static function GetTypeTemplate($mime) { * @return string */ public static function GetMimeTemplate($type) { - switch($type) { + switch ($type) { case "document": return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; case "spreadsheet": @@ -163,7 +163,7 @@ public static function GetMimeTemplate($type) { */ public static function IsTemplateType($name) { $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); - switch($ext) { + switch ($ext) { case "docx": case "xlsx": case "pptx": From 37b20c5a6aa19538e106dc2e6dcabfcd61b093ff Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 10 Oct 2023 15:49:54 +0300 Subject: [PATCH 022/209] =?UTF-8?q?no=20spaces=20with=20=D1=81losing=20and?= =?UTF-8?q?=20opening=20parenthesis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appinfo/application.php | 25 +++++++++++++------------ controller/editorapicontroller.php | 1 - controller/editorcontroller.php | 2 -- lib/documentservice.php | 11 ----------- lib/extrapermissions.php | 1 - lib/fileutility.php | 1 - lib/listeners/directeditorlistener.php | 1 - lib/listeners/fileslistener.php | 1 - lib/remoteinstance.php | 1 - 9 files changed, 13 insertions(+), 31 deletions(-) diff --git a/appinfo/application.php b/appinfo/application.php index 26712261..4fbb8b60 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -258,7 +258,7 @@ public function register(IRegistrationContext $context): void { $container = $this->getContainer(); $previewManager = $container->query(IPreview::class); - $previewManager->registerProvider(Preview::getMimeTypeRegex(), function() use ($container) { + $previewManager->registerProvider(Preview::getMimeTypeRegex(), function () use ($container) { return $container->query(Preview::class); }); @@ -283,17 +283,19 @@ public function boot(IBootContext $context): void { $context->injectFn(function (SymfonyAdapter $eventDispatcher) { if (class_exists("OCP\Files\Template\FileCreatedFromTemplateEvent")) { - $eventDispatcher->addListener(FileCreatedFromTemplateEvent::class, - function (FileCreatedFromTemplateEvent $event) { - $template = $event->getTemplate(); - if ($template === null) { - $targetFile = $event->getTarget(); - $templateEmpty = TemplateManager::GetEmptyTemplate($targetFile->getName()); - if ($templateEmpty) { - $targetFile->putContent($templateEmpty); + $eventDispatcher->addListener( + FileCreatedFromTemplateEvent::class, + function (FileCreatedFromTemplateEvent $event) { + $template = $event->getTemplate(); + if ($template === null) { + $targetFile = $event->getTarget(); + $templateEmpty = TemplateManager::GetEmptyTemplate($targetFile->getName()); + if ($templateEmpty) { + $targetFile->putContent($templateEmpty); + } } } - }); + ); } }); @@ -302,11 +304,10 @@ function (FileCreatedFromTemplateEvent $event) { }); if (class_exists("OCP\Files\Template\TemplateFileCreator")) { - $context->injectFn(function(ITemplateManager $templateManager, IL10N $trans, $appName) { + $context->injectFn(function (ITemplateManager $templateManager, IL10N $trans, $appName) { if (!empty($this->appConfig->GetDocumentServerUrl()) && $this->appConfig->SettingsAreSuccessful() && $this->appConfig->isUserAllowedToUse()) { - $templateManager->registerTemplateFileCreator(function () use ($appName, $trans) { $wordTemplate = new TemplateFileCreator($appName, $trans->t("New document"), ".docx"); $wordTemplate->addMimetype("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 27f8b9ad..83211185 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -451,7 +451,6 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok if (!$template && $file->isUpdateable() && (empty($shareToken) || ($share->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE)) { - $params["document"]["permissions"]["changeHistory"] = true; } diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index d947560a..9219bd3c 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -515,7 +515,6 @@ public function mention($fileId, $anchor, $comment, $emails) { if (!$isAvailable && ($file->getFileInfo()->getStorage()->instanceOfStorage("\OCA\GroupFolders\Mount\GroupFolderStorage") || $file->getFileInfo()->getMountPoint() instanceof \OCA\Files_External\Config\ExternalMountPoint)) { - $recipientFolder = $this->root->getUserFolder($recipientId); $recipientFile = $recipientFolder->getById($file->getId()); @@ -978,7 +977,6 @@ public function version($fileId, $version) { if ($version > 1 && count($versions) >= $version - 1 && FileVersions::hasChanges($ownerId, $fileId, $versionId)) { - $changesUrl = $this->getUrl($file, $user, null, $version, true); $result["changesUrl"] = $changesUrl; diff --git a/lib/documentservice.php b/lib/documentservice.php index ec7a3ac3..7d5b9312 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -388,45 +388,36 @@ public function checkDocServiceUrl($urlGenerator, $crypt) { $version = null; try { - if (preg_match("/^https:\/\//i", $urlGenerator->getAbsoluteURL("/")) && preg_match("/^http:\/\//i", $this->config->GetDocumentServerUrl())) { throw new \Exception($this->trans->t("Mixed Active Content is not allowed. HTTPS address for ONLYOFFICE Docs is required.")); } - } catch (\Exception $e) { $logger->logException($e, ["message" => "Protocol on check error", "app" => self::$appName]); return [$e->getMessage(), $version]; } try { - $healthcheckResponse = $this->HealthcheckRequest(); if (!$healthcheckResponse) { throw new \Exception($this->trans->t("Bad healthcheck status")); } - } catch (\Exception $e) { $logger->logException($e, ["message" => "HealthcheckRequest on check error", "app" => self::$appName]); return [$e->getMessage(), $version]; } try { - $commandResponse = $this->CommandRequest("version"); - $logger->debug("CommandRequest on check: " . json_encode($commandResponse), ["app" => self::$appName]); - if (empty($commandResponse)) { throw new \Exception($this->trans->t("Error occurred in the document service")); } - $version = $commandResponse->version; $versionF = floatval($version); if ($versionF > 0.0 && $versionF <= 6.0) { throw new \Exception($this->trans->t("Not supported version")); } - } catch (\Exception $e) { $logger->logException($e, ["message" => "CommandRequest on check error", "app" => self::$appName]); return [$e->getMessage(), $version]; @@ -434,7 +425,6 @@ public function checkDocServiceUrl($urlGenerator, $crypt) { $convertedFileUri = null; try { - $hashUrl = $crypt->GetHash(["action" => "empty"]); $fileUrl = $urlGenerator->linkToRouteAbsolute(self::$appName . ".callback.emptyfile", ["doc" => $hashUrl]); if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { @@ -446,7 +436,6 @@ public function checkDocServiceUrl($urlGenerator, $crypt) { if (strcmp($convertedFileUri, $fileUrl) === 0) { $logger->debug("GetConvertedUri skipped", ["app" => self::$appName]); } - } catch (\Exception $e) { $logger->logException($e, ["message" => "GetConvertedUri on check error", "app" => self::$appName]); return [$e->getMessage(), $version]; diff --git a/lib/extrapermissions.php b/lib/extrapermissions.php index d4c2a5aa..8c6bec95 100644 --- a/lib/extrapermissions.php +++ b/lib/extrapermissions.php @@ -161,7 +161,6 @@ public function getExtras($shares) { $noActualList = []; foreach ($shares as $share) { - $currentExtra = []; foreach ($extras as $extra) { if ($extra["share_id"] === $share->getId()) { diff --git a/lib/fileutility.php b/lib/fileutility.php index 390f5dca..e4d4b35a 100644 --- a/lib/fileutility.php +++ b/lib/fileutility.php @@ -219,7 +219,6 @@ public function getKey($file, $origin = false) { if ($origin && RemoteInstance::isRemoteFile($file)) { - $key = RemoteInstance::getRemoteKey($file); if (!empty($key)) { return $key; diff --git a/lib/listeners/directeditorlistener.php b/lib/listeners/directeditorlistener.php index f9718435..4c1de5a1 100644 --- a/lib/listeners/directeditorlistener.php +++ b/lib/listeners/directeditorlistener.php @@ -64,7 +64,6 @@ public function handle(Event $event): void { if (!empty($this->appConfig->GetDocumentServerUrl()) && $this->appConfig->SettingsAreSuccessful()) { - $event->register($this->editor); } } diff --git a/lib/listeners/fileslistener.php b/lib/listeners/fileslistener.php index 7173aa2e..2d2c15cf 100644 --- a/lib/listeners/fileslistener.php +++ b/lib/listeners/fileslistener.php @@ -79,7 +79,6 @@ public function handle(Event $event): void { if (!empty($this->appConfig->GetDocumentServerUrl()) && $this->appConfig->SettingsAreSuccessful() && $this->appConfig->isUserAllowedToUse()) { - Util::addScript("onlyoffice", "desktop"); Util::addScript("onlyoffice", "main"); Util::addScript("onlyoffice", "template"); diff --git a/lib/remoteinstance.php b/lib/remoteinstance.php index f4578175..34cc525b 100644 --- a/lib/remoteinstance.php +++ b/lib/remoteinstance.php @@ -143,7 +143,6 @@ public static function healthCheck($remote) { if (isset($data["alive"])) { $status = $data["alive"] === true; } - } catch (\Exception $e) { $logger->logException($e, ["message" => "Failed to request federated health check for" . $remote, "app" => self::App_Name]); } From f1ec41ec9064ef14233615e603c951d371553dab Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 10 Oct 2023 16:25:47 +0300 Subject: [PATCH 023/209] UPPERCASE for class constants --- controller/callbackcontroller.php | 28 +++++++++--------- controller/editorapicontroller.php | 8 +++--- lib/extrapermissions.php | 46 +++++++++++++++--------------- lib/keymanager.php | 14 ++++----- lib/preview.php | 6 ++-- lib/remoteinstance.php | 38 ++++++++++++------------ templates/settings.php | 2 +- 7 files changed, 71 insertions(+), 71 deletions(-) diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index eec61d17..e4b91d89 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -135,12 +135,12 @@ class CallbackController extends Controller { /** * Status of the document */ - private const TrackerStatus_Editing = 1; - private const TrackerStatus_MustSave = 2; - private const TrackerStatus_Corrupted = 3; - private const TrackerStatus_Closed = 4; - private const TrackerStatus_ForceSave = 6; - private const TrackerStatus_CorruptedForceSave = 7; + private const TRACKERSTATUS_EDITING = 1; + private const TRACKERSTATUS_MUSTSAVE = 2; + private const TRACKERSTATUS_CORRUPTED = 3; + private const TRACKERSTATUS_CLOSED = 4; + private const TRACKERSTATUS_FORCESAVE = 6; + private const TRACKERSTATUS_CORRUPTEDFORCESAVE = 7; /** * @param string $AppName - application name @@ -448,13 +448,13 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan \OC_Util::tearDownFS(); - $isForcesave = $status === self::TrackerStatus_ForceSave || $status === self::TrackerStatus_CorruptedForceSave; + $isForcesave = $status === self::TRACKERSTATUS_FORCESAVE || $status === self::TRACKERSTATUS_CORRUPTEDFORCESAVE; $callbackUserId = $hashData->userId; $userId = null; if (!empty($users) - && $status !== self::TrackerStatus_Editing) { + && $status !== self::TRACKERSTATUS_EDITING) { // author of the latest changes $userId = $this->parseUserId($users[0]); } else { @@ -511,10 +511,10 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan $result = 1; switch ($status) { - case self::TrackerStatus_MustSave: - case self::TrackerStatus_Corrupted: - case self::TrackerStatus_ForceSave: - case self::TrackerStatus_CorruptedForceSave: + case self::TRACKERSTATUS_MUSTSAVE: + case self::TRACKERSTATUS_CORRUPTED: + case self::TRACKERSTATUS_FORCESAVE: + case self::TRACKERSTATUS_CORRUPTEDFORCESAVE: if (empty($url)) { $this->logger->error("Track without url: $fileId status $status", ["app" => $this->appName]); return new JSONResponse(["message" => "Url not found"], Http::STATUS_BAD_REQUEST); @@ -604,12 +604,12 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan } break; - case self::TrackerStatus_Editing: + case self::TRACKERSTATUS_EDITING: $this->lock($file); $result = 0; break; - case self::TrackerStatus_Closed: + case self::TRACKERSTATUS_CLOSED: $this->unlock($file); $result = 0; diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 83211185..60195173 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -351,7 +351,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok if (!empty($extraPermissions)) { if (isset($format["review"]) && $format["review"]) { - $reviewPermission = ($extraPermissions["permissions"] & ExtraPermissions::Review) === ExtraPermissions::Review; + $reviewPermission = ($extraPermissions["permissions"] & ExtraPermissions::REVIEW) === ExtraPermissions::REVIEW; if ($reviewPermission) { $restrictedEditing = true; $params["document"]["permissions"]["review"] = true; @@ -359,7 +359,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok } if (isset($format["comment"]) && $format["comment"]) { - $commentPermission = ($extraPermissions["permissions"] & ExtraPermissions::Comment) === ExtraPermissions::Comment; + $commentPermission = ($extraPermissions["permissions"] & ExtraPermissions::COMMENT) === ExtraPermissions::COMMENT; if ($commentPermission) { $restrictedEditing = true; $params["document"]["permissions"]["comment"] = true; @@ -367,7 +367,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok } if (isset($format["fillForms"]) && $format["fillForms"]) { - $fillFormsPermission = ($extraPermissions["permissions"] & ExtraPermissions::FillForms) === ExtraPermissions::FillForms; + $fillFormsPermission = ($extraPermissions["permissions"] & ExtraPermissions::FILLFORMS) === ExtraPermissions::FILLFORMS; if ($fillFormsPermission) { $restrictedEditing = true; $params["document"]["permissions"]["fillForms"] = true; @@ -375,7 +375,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok } if (isset($format["modifyFilter"]) && $format["modifyFilter"]) { - $modifyFilter = ($extraPermissions["permissions"] & ExtraPermissions::ModifyFilter) === ExtraPermissions::ModifyFilter; + $modifyFilter = ($extraPermissions["permissions"] & ExtraPermissions::MODIFYFILTER) === ExtraPermissions::MODIFYFILTER; $params["document"]["permissions"]["modifyFilter"] = $modifyFilter; } } diff --git a/lib/extrapermissions.php b/lib/extrapermissions.php index 8c6bec95..3f6d9792 100644 --- a/lib/extrapermissions.php +++ b/lib/extrapermissions.php @@ -64,18 +64,18 @@ class ExtraPermissions { /** * Table name */ - private const TableName_Key = "onlyoffice_permissions"; + private const TABLENAME_KEY = "onlyoffice_permissions"; /** * Extra permission values * * @var integer */ - public const None = 0; - public const Review = 1; - public const Comment = 2; - public const FillForms = 4; - public const ModifyFilter = 8; + public const NONE = 0; + public const REVIEW = 1; + public const COMMENT = 2; + public const FILLFORMS = 4; + public const MODIFYFILTER = 8; /** * @param string $AppName - application name @@ -111,7 +111,7 @@ public function getExtra($shareId) { $shareId = $share->getId(); $extra = self::get($shareId); - $checkExtra = isset($extra["permissions"]) ? (int)$extra["permissions"] : self::None; + $checkExtra = isset($extra["permissions"]) ? (int)$extra["permissions"] : self::NONE; list($availableExtra, $defaultPermissions) = $this->validation($share, $checkExtra); if ($availableExtra === 0 @@ -168,7 +168,7 @@ public function getExtras($shares) { } } - $checkExtra = isset($currentExtra["permissions"]) ? (int)$currentExtra["permissions"] : self::None; + $checkExtra = isset($currentExtra["permissions"]) ? (int)$currentExtra["permissions"] : self::NONE; list($availableExtra, $defaultPermissions) = $this->validation($share, $checkExtra); if ($availableExtra === 0 @@ -244,7 +244,7 @@ public function setExtra($shareId, $permissions, $extraId) { public static function delete($shareId) { $connection = \OC::$server->getDatabaseConnection(); $delete = $connection->prepare(" - DELETE FROM `*PREFIX*" . self::TableName_Key . "` + DELETE FROM `*PREFIX*" . self::TABLENAME_KEY . "` WHERE `share_id` = ? "); return (bool)$delete->execute([$shareId]); @@ -268,7 +268,7 @@ public static function deleteList($shareIds) { } $delete = $connection->prepare(" - DELETE FROM `*PREFIX*" . self::TableName_Key . "` + DELETE FROM `*PREFIX*" . self::TABLENAME_KEY . "` WHERE `share_id` = ? " . $condition); return (bool)$delete->execute($shareIds); @@ -285,7 +285,7 @@ private static function get($shareId) { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT id, share_id, permissions - FROM `*PREFIX*" . self::TableName_Key . "` + FROM `*PREFIX*" . self::TABLENAME_KEY . "` WHERE `share_id` = ? "); $result = $select->execute([$shareId]); @@ -325,7 +325,7 @@ private static function getList($shareIds) { $select = $connection->prepare(" SELECT id, share_id, permissions - FROM `*PREFIX*" . self::TableName_Key . "` + FROM `*PREFIX*" . self::TABLENAME_KEY . "` WHERE `share_id` = ? " . $condition); @@ -358,7 +358,7 @@ private static function getList($shareIds) { private static function insert($shareId, $permissions) { $connection = \OC::$server->getDatabaseConnection(); $insert = $connection->prepare(" - INSERT INTO `*PREFIX*" . self::TableName_Key . "` + INSERT INTO `*PREFIX*" . self::TABLENAME_KEY . "` (`share_id`, `permissions`) VALUES (?, ?) "); @@ -376,7 +376,7 @@ private static function insert($shareId, $permissions) { private static function update($shareId, $permissions) { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" - UPDATE `*PREFIX*" . self::TableName_Key . "` + UPDATE `*PREFIX*" . self::TABLENAME_KEY . "` SET `permissions` = ? WHERE `share_id` = ? "); @@ -392,8 +392,8 @@ private static function update($shareId, $permissions) { * @return array */ private function validation($share, $checkExtra) { - $availableExtra = self::None; - $defaultExtra = self::None; + $availableExtra = self::NONE; + $defaultExtra = self::NONE; if (($share->getPermissions() & Constants::PERMISSION_SHARE) === Constants::PERMISSION_SHARE) { return [$availableExtra, $defaultExtra]; @@ -408,21 +408,21 @@ private function validation($share, $checkExtra) { if (($share->getPermissions() & Constants::PERMISSION_UPDATE) === Constants::PERMISSION_UPDATE) { if (isset($format["modifyFilter"]) && $format["modifyFilter"]) { - $availableExtra |= self::ModifyFilter; - $defaultExtra |= self::ModifyFilter; + $availableExtra |= self::MODIFYFILTER; + $defaultExtra |= self::MODIFYFILTER; } } if (($share->getPermissions() & Constants::PERMISSION_UPDATE) !== Constants::PERMISSION_UPDATE) { if (isset($format["review"]) && $format["review"]) { - $availableExtra |= self::Review; + $availableExtra |= self::REVIEW; } if (isset($format["comment"]) && $format["comment"] - && ($checkExtra & self::Review) !== self::Review) { - $availableExtra |= self::Comment; + && ($checkExtra & self::REVIEW) !== self::REVIEW) { + $availableExtra |= self::COMMENT; } if (isset($format["fillForms"]) && $format["fillForms"] - && ($checkExtra & self::Review) !== self::Review) { - $availableExtra |= self::FillForms; + && ($checkExtra & self::REVIEW) !== self::REVIEW) { + $availableExtra |= self::FILLFORMS; } } diff --git a/lib/keymanager.php b/lib/keymanager.php index 6bb148c2..ba9e1fd2 100644 --- a/lib/keymanager.php +++ b/lib/keymanager.php @@ -29,7 +29,7 @@ class KeyManager { /** * Table name */ - private const TableName_Key = "onlyoffice_filekey"; + private const TABLENAME_KEY = "onlyoffice_filekey"; /** * Get document identifier @@ -42,7 +42,7 @@ public static function get($fileId) { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT `key` - FROM `*PREFIX*" . self::TableName_Key . "` + FROM `*PREFIX*" . self::TABLENAME_KEY . "` WHERE `file_id` = ? "); $result = $select->execute([$fileId]); @@ -64,7 +64,7 @@ public static function get($fileId) { public static function set($fileId, $key) { $connection = \OC::$server->getDatabaseConnection(); $insert = $connection->prepare(" - INSERT INTO `*PREFIX*" . self::TableName_Key . "` + INSERT INTO `*PREFIX*" . self::TABLENAME_KEY . "` (`file_id`, `key`) VALUES (?, ?) "); @@ -83,7 +83,7 @@ public static function delete($fileId, $unlock = false) { $connection = \OC::$server->getDatabaseConnection(); $delete = $connection->prepare( " - DELETE FROM `*PREFIX*" . self::TableName_Key . "` + DELETE FROM `*PREFIX*" . self::TABLENAME_KEY . "` WHERE `file_id` = ? " . ($unlock === false ? "AND `lock` != 1" : "") ); @@ -101,7 +101,7 @@ public static function delete($fileId, $unlock = false) { public static function lock($fileId, $lock = true) { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" - UPDATE `*PREFIX*" . self::TableName_Key . "` + UPDATE `*PREFIX*" . self::TABLENAME_KEY . "` SET `lock` = ? WHERE `file_id` = ? "); @@ -119,7 +119,7 @@ public static function lock($fileId, $lock = true) { public static function setForcesave($fileId, $fs = true) { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" - UPDATE `*PREFIX*" . self::TableName_Key . "` + UPDATE `*PREFIX*" . self::TABLENAME_KEY . "` SET `fs` = ? WHERE `file_id` = ? "); @@ -137,7 +137,7 @@ public static function wasForcesave($fileId) { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT `fs` - FROM `*PREFIX*" . self::TableName_Key . "` + FROM `*PREFIX*" . self::TABLENAME_KEY . "` WHERE `file_id` = ? "); $result = $select->execute([$fileId]); diff --git a/lib/preview.php b/lib/preview.php index d29ac650..0b877bc6 100644 --- a/lib/preview.php +++ b/lib/preview.php @@ -146,7 +146,7 @@ class Preview extends Provider { /** * Converted thumbnail format */ - private const thumbExtension = "jpeg"; + private const THUMBEXTENSION = "jpeg"; /** * @param string $appName - application name @@ -260,9 +260,9 @@ public function getThumbnail($path, $maxX, $maxY, $scalingup, $view) { $imageUrl = null; $documentService = new DocumentService($this->trans, $this->config); try { - $imageUrl = $documentService->GetConvertedUri($fileUrl, $extension, self::thumbExtension, $key); + $imageUrl = $documentService->GetConvertedUri($fileUrl, $extension, self::THUMBEXTENSION, $key); } catch (\Exception $e) { - $this->logger->logException($e, ["message" => "GetConvertedUri: from $extension to " . self::thumbExtension, "app" => $this->appName]); + $this->logger->logException($e, ["message" => "GetConvertedUri: from $extension to " . self::THUMBEXTENSION, "app" => $this->appName]); return false; } diff --git a/lib/remoteinstance.php b/lib/remoteinstance.php index 34cc525b..55422a06 100644 --- a/lib/remoteinstance.php +++ b/lib/remoteinstance.php @@ -33,12 +33,12 @@ class RemoteInstance { /** * App name */ - private const App_Name = "onlyoffice"; + private const APP_NAME = "onlyoffice"; /** * Table name */ - private const TableName_Key = "onlyoffice_instance"; + private const TABLENAME_KEY = "onlyoffice_instance"; /** * Time to live of remote instance (12 hours) @@ -61,7 +61,7 @@ private static function get($remote) { $connection = \OC::$server->getDatabaseConnection(); $select = $connection->prepare(" SELECT remote, expire, status - FROM `*PREFIX*" . self::TableName_Key . "` + FROM `*PREFIX*" . self::TABLENAME_KEY . "` WHERE `remote` = ? "); $result = $select->execute([$remote]); @@ -82,7 +82,7 @@ private static function get($remote) { private static function set($remote, $status) { $connection = \OC::$server->getDatabaseConnection(); $insert = $connection->prepare(" - INSERT INTO `*PREFIX*" . self::TableName_Key . "` + INSERT INTO `*PREFIX*" . self::TABLENAME_KEY . "` (`remote`, `status`, `expire`) VALUES (?, ?, ?) "); @@ -100,7 +100,7 @@ private static function set($remote, $status) { private static function update($remote, $status) { $connection = \OC::$server->getDatabaseConnection(); $update = $connection->prepare(" - UPDATE `*PREFIX*" . self::TableName_Key . "` + UPDATE `*PREFIX*" . self::TABLENAME_KEY . "` SET status = ?, expire = ? WHERE remote = ? "); @@ -119,13 +119,13 @@ public static function healthCheck($remote) { $remote = rtrim($remote, "/") . "/"; if (array_key_exists($remote, self::$healthRemote)) { - $logger->debug("Remote instance " . $remote . " from local cache", ["app" => self::App_Name]); + $logger->debug("Remote instance " . $remote . " from local cache", ["app" => self::APP_NAME]); return self::$healthRemote[$remote]; } $dbremote = self::get($remote); if (!empty($dbremote) && $dbremote["expire"] + self::$ttl > time()) { - $logger->debug("Remote instance " . $remote . " from database status " . $dbremote["status"], ["app" => self::App_Name]); + $logger->debug("Remote instance " . $remote . " from database status " . $dbremote["status"], ["app" => self::APP_NAME]); self::$healthRemote[$remote] = $dbremote["status"]; return self::$healthRemote[$remote]; } @@ -135,7 +135,7 @@ public static function healthCheck($remote) { $status = false; try { - $response = $client->get($remote . "ocs/v2.php/apps/" . self::App_Name . "/api/v1/healthcheck?format=json"); + $response = $client->get($remote . "ocs/v2.php/apps/" . self::APP_NAME . "/api/v1/healthcheck?format=json"); $body = json_decode($response->getBody(), true); $data = $body["ocs"]["data"]; @@ -144,7 +144,7 @@ public static function healthCheck($remote) { $status = $data["alive"] === true; } } catch (\Exception $e) { - $logger->logException($e, ["message" => "Failed to request federated health check for" . $remote, "app" => self::App_Name]); + $logger->logException($e, ["message" => "Failed to request federated health check for" . $remote, "app" => self::APP_NAME]); } if (empty($dbremote)) { @@ -153,7 +153,7 @@ public static function healthCheck($remote) { self::update($remote, $status); } - $logger->debug("Remote instance " . $remote . " was stored to database status " . $dbremote["status"], ["app" => self::App_Name]); + $logger->debug("Remote instance " . $remote . " was stored to database status " . $dbremote["status"], ["app" => self::APP_NAME]); self::$healthRemote[$remote] = $status; @@ -178,7 +178,7 @@ public static function getRemoteKey($file) { $client = $httpClientService->newClient(); try { - $response = $client->post($remote . "ocs/v2.php/apps/" . self::App_Name . "/api/v1/key?format=json", [ + $response = $client->post($remote . "ocs/v2.php/apps/" . self::APP_NAME . "/api/v1/key?format=json", [ "timeout" => 5, "body" => [ "shareToken" => $shareToken, @@ -190,20 +190,20 @@ public static function getRemoteKey($file) { $data = $body["ocs"]["data"]; if (!empty($data["error"])) { - $logger->error("Error federated key " . $data["error"], ["app" => self::App_Name]); + $logger->error("Error federated key " . $data["error"], ["app" => self::APP_NAME]); return null; } $key = $data["key"]; - $logger->debug("Federated key: $key", ["app" => self::App_Name]); + $logger->debug("Federated key: $key", ["app" => self::APP_NAME]); return $key; } catch (\Exception $e) { - $logger->logException($e, ["message" => "Failed to request federated key " . $file->getId(), "app" => self::App_Name]); + $logger->logException($e, ["message" => "Failed to request federated key " . $file->getId(), "app" => self::APP_NAME]); if ($e->getResponse()->getStatusCode() === 404) { self::update($remote, false); - $logger->debug("Changed status for remote instance $remote to false", ["app" => self::App_Name]); + $logger->debug("Changed status for remote instance $remote to false", ["app" => self::APP_NAME]); } return null; @@ -242,22 +242,22 @@ public static function lockRemoteKey($file, $lock, $fs) { } try { - $response = $client->post($remote . "ocs/v2.php/apps/" . self::App_Name . "/api/v1/keylock?format=json", $data); + $response = $client->post($remote . "ocs/v2.php/apps/" . self::APP_NAME . "/api/v1/keylock?format=json", $data); $body = \json_decode($response->getBody(), true); $data = $body["ocs"]["data"]; if (empty($data)) { - $logger->debug("Federated request " . $action . " for " . $file->getFileInfo()->getId() . " is successful", ["app" => self::App_Name]); + $logger->debug("Federated request " . $action . " for " . $file->getFileInfo()->getId() . " is successful", ["app" => self::APP_NAME]); return true; } if (!empty($data["error"])) { - $logger->error("Error " . $action . " federated key for " . $file->getFileInfo()->getId() . ": " . $data["error"], ["app" => self::App_Name]); + $logger->error("Error " . $action . " federated key for " . $file->getFileInfo()->getId() . ": " . $data["error"], ["app" => self::APP_NAME]); return false; } } catch (\Exception $e) { - $logger->logException($e, ["message" => "Failed to request federated " . $action . " for " . $file->getFileInfo()->getId(), "app" => self::App_Name]); + $logger->logException($e, ["message" => "Failed to request federated " . $action . " for " . $file->getFileInfo()->getId(), "app" => self::APP_NAME]); return false; } } diff --git a/templates/settings.php b/templates/settings.php index 8b584a19..56213c74 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -228,7 +228,7 @@

- t("Review mode for viewing")) ?> + t("REVIEW mode for viewing")) ?>

From 5d7661f3710abb38fa5eee59fb62224a481cade0 Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 10 Oct 2023 17:10:36 +0300 Subject: [PATCH 024/209] correct camelCase --- appinfo/application.php | 8 +- controller/callbackcontroller.php | 48 +++---- controller/editorapicontroller.php | 78 +++++------ controller/editorcontroller.php | 70 +++++----- controller/federationcontroller.php | 2 +- controller/joblistcontroller.php | 2 +- controller/settingscontroller.php | 138 +++++++++---------- controller/sharingapicontroller.php | 2 +- controller/templatecontroller.php | 22 +-- lib/appconfig.php | 184 ++++++++++++------------- lib/command/documentserver.php | 4 +- lib/cron/editorscheck.php | 12 +- lib/crypt.php | 8 +- lib/directeditor.php | 8 +- lib/documentservice.php | 84 +++++------ lib/extrapermissions.php | 2 +- lib/filecreator.php | 2 +- lib/fileutility.php | 4 +- lib/listeners/directeditorlistener.php | 4 +- lib/listeners/filesharinglistener.php | 6 +- lib/listeners/fileslistener.php | 8 +- lib/listeners/viewerlistener.php | 4 +- lib/listeners/widgetlistener.php | 4 +- lib/preview.php | 22 +-- lib/settingsdata.php | 4 +- lib/templatemanager.php | 30 ++-- lib/templateprovider.php | 4 +- 27 files changed, 382 insertions(+), 382 deletions(-) diff --git a/appinfo/application.php b/appinfo/application.php index 4fbb8b60..c59d1752 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -115,7 +115,7 @@ public function register(IRegistrationContext $context): void { } // Set the leeway for the JWT library in case the system clock is a second off - \Firebase\JWT\JWT::$leeway = $this->appConfig->GetJwtLeeway(); + \Firebase\JWT\JWT::$leeway = $this->appConfig->getJwtLeeway(); $context->registerService("L10N", function (ContainerInterface $c) { return $c->get("ServerContainer")->getL10N($c->get("AppName")); @@ -289,7 +289,7 @@ function (FileCreatedFromTemplateEvent $event) { $template = $event->getTemplate(); if ($template === null) { $targetFile = $event->getTarget(); - $templateEmpty = TemplateManager::GetEmptyTemplate($targetFile->getName()); + $templateEmpty = TemplateManager::getEmptyTemplate($targetFile->getName()); if ($templateEmpty) { $targetFile->putContent($templateEmpty); } @@ -305,8 +305,8 @@ function (FileCreatedFromTemplateEvent $event) { if (class_exists("OCP\Files\Template\TemplateFileCreator")) { $context->injectFn(function (ITemplateManager $templateManager, IL10N $trans, $appName) { - if (!empty($this->appConfig->GetDocumentServerUrl()) - && $this->appConfig->SettingsAreSuccessful() + if (!empty($this->appConfig->getDocumentServerUrl()) + && $this->appConfig->settingsAreSuccessful() && $this->appConfig->isUserAllowedToUse()) { $templateManager->registerTemplateFileCreator(function () use ($appName, $trans) { $wordTemplate = new TemplateFileCreator($appName, $trans->t("New document"), ".docx"); diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index e4b91d89..8c48d69b 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -204,7 +204,7 @@ public function __construct( */ public function download($doc) { - list($hashData, $error) = $this->crypt->ReadHash($doc); + list($hashData, $error) = $this->crypt->readHash($doc); if ($hashData === null) { $this->logger->error("Download with empty or not correct hash: $error", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -220,8 +220,8 @@ public function download($doc) { $template = isset($hashData->template) ? $hashData->template : false; $this->logger->debug("Download: $fileId ($version)" . ($changes ? " changes" : ""), ["app" => $this->appName]); - if (!empty($this->config->GetDocumentServerSecret())) { - $header = \OC::$server->getRequest()->getHeader($this->config->JwtHeader()); + if (!empty($this->config->getDocumentServerSecret())) { + $header = \OC::$server->getRequest()->getHeader($this->config->jwtHeader()); if (empty($header)) { $this->logger->error("Download without jwt", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -230,7 +230,7 @@ public function download($doc) { $header = substr($header, strlen("Bearer ")); try { - $decodedHeader = \Firebase\JWT\JWT::decode($header, new \Firebase\JWT\Key($this->config->GetDocumentServerSecret(), "HS256")); + $decodedHeader = \Firebase\JWT\JWT::decode($header, new \Firebase\JWT\Key($this->config->getDocumentServerSecret(), "HS256")); } catch (\UnexpectedValueException $e) { $this->logger->logException($e, ["message" => "Download with invalid jwt", "app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -329,7 +329,7 @@ public function download($doc) { public function emptyfile($doc) { $this->logger->debug("Download empty", ["app" => $this->appName]); - list($hashData, $error) = $this->crypt->ReadHash($doc); + list($hashData, $error) = $this->crypt->readHash($doc); if ($hashData === null) { $this->logger->error("Download empty with empty or not correct hash: $error", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -339,8 +339,8 @@ public function emptyfile($doc) { return new JSONResponse(["message" => $this->trans->t("Invalid request")], Http::STATUS_BAD_REQUEST); } - if (!empty($this->config->GetDocumentServerSecret())) { - $header = \OC::$server->getRequest()->getHeader($this->config->JwtHeader()); + if (!empty($this->config->getDocumentServerSecret())) { + $header = \OC::$server->getRequest()->getHeader($this->config->jwtHeader()); if (empty($header)) { $this->logger->error("Download empty without jwt", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -349,14 +349,14 @@ public function emptyfile($doc) { $header = substr($header, strlen("Bearer ")); try { - $decodedHeader = \Firebase\JWT\JWT::decode($header, new \Firebase\JWT\Key($this->config->GetDocumentServerSecret(), "HS256")); + $decodedHeader = \Firebase\JWT\JWT::decode($header, new \Firebase\JWT\Key($this->config->getDocumentServerSecret(), "HS256")); } catch (\UnexpectedValueException $e) { $this->logger->logException($e, ["message" => "Download empty with invalid jwt", "app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); } } - $templatePath = TemplateManager::GetEmptyTemplatePath("en", ".docx"); + $templatePath = TemplateManager::getEmptyTemplatePath("en", ".docx"); $template = file_get_contents($templatePath); if (!$template) { @@ -397,7 +397,7 @@ public function emptyfile($doc) { */ public function track($doc, $users, $key, $status, $url, $token, $history, $changesurl, $forcesavetype, $actions, $filetype) { - list($hashData, $error) = $this->crypt->ReadHash($doc); + list($hashData, $error) = $this->crypt->readHash($doc); if ($hashData === null) { $this->logger->error("Track with empty or not correct hash: $error", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -410,16 +410,16 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan $fileId = $hashData->fileId; $this->logger->debug("Track: $fileId status $status", ["app" => $this->appName]); - if (!empty($this->config->GetDocumentServerSecret())) { + if (!empty($this->config->getDocumentServerSecret())) { if (!empty($token)) { try { - $payload = \Firebase\JWT\JWT::decode($token, new \Firebase\JWT\Key($this->config->GetDocumentServerSecret(), "HS256")); + $payload = \Firebase\JWT\JWT::decode($token, new \Firebase\JWT\Key($this->config->getDocumentServerSecret(), "HS256")); } catch (\UnexpectedValueException $e) { $this->logger->logException($e, ["message" => "Track with invalid jwt in body", "app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); } } else { - $header = \OC::$server->getRequest()->getHeader($this->config->JwtHeader()); + $header = \OC::$server->getRequest()->getHeader($this->config->jwtHeader()); if (empty($header)) { $this->logger->error("Track without jwt", ["app" => $this->appName]); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); @@ -428,7 +428,7 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan $header = substr($header, strlen("Bearer ")); try { - $decodedHeader = \Firebase\JWT\JWT::decode($header, new \Firebase\JWT\Key($this->config->GetDocumentServerSecret(), "HS256")); + $decodedHeader = \Firebase\JWT\JWT::decode($header, new \Firebase\JWT\Key($this->config->getDocumentServerSecret(), "HS256")); $payload = $decodedHeader->payload; } catch (\UnexpectedValueException $e) { @@ -521,7 +521,7 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan } try { - $url = $this->config->ReplaceDocumentServerUrlToInternal($url); + $url = $this->config->replaceDocumentServerUrlToInternal($url); $prevVersion = $file->getFileInfo()->getMtime(); $fileName = $file->getName(); @@ -530,18 +530,18 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan $documentService = new DocumentService($this->trans, $this->config); if ($downloadExt !== $curExt) { - $key = DocumentService::GenerateRevisionId($fileId . $url); + $key = DocumentService::generateRevisionId($fileId . $url); try { $this->logger->debug("Converted from $downloadExt to $curExt", ["app" => $this->appName]); - $url = $documentService->GetConvertedUri($url, $downloadExt, $curExt, $key); + $url = $documentService->getConvertedUri($url, $downloadExt, $curExt, $key); } catch (\Exception $e) { $this->logger->logException($e, ["message" => "Converted on save error", "app" => $this->appName]); return new JSONResponse(["message" => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR); } } - $newData = $documentService->Request($url); + $newData = $documentService->request($url); $prevIsForcesave = KeyManager::wasForcesave($fileId); @@ -585,16 +585,16 @@ public function track($doc, $users, $key, $status, $url, $token, $history, $chan if (!$isForcesave && !$prevIsForcesave && $this->versionManager !== null - && $this->config->GetVersionHistory()) { + && $this->config->getVersionHistory()) { $changes = null; if (!empty($changesurl)) { - $changesurl = $this->config->ReplaceDocumentServerUrlToInternal($changesurl); - $changes = $documentService->Request($changesurl); + $changesurl = $this->config->replaceDocumentServerUrlToInternal($changesurl); + $changes = $documentService->request($changesurl); } FileVersions::saveHistory($file->getFileInfo(), $history, $changes, $prevVersion); } - if (!empty($user) && $this->config->GetVersionHistory()) { + if (!empty($user) && $this->config->getVersionHistory()) { FileVersions::saveAuthor($file->getFileInfo(), $user); } @@ -639,7 +639,7 @@ private function getFile($userId, $fileId, $filePath = null, $version = 0, $temp } try { - $folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::GetGlobalTemplateDir(); + $folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::getGlobalTemplateDir(); $files = $folder->getById($fileId); } catch (\Exception $e) { $this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]); @@ -780,7 +780,7 @@ private function getShare($shareToken) { * @return string */ private function parseUserId($userId) { - $instanceId = $this->config->GetSystemValue("instanceid", true); + $instanceId = $this->config->getSystemValue("instanceid", true); $instanceId = $instanceId . "_"; if (substr($userId, 0, strlen($instanceId)) === $instanceId) { diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 60195173..6d341779 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -207,7 +207,7 @@ public function __construct( } } - if ($this->config->GetAdvanced() + if ($this->config->getAdvanced() && \OC::$server->getAppManager()->isInstalled("files_sharing")) { $this->extraPermissions = new ExtraPermissions($AppName, $logger, $shareManager, $config); } @@ -238,7 +238,7 @@ public function __construct( public function config($fileId, $filePath = null, $shareToken = null, $directToken = null, $version = 0, $inframe = false, $inviewer = false, $desktop = false, $guestName = null, $template = false, $anchor = null) { if (!empty($directToken)) { - list($directData, $error) = $this->crypt->ReadHash($directToken); + list($directData, $error) = $this->crypt->readHash($directToken); if ($directData === null) { $this->logger->error("Config for directEditor with empty or not correct hash: $error", ["app" => $this->appName]); return new JSONResponse(["error" => $this->trans->t("Not permitted")]); @@ -288,7 +288,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $fileName = $file->getName(); $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); - $format = !empty($ext) && array_key_exists($ext, $this->config->FormatsSetting()) ? $this->config->FormatsSetting()[$ext] : null; + $format = !empty($ext) && array_key_exists($ext, $this->config->formatsSetting()) ? $this->config->formatsSetting()[$ext] : null; if (!isset($format)) { $this->logger->info("Format is not supported for editing: $fileName", ["app" => $this->appName]); return new JSONResponse(["error" => $this->trans->t("Format is not supported")]); @@ -312,7 +312,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok if ($key === null) { $key = $this->fileUtility->getKey($file, true); } - $key = DocumentService::GenerateRevisionId($key); + $key = DocumentService::generateRevisionId($key); $params = [ "document" => [ @@ -323,7 +323,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok "url" => $fileUrl, "referenceData" => [ "fileKey" => $file->getId(), - "instanceId" => $this->config->GetSystemValue("instanceid", true), + "instanceId" => $this->config->getSystemValue("instanceid", true), ], ], "documentType" => $format["type"], @@ -333,7 +333,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok ] ]; - $permissions_modifyFilter = $this->config->GetSystemValue($this->config->_permissions_modifyFilter); + $permissions_modifyFilter = $this->config->getSystemValue($this->config->_permissions_modifyFilter); if (isset($permissions_modifyFilter)) { $params["document"]["permissions"]["modifyFilter"] = $permissions_modifyFilter; } @@ -426,7 +426,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok } $canProtect = true; - if ($this->config->GetProtection() === "owner") { + if ($this->config->getProtection() === "owner") { $canProtect = $ownerId === $userId; } $params["document"]["permissions"]["protect"] = $canProtect; @@ -436,11 +436,11 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $params["document"]["permissions"]["protect"] = false; } - $hashCallback = $this->crypt->GetHash(["userId" => $userId, "ownerId" => $ownerId, "fileId" => $file->getId(), "filePath" => $filePath, "shareToken" => $shareToken, "action" => "track"]); + $hashCallback = $this->crypt->getHash(["userId" => $userId, "ownerId" => $ownerId, "fileId" => $file->getId(), "filePath" => $filePath, "shareToken" => $shareToken, "action" => "track"]); $callback = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.track", ["doc" => $hashCallback]); - if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { - $callback = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $callback); + if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) { + $callback = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $callback); } $params["editorConfig"]["callbackUrl"] = $callback; @@ -527,7 +527,7 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $createUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".editor.create_new", $createParam); $params["editorConfig"]["createUrl"] = urldecode($createUrl); - $templatesList = TemplateManager::GetGlobalTemplates($file->getMimeType()); + $templatesList = TemplateManager::getGlobalTemplates($file->getMimeType()); if (!empty($templatesList)) { $templates = []; foreach ($templatesList as $templateItem) { @@ -551,13 +551,13 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok } if ($folderLink !== null - && $this->config->GetSystemValue($this->config->_customization_goback) !== false) { + && $this->config->getSystemValue($this->config->_customization_goback) !== false) { $params["editorConfig"]["customization"]["goback"] = [ "url" => $folderLink ]; if (!$desktop && !$inviewer) { - if ($this->config->GetSameTab()) { + if ($this->config->getSameTab()) { $params["editorConfig"]["customization"]["goback"]["blank"] = false; } @@ -581,8 +581,8 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok $params = $this->setWatermark($params, !empty($shareToken), $userId, $file); - if ($this->config->UseDemo()) { - $params["editorConfig"]["tenant"] = $this->config->GetSystemValue("instanceid", true); + if ($this->config->useDemo()) { + $params["editorConfig"]["tenant"] = $this->config->getSystemValue("instanceid", true); } if ($anchor !== null) { @@ -595,8 +595,8 @@ public function config($fileId, $filePath = null, $shareToken = null, $directTok } } - if (!empty($this->config->GetDocumentServerSecret())) { - $token = \Firebase\JWT\JWT::encode($params, $this->config->GetDocumentServerSecret(), "HS256"); + if (!empty($this->config->getDocumentServerSecret())) { + $token = \Firebase\JWT\JWT::encode($params, $this->config->getDocumentServerSecret(), "HS256"); $params["token"] = $token; } @@ -621,7 +621,7 @@ private function getFile($userId, $fileId, $filePath = null, $template = false) } try { - $folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::GetGlobalTemplateDir(); + $folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::getGlobalTemplateDir(); $files = $folder->getById($fileId); } catch (\Exception $e) { $this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]); @@ -689,12 +689,12 @@ private function getUrl($file, $user = null, $shareToken = null, $version = 0, $ $data["template"] = true; } - $hashUrl = $this->crypt->GetHash($data); + $hashUrl = $this->crypt->getHash($data); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]); - if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { - $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); + if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) { + $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $fileUrl); } return $fileUrl; @@ -708,7 +708,7 @@ private function getUrl($file, $user = null, $shareToken = null, $version = 0, $ * @return string */ private function buildUserId($userId) { - $instanceId = $this->config->GetSystemValue("instanceid", true); + $instanceId = $this->config->getSystemValue("instanceid", true); $userId = $instanceId . "_" . $userId; return $userId; } @@ -722,84 +722,84 @@ private function buildUserId($userId) { */ private function setCustomization($params) { //default is true - if ($this->config->GetCustomizationChat() === false) { + if ($this->config->getCustomizationChat() === false) { $params["editorConfig"]["customization"]["chat"] = false; } //default is false - if ($this->config->GetCustomizationCompactHeader() === true) { + if ($this->config->getCustomizationCompactHeader() === true) { $params["editorConfig"]["customization"]["compactHeader"] = true; } //default is false - if ($this->config->GetCustomizationFeedback() === true) { + if ($this->config->getCustomizationFeedback() === true) { $params["editorConfig"]["customization"]["feedback"] = true; } //default is false - if ($this->config->GetCustomizationForcesave() === true) { + if ($this->config->getCustomizationForcesave() === true) { $params["editorConfig"]["customization"]["forcesave"] = true; } //default is true - if ($this->config->GetCustomizationHelp() === false) { + if ($this->config->getCustomizationHelp() === false) { $params["editorConfig"]["customization"]["help"] = false; } //default is original - $reviewDisplay = $this->config->GetCustomizationReviewDisplay(); + $reviewDisplay = $this->config->getCustomizationReviewDisplay(); if ($reviewDisplay !== "original") { $params["editorConfig"]["customization"]["reviewDisplay"] = $reviewDisplay; } - $theme = $this->config->GetCustomizationTheme(); + $theme = $this->config->getCustomizationTheme(); if (isset($theme)) { $params["editorConfig"]["customization"]["uiTheme"] = $theme; } //default is false - if ($this->config->GetCustomizationToolbarNoTabs() === true) { + if ($this->config->getCustomizationToolbarNoTabs() === true) { $params["editorConfig"]["customization"]["toolbarNoTabs"] = true; } //default is true - if ($this->config->GetCustomizationMacros() === false) { + if ($this->config->getCustomizationMacros() === false) { $params["editorConfig"]["customization"]["macros"] = false; } //default is true - if ($this->config->GetCustomizationPlugins() === false) { + if ($this->config->getCustomizationPlugins() === false) { $params["editorConfig"]["customization"]["plugins"] = false; } /* from system config */ - $autosave = $this->config->GetSystemValue($this->config->_customization_autosave); + $autosave = $this->config->getSystemValue($this->config->_customization_autosave); if (isset($autosave)) { $params["editorConfig"]["customization"]["autosave"] = $autosave; } - $customer = $this->config->GetSystemValue($this->config->_customization_customer); + $customer = $this->config->getSystemValue($this->config->_customization_customer); if (isset($customer)) { $params["editorConfig"]["customization"]["customer"] = $customer; } - $loaderLogo = $this->config->GetSystemValue($this->config->_customization_loaderLogo); + $loaderLogo = $this->config->getSystemValue($this->config->_customization_loaderLogo); if (isset($loaderLogo)) { $params["editorConfig"]["customization"]["loaderLogo"] = $loaderLogo; } - $loaderName = $this->config->GetSystemValue($this->config->_customization_loaderName); + $loaderName = $this->config->getSystemValue($this->config->_customization_loaderName); if (isset($loaderName)) { $params["editorConfig"]["customization"]["loaderName"] = $loaderName; } - $logo = $this->config->GetSystemValue($this->config->_customization_logo); + $logo = $this->config->getSystemValue($this->config->_customization_logo); if (isset($logo)) { $params["editorConfig"]["customization"]["logo"] = $logo; } - $zoom = $this->config->GetSystemValue($this->config->_customization_zoom); + $zoom = $this->config->getSystemValue($this->config->_customization_zoom); if (isset($zoom)) { $params["editorConfig"]["customization"]["zoom"] = $zoom; } @@ -869,7 +869,7 @@ private function setWatermark($params, $isPublic, $userId, $file) { * @return bool|string */ private function getWatermarkText($isPublic, $userId, $file, $canEdit, $canDownload) { - $watermarkSettings = $this->config->GetWatermarkSettings(); + $watermarkSettings = $this->config->getWatermarkSettings(); if (!$watermarkSettings["enabled"]) { return false; } diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 9219bd3c..69ce397b 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -256,7 +256,7 @@ public function create($name, $dir, $templateId = null, $targetId = 0, $shareTok } if (!empty($templateId)) { - $templateFile = TemplateManager::GetTemplate($templateId); + $templateFile = TemplateManager::getTemplate($templateId); if ($templateFile !== null) { $template = $templateFile->getContent(); } @@ -272,14 +272,14 @@ public function create($name, $dir, $templateId = null, $targetId = 0, $shareTok $region = str_replace("_", "-", \OC::$server->getL10NFactory()->get("")->getLocaleCode()); $documentService = new DocumentService($this->trans, $this->config); try { - $newFileUri = $documentService->GetConvertedUri($fileUrl, $targetExt, $ext, $targetKey, $region); + $newFileUri = $documentService->getConvertedUri($fileUrl, $targetExt, $ext, $targetKey, $region); } catch (\Exception $e) { - $this->logger->logException($e, ["message" => "GetConvertedUri: " . $targetFile->getId(), "app" => $this->appName]); + $this->logger->logException($e, ["message" => "getConvertedUri: " . $targetFile->getId(), "app" => $this->appName]); return ["error" => $e->getMessage()]; } - $template = $documentService->Request($newFileUri); + $template = $documentService->request($newFileUri); } else { - $template = TemplateManager::GetEmptyTemplate($name); + $template = TemplateManager::getEmptyTemplate($name); } if (!$template) { @@ -582,7 +582,7 @@ public function reference($referenceData, $path = null) { $file = null; $fileId = (integer)($referenceData["fileKey"] ?? 0); if (!empty($fileId) - && $referenceData["instanceId"] === $this->config->GetSystemValue("instanceid", true)) { + && $referenceData["instanceId"] === $this->config->getSystemValue("instanceid", true)) { list($file, $error, $share) = $this->getFile($userId, $fileId); } @@ -610,13 +610,13 @@ public function reference($referenceData, $path = null) { "path" => $userFolder->getRelativePath($file->getPath()), "referenceData" => [ "fileKey" => $file->getId(), - "instanceId" => $this->config->GetSystemValue("instanceid", true), + "instanceId" => $this->config->getSystemValue("instanceid", true), ], "url" => $this->getUrl($file, $user), ]; - if (!empty($this->config->GetDocumentServerSecret())) { - $token = \Firebase\JWT\JWT::encode($response, $this->config->GetDocumentServerSecret(), "HS256"); + if (!empty($this->config->getDocumentServerSecret())) { + $token = \Firebase\JWT\JWT::encode($response, $this->config->getDocumentServerSecret(), "HS256"); $response["token"] = $token; } @@ -661,7 +661,7 @@ public function convert($fileId, $shareToken = null) { $fileName = $file->getName(); $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); - $format = $this->config->FormatsSetting()[$ext]; + $format = $this->config->formatsSetting()[$ext]; if (!isset($format)) { $this->logger->info("Format for convertion not supported: $fileName", ["app" => $this->appName]); return ["error" => $this->trans->t("Format is not supported")]; @@ -688,9 +688,9 @@ public function convert($fileId, $shareToken = null) { $fileUrl = $this->getUrl($file, $user, $shareToken); $region = str_replace("_", "-", \OC::$server->getL10NFactory()->get("")->getLocaleCode()); try { - $newFileUri = $documentService->GetConvertedUri($fileUrl, $ext, $internalExtension, $key, $region); + $newFileUri = $documentService->getConvertedUri($fileUrl, $ext, $internalExtension, $key, $region); } catch (\Exception $e) { - $this->logger->logException($e, ["message" => "GetConvertedUri: " . $file->getId(), "app" => $this->appName]); + $this->logger->logException($e, ["message" => "getConvertedUri: " . $file->getId(), "app" => $this->appName]); return ["error" => $e->getMessage()]; } @@ -700,7 +700,7 @@ public function convert($fileId, $shareToken = null) { } try { - $newData = $documentService->Request($newFileUri); + $newData = $documentService->request($newFileUri); } catch (\Exception $e) { $this->logger->logException($e, ["message" => "Failed to download converted file", "app" => $this->appName]); return ["error" => $this->trans->t("Failed to download converted file")]; @@ -756,11 +756,11 @@ public function save($name, $dir, $url) { return ["error" => $this->trans->t("You don't have enough permission to create")]; } - $url = $this->config->ReplaceDocumentServerUrlToInternal($url); + $url = $this->config->replaceDocumentServerUrlToInternal($url); try { $documentService = new DocumentService($this->trans, $this->config); - $newData = $documentService->Request($url); + $newData = $documentService->request($url); } catch (\Exception $e) { $this->logger->logException($e, ["message" => "Failed to download file for saving: $url", "app" => $this->appName]); return ["error" => $this->trans->t("Download failed")]; @@ -836,7 +836,7 @@ public function history($fileId) { $versionNum = $versionNum + 1; $key = $this->fileUtility->getVersionKey($version); - $key = DocumentService::GenerateRevisionId($key); + $key = DocumentService::generateRevisionId($key); $historyItem = [ "created" => $version->getTimestamp(), @@ -867,7 +867,7 @@ public function history($fileId) { } $key = $this->fileUtility->getKey($file, true); - $key = DocumentService::GenerateRevisionId($key); + $key = DocumentService::generateRevisionId($key); $historyItem = [ "created" => $file->getMTime(), @@ -963,7 +963,7 @@ public function version($fileId, $version) { $fileUrl = $this->getUrl($file, $user, null, $version); } - $key = DocumentService::GenerateRevisionId($key); + $key = DocumentService::generateRevisionId($key); $fileName = $file->getName(); $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); @@ -982,7 +982,7 @@ public function version($fileId, $version) { $prevVersion = array_values($versions)[$version - 2]; $prevVersionKey = $this->fileUtility->getVersionKey($prevVersion); - $prevVersionKey = DocumentService::GenerateRevisionId($prevVersionKey); + $prevVersionKey = DocumentService::generateRevisionId($prevVersionKey); $prevVersionUrl = $this->getUrl($file, $user, null, $version - 1); @@ -993,8 +993,8 @@ public function version($fileId, $version) { ]; } - if (!empty($this->config->GetDocumentServerSecret())) { - $token = \Firebase\JWT\JWT::encode($result, $this->config->GetDocumentServerSecret(), "HS256"); + if (!empty($this->config->getDocumentServerSecret())) { + $token = \Firebase\JWT\JWT::encode($result, $this->config->getDocumentServerSecret(), "HS256"); $result["token"] = $token; } @@ -1094,8 +1094,8 @@ public function url($filePath) { "url" => $fileUrl ]; - if (!empty($this->config->GetDocumentServerSecret())) { - $token = \Firebase\JWT\JWT::encode($result, $this->config->GetDocumentServerSecret(), "HS256"); + if (!empty($this->config->getDocumentServerSecret())) { + $token = \Firebase\JWT\JWT::encode($result, $this->config->getDocumentServerSecret(), "HS256"); $result["token"] = $token; } @@ -1122,7 +1122,7 @@ public function download($fileId, $toExtension = null, $template = false) { } if ($template) { - $templateFile = TemplateManager::GetTemplate($fileId); + $templateFile = TemplateManager::getTemplate($fileId); if (empty($templateFile)) { $this->logger->info("Download: template not found: $fileId", ["app" => $this->appName]); return $this->renderError($this->trans->t("File not found")); @@ -1171,14 +1171,14 @@ public function download($fileId, $toExtension = null, $template = false) { $key = $this->fileUtility->getKey($file); $fileUrl = $this->getUrl($file, $user); try { - $newFileUri = $documentService->GetConvertedUri($fileUrl, $ext, $toExtension, $key); + $newFileUri = $documentService->getConvertedUri($fileUrl, $ext, $toExtension, $key); } catch (\Exception $e) { - $this->logger->logException($e, ["message" => "GetConvertedUri: " . $file->getId(), "app" => $this->appName]); + $this->logger->logException($e, ["message" => "getConvertedUri: " . $file->getId(), "app" => $this->appName]); return $this->renderError($e->getMessage()); } try { - $newData = $documentService->Request($newFileUri); + $newData = $documentService->request($newFileUri); } catch (\Exception $e) { $this->logger->logException($e, ["message" => "Failed to download converted file", "app" => $this->appName]); return $this->renderError($this->trans->t("Failed to download converted file")); @@ -1187,7 +1187,7 @@ public function download($fileId, $toExtension = null, $template = false) { $fileNameWithoutExt = substr($fileName, 0, strlen($fileName) - strlen($ext) - 1); $newFileName = $fileNameWithoutExt . "." . $toExtension; - $formats = $this->config->FormatsSetting(); + $formats = $this->config->formatsSetting(); return new DataDownloadResponse($newData, $newFileName, $formats[$toExtension]["mime"]); } @@ -1232,7 +1232,7 @@ public function index($fileId, $filePath = null, $shareToken = null, $version = return $this->renderError($this->trans->t("Not permitted")); } - $documentServerUrl = $this->config->GetDocumentServerUrl(); + $documentServerUrl = $this->config->getDocumentServerUrl(); if (empty($documentServerUrl)) { $this->logger->error("documentServerUrl is empty", ["app" => $this->appName]); @@ -1299,7 +1299,7 @@ public function index($fileId, $filePath = null, $shareToken = null, $version = * @NoCSRFRequired * @PublicPage */ - public function PublicPage($fileId, $shareToken, $version = 0, $inframe = false) { + public function publicPage($fileId, $shareToken, $version = 0, $inframe = false) { return $this->index($fileId, null, $shareToken, $version, $inframe); } @@ -1319,7 +1319,7 @@ private function getFile($userId, $fileId, $filePath = null, $template = false) } try { - $folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::GetGlobalTemplateDir(); + $folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::getGlobalTemplateDir(); $files = $folder->getById($fileId); } catch (\Exception $e) { $this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]); @@ -1387,12 +1387,12 @@ private function getUrl($file, $user = null, $shareToken = null, $version = 0, $ $data["template"] = true; } - $hashUrl = $this->crypt->GetHash($data); + $hashUrl = $this->crypt->getHash($data); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]); - if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { - $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); + if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) { + $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $fileUrl); } return $fileUrl; @@ -1421,7 +1421,7 @@ private function getShareExcludedGroups() { * @return string */ private function buildUserId($userId) { - $instanceId = $this->config->GetSystemValue("instanceid", true); + $instanceId = $this->config->getSystemValue("instanceid", true); $userId = $instanceId . "_" . $userId; return $userId; } diff --git a/controller/federationcontroller.php b/controller/federationcontroller.php index c06af242..55e32b8c 100644 --- a/controller/federationcontroller.php +++ b/controller/federationcontroller.php @@ -105,7 +105,7 @@ public function key($shareToken, $path) { $key = $this->fileUtility->getKey($file, true); - $key = DocumentService::GenerateRevisionId($key); + $key = DocumentService::generateRevisionId($key); $this->logger->debug("Federated request get for " . $file->getId() . " key $key", ["app" => $this->appName]); diff --git a/controller/joblistcontroller.php b/controller/joblistcontroller.php index ee5f4752..8d536034 100644 --- a/controller/joblistcontroller.php +++ b/controller/joblistcontroller.php @@ -91,7 +91,7 @@ private function removeJob($job) { * */ private function checkEditorsCheckJob() { - if ($this->config->GetEditorsCheckInterval() > 0) { + if ($this->config->getEditorsCheckInterval() > 0) { $this->addJob(EditorsCheck::class); } else { $this->removeJob(EditorsCheck::class); diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 0e181196..5895d0e8 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -106,36 +106,36 @@ public function __construct( */ public function index() { $data = [ - "documentserver" => $this->config->GetDocumentServerUrl(true), - "documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true), - "storageUrl" => $this->config->GetStorageUrl(), - "verifyPeerOff" => $this->config->GetVerifyPeerOff(), - "secret" => $this->config->GetDocumentServerSecret(true), - "jwtHeader" => $this->config->JwtHeader(true), - "demo" => $this->config->GetDemoData(), + "documentserver" => $this->config->getDocumentServerUrl(true), + "documentserverInternal" => $this->config->getDocumentServerInternalUrl(true), + "storageUrl" => $this->config->getStorageUrl(), + "verifyPeerOff" => $this->config->getVerifyPeerOff(), + "secret" => $this->config->getDocumentServerSecret(true), + "jwtHeader" => $this->config->jwtHeader(true), + "demo" => $this->config->getDemoData(), "currentServer" => $this->urlGenerator->getAbsoluteURL("/"), - "formats" => $this->config->FormatsSetting(), - "sameTab" => $this->config->GetSameTab(), - "preview" => $this->config->GetPreview(), - "advanced" => $this->config->GetAdvanced(), - "versionHistory" => $this->config->GetVersionHistory(), - "protection" => $this->config->GetProtection(), - "limitGroups" => $this->config->GetLimitGroups(), - "chat" => $this->config->GetCustomizationChat(), - "compactHeader" => $this->config->GetCustomizationCompactHeader(), - "feedback" => $this->config->GetCustomizationFeedback(), - "forcesave" => $this->config->GetCustomizationForcesave(), - "help" => $this->config->GetCustomizationHelp(), - "toolbarNoTabs" => $this->config->GetCustomizationToolbarNoTabs(), - "successful" => $this->config->SettingsAreSuccessful(), - "watermark" => $this->config->GetWatermarkSettings(), - "plugins" => $this->config->GetCustomizationPlugins(), - "macros" => $this->config->GetCustomizationMacros(), + "formats" => $this->config->formatsSetting(), + "sameTab" => $this->config->getSameTab(), + "preview" => $this->config->getPreview(), + "advanced" => $this->config->getAdvanced(), + "versionHistory" => $this->config->getVersionHistory(), + "protection" => $this->config->getProtection(), + "limitGroups" => $this->config->getLimitGroups(), + "chat" => $this->config->getCustomizationChat(), + "compactHeader" => $this->config->getCustomizationCompactHeader(), + "feedback" => $this->config->getCustomizationFeedback(), + "forcesave" => $this->config->getCustomizationForcesave(), + "help" => $this->config->getCustomizationHelp(), + "toolbarNoTabs" => $this->config->getCustomizationToolbarNoTabs(), + "successful" => $this->config->settingsAreSuccessful(), + "watermark" => $this->config->getWatermarkSettings(), + "plugins" => $this->config->getCustomizationPlugins(), + "macros" => $this->config->getCustomizationMacros(), "tagsEnabled" => \OC::$server->getAppManager()->isEnabledForUser("systemtags"), - "reviewDisplay" => $this->config->GetCustomizationReviewDisplay(), - "theme" => $this->config->GetCustomizationTheme(), - "templates" => $this->GetGlobalTemplates(), - "linkToDocs" => $this->config->GetLinkToDocs() + "reviewDisplay" => $this->config->getCustomizationReviewDisplay(), + "theme" => $this->config->getCustomizationTheme(), + "templates" => $this->getGlobalTemplates(), + "linkToDocs" => $this->config->getLinkToDocs() ]; return new TemplateResponse($this->appName, "settings", $data, "blank"); } @@ -153,7 +153,7 @@ public function index() { * * @return array */ - public function SaveAddress( + public function saveAddress( $documentserver, $documentserverInternal, $storageUrl, @@ -163,35 +163,35 @@ public function SaveAddress( $demo ) { $error = null; - if (!$this->config->SelectDemo($demo === true)) { + if (!$this->config->selectDemo($demo === true)) { $error = $this->trans->t("The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server."); } if ($demo !== true) { - $this->config->SetDocumentServerUrl($documentserver); - $this->config->SetVerifyPeerOff($verifyPeerOff); - $this->config->SetDocumentServerInternalUrl($documentserverInternal); - $this->config->SetDocumentServerSecret($secret); - $this->config->SetJwtHeader($jwtHeader); + $this->config->setDocumentServerUrl($documentserver); + $this->config->setVerifyPeerOff($verifyPeerOff); + $this->config->setDocumentServerInternalUrl($documentserverInternal); + $this->config->setDocumentServerSecret($secret); + $this->config->setJwtHeader($jwtHeader); } - $this->config->SetStorageUrl($storageUrl); + $this->config->setStorageUrl($storageUrl); $version = null; if (empty($error)) { - $documentserver = $this->config->GetDocumentServerUrl(); + $documentserver = $this->config->getDocumentServerUrl(); if (!empty($documentserver)) { $documentService = new DocumentService($this->trans, $this->config); list($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); - $this->config->SetSettingsError($error); + $this->config->setSettingsError($error); } } return [ - "documentserver" => $this->config->GetDocumentServerUrl(true), - "verifyPeerOff" => $this->config->GetVerifyPeerOff(), - "documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true), - "storageUrl" => $this->config->GetStorageUrl(), - "secret" => $this->config->GetDocumentServerSecret(true), - "jwtHeader" => $this->config->JwtHeader(true), + "documentserver" => $this->config->getDocumentServerUrl(true), + "verifyPeerOff" => $this->config->getVerifyPeerOff(), + "documentserverInternal" => $this->config->getDocumentServerInternalUrl(true), + "storageUrl" => $this->config->getStorageUrl(), + "secret" => $this->config->getDocumentServerSecret(true), + "jwtHeader" => $this->config->jwtHeader(true), "error" => $error, "version" => $version, ]; @@ -217,7 +217,7 @@ public function SaveAddress( * * @return array */ - public function SaveCommon( + public function saveCommon( $defFormats, $editFormats, $sameTab, @@ -235,21 +235,21 @@ public function SaveCommon( $theme ) { - $this->config->SetDefaultFormats($defFormats); - $this->config->SetEditableFormats($editFormats); - $this->config->SetSameTab($sameTab); - $this->config->SetPreview($preview); - $this->config->SetAdvanced($advanced); - $this->config->SetVersionHistory($versionHistory); - $this->config->SetLimitGroups($limitGroups); - $this->config->SetCustomizationChat($chat); - $this->config->SetCustomizationCompactHeader($compactHeader); - $this->config->SetCustomizationFeedback($feedback); - $this->config->SetCustomizationForcesave($forcesave); - $this->config->SetCustomizationHelp($help); - $this->config->SetCustomizationToolbarNoTabs($toolbarNoTabs); - $this->config->SetCustomizationReviewDisplay($reviewDisplay); - $this->config->SetCustomizationTheme($theme); + $this->config->setDefaultFormats($defFormats); + $this->config->setEditableFormats($editFormats); + $this->config->setSameTab($sameTab); + $this->config->setPreview($preview); + $this->config->setAdvanced($advanced); + $this->config->setVersionHistory($versionHistory); + $this->config->setLimitGroups($limitGroups); + $this->config->setCustomizationChat($chat); + $this->config->setCustomizationCompactHeader($compactHeader); + $this->config->setCustomizationFeedback($feedback); + $this->config->setCustomizationForcesave($forcesave); + $this->config->setCustomizationHelp($help); + $this->config->setCustomizationToolbarNoTabs($toolbarNoTabs); + $this->config->setCustomizationReviewDisplay($reviewDisplay); + $this->config->setCustomizationTheme($theme); return [ ]; @@ -265,7 +265,7 @@ public function SaveCommon( * * @return array */ - public function SaveSecurity( + public function saveSecurity( $watermarks, $plugins, $macros, @@ -279,10 +279,10 @@ public function SaveSecurity( } } - $this->config->SetWatermarkSettings($watermarks); - $this->config->SetCustomizationPlugins($plugins); - $this->config->SetCustomizationMacros($macros); - $this->config->SetProtection($protection); + $this->config->setWatermarkSettings($watermarks); + $this->config->setCustomizationPlugins($plugins); + $this->config->setCustomizationMacros($macros); + $this->config->setProtection($protection); return [ ]; @@ -293,7 +293,7 @@ public function SaveSecurity( * * @return array */ - public function ClearHistory() { + public function clearHistory() { FileVersions::clearHistory(); @@ -306,15 +306,15 @@ public function ClearHistory() { * * @return array */ - private function GetGlobalTemplates() { + private function getGlobalTemplates() { $templates = []; - $templatesList = TemplateManager::GetGlobalTemplates(); + $templatesList = TemplateManager::getGlobalTemplates(); foreach ($templatesList as $templatesItem) { $template = [ "id" => $templatesItem->getId(), "name" => $templatesItem->getName(), - "type" => TemplateManager::GetTypeTemplate($templatesItem->getMimeType()) + "type" => TemplateManager::getTypeTemplate($templatesItem->getMimeType()) ]; array_push($templates, $template); } diff --git a/controller/sharingapicontroller.php b/controller/sharingapicontroller.php index e4693a46..65b9f6e1 100644 --- a/controller/sharingapicontroller.php +++ b/controller/sharingapicontroller.php @@ -118,7 +118,7 @@ public function __construct( $this->shareManager = $shareManager; $this->appConfig = $appConfig; - if ($this->appConfig->GetAdvanced() + if ($this->appConfig->getAdvanced() && \OC::$server->getAppManager()->isInstalled("files_sharing")) { $this->extraPermissions = new ExtraPermissions($AppName, $logger, $shareManager, $appConfig); } diff --git a/controller/templatecontroller.php b/controller/templatecontroller.php index d4e94f73..215074f9 100644 --- a/controller/templatecontroller.php +++ b/controller/templatecontroller.php @@ -83,15 +83,15 @@ public function __construct( * * @NoAdminRequired */ - public function GetTemplates() { - $templatesList = TemplateManager::GetGlobalTemplates(); + public function getTemplates() { + $templatesList = TemplateManager::getGlobalTemplates(); $templates = []; foreach ($templatesList as $templatesItem) { $template = [ "id" => $templatesItem->getId(), "name" => $templatesItem->getName(), - "type" => TemplateManager::GetTypeTemplate($templatesItem->getMimeType()) + "type" => TemplateManager::getTypeTemplate($templatesItem->getMimeType()) ]; array_push($templates, $template); } @@ -104,19 +104,19 @@ public function GetTemplates() { * * @return array */ - public function AddTemplate() { + public function addTemplate() { $file = $this->request->getUploadedFile("file"); if (!is_null($file)) { if (is_uploaded_file($file["tmp_name"]) && $file["error"] === 0) { - if (!TemplateManager::IsTemplateType($file["name"])) { + if (!TemplateManager::isTemplateType($file["name"])) { return [ "error" => $this->trans->t("Template must be in OOXML format") ]; } - $templateDir = TemplateManager::GetGlobalTemplateDir(); + $templateDir = TemplateManager::getGlobalTemplateDir(); if ($templateDir->nodeExists($file["name"])) { return [ "error" => $this->trans->t("Template already exists") @@ -132,7 +132,7 @@ public function AddTemplate() { $result = [ "id" => $fileInfo->getId(), "name" => $fileInfo->getName(), - "type" => TemplateManager::GetTypeTemplate($fileInfo->getMimeType()) + "type" => TemplateManager::getTypeTemplate($fileInfo->getMimeType()) ]; return $result; @@ -151,13 +151,13 @@ public function AddTemplate() { * * @return array */ - public function DeleteTemplate($templateId) { - $templateDir = TemplateManager::GetGlobalTemplateDir(); + public function deleteTemplate($templateId) { + $templateDir = TemplateManager::getGlobalTemplateDir(); try { $templates = $templateDir->getById($templateId); } catch (\Exception $e) { - $this->logger->logException($e, ["message" => "DeleteTemplate: $templateId", "app" => $this->AppName]); + $this->logger->logException($e, ["message" => "deleteTemplate: $templateId", "app" => $this->AppName]); return [ "error" => $this->trans->t("Failed to delete template") ]; @@ -195,7 +195,7 @@ public function preview($fileId, $x = 256, $y = 256, $crop = false, $mode = IPre return new DataResponse([], Http::STATUS_BAD_REQUEST); } - $template = TemplateManager::GetTemplate($fileId); + $template = TemplateManager::getTemplate($fileId); if (empty($template)) { $this->logger->error("Template not found: $fileId", ["app" => $this->appName]); return new DataResponse([], Http::STATUS_NOT_FOUND); diff --git a/lib/appconfig.php b/lib/appconfig.php index 01707fcb..3d568d3d 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -345,7 +345,7 @@ public function __construct($AppName) { * * @return string */ - public function GetSystemValue($key, $system = false) { + public function getSystemValue($key, $system = false) { if ($system) { return $this->config->getSystemValue($key); } @@ -363,10 +363,10 @@ public function GetSystemValue($key, $system = false) { * * @return bool */ - public function SelectDemo($value) { + public function selectDemo($value) { $this->logger->info("Select demo: " . json_encode($value), ["app" => $this->appName]); - $data = $this->GetDemoData(); + $data = $this->getDemoData(); if ($value === true && !$data["available"]) { $this->logger->info("Trial demo is overdue: " . json_encode($data), ["app" => $this->appName]); @@ -387,7 +387,7 @@ public function SelectDemo($value) { * * @return array */ - public function GetDemoData() { + public function getDemoData() { $data = $this->config->getAppValue($this->appName, $this->_demo, ""); if (empty($data)) { @@ -416,8 +416,8 @@ public function GetDemoData() { * * @return bool */ - public function UseDemo() { - return $this->GetDemoData()["enabled"] === true; + public function useDemo() { + return $this->getDemoData()["enabled"] === true; } /** @@ -425,7 +425,7 @@ public function UseDemo() { * * @param string $documentServer - document service address */ - public function SetDocumentServerUrl($documentServer) { + public function setDocumentServerUrl($documentServer) { $documentServer = trim($documentServer); if (strlen($documentServer) > 0) { $documentServer = rtrim($documentServer, "/") . "/"; @@ -434,7 +434,7 @@ public function SetDocumentServerUrl($documentServer) { } } - $this->logger->info("SetDocumentServerUrl: $documentServer", ["app" => $this->appName]); + $this->logger->info("setDocumentServerUrl: $documentServer", ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_documentserver, $documentServer); } @@ -446,14 +446,14 @@ public function SetDocumentServerUrl($documentServer) { * * @return string */ - public function GetDocumentServerUrl($origin = false) { - if (!$origin && $this->UseDemo()) { + public function getDocumentServerUrl($origin = false) { + if (!$origin && $this->useDemo()) { return $this->DEMO_PARAM["ADDR"]; } $url = $this->config->getAppValue($this->appName, $this->_documentserver, ""); if (empty($url)) { - $url = $this->GetSystemValue($this->_documentserver); + $url = $this->getSystemValue($this->_documentserver); } if ($url !== null && $url !== "/") { $url = rtrim($url, "/"); @@ -469,7 +469,7 @@ public function GetDocumentServerUrl($origin = false) { * * @param string $documentServerInternal - document service address */ - public function SetDocumentServerInternalUrl($documentServerInternal) { + public function setDocumentServerInternalUrl($documentServerInternal) { $documentServerInternal = rtrim(trim($documentServerInternal), "/"); if (strlen($documentServerInternal) > 0) { $documentServerInternal = $documentServerInternal . "/"; @@ -478,7 +478,7 @@ public function SetDocumentServerInternalUrl($documentServerInternal) { } } - $this->logger->info("SetDocumentServerInternalUrl: $documentServerInternal", ["app" => $this->appName]); + $this->logger->info("setDocumentServerInternalUrl: $documentServerInternal", ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_documentserverInternal, $documentServerInternal); } @@ -490,17 +490,17 @@ public function SetDocumentServerInternalUrl($documentServerInternal) { * * @return string */ - public function GetDocumentServerInternalUrl($origin = false) { - if (!$origin && $this->UseDemo()) { - return $this->GetDocumentServerUrl(); + public function getDocumentServerInternalUrl($origin = false) { + if (!$origin && $this->useDemo()) { + return $this->getDocumentServerUrl(); } $url = $this->config->getAppValue($this->appName, $this->_documentserverInternal, ""); if (empty($url)) { - $url = $this->GetSystemValue($this->_documentserverInternal); + $url = $this->getSystemValue($this->_documentserverInternal); } if (!$origin && empty($url)) { - $url = $this->GetDocumentServerUrl(); + $url = $this->getDocumentServerUrl(); } return $url; } @@ -512,10 +512,10 @@ public function GetDocumentServerInternalUrl($origin = false) { * * @return string */ - public function ReplaceDocumentServerUrlToInternal($url) { - $documentServerUrl = $this->GetDocumentServerInternalUrl(); + public function replaceDocumentServerUrlToInternal($url) { + $documentServerUrl = $this->getDocumentServerInternalUrl(); if (!empty($documentServerUrl)) { - $from = $this->GetDocumentServerUrl(); + $from = $this->getDocumentServerUrl(); if (!preg_match("/^https?:\/\//i", $from)) { $parsedUrl = parse_url($url); @@ -536,7 +536,7 @@ public function ReplaceDocumentServerUrlToInternal($url) { * * @param string $documentServer - document service address */ - public function SetStorageUrl($storageUrl) { + public function setStorageUrl($storageUrl) { $storageUrl = rtrim(trim($storageUrl), "/"); if (strlen($storageUrl) > 0) { $storageUrl = $storageUrl . "/"; @@ -545,7 +545,7 @@ public function SetStorageUrl($storageUrl) { } } - $this->logger->info("SetStorageUrl: $storageUrl", ["app" => $this->appName]); + $this->logger->info("setStorageUrl: $storageUrl", ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_storageUrl, $storageUrl); } @@ -555,10 +555,10 @@ public function SetStorageUrl($storageUrl) { * * @return string */ - public function GetStorageUrl() { + public function getStorageUrl() { $url = $this->config->getAppValue($this->appName, $this->_storageUrl, ""); if (empty($url)) { - $url = $this->GetSystemValue($this->_storageUrl); + $url = $this->getSystemValue($this->_storageUrl); } return $url; } @@ -568,7 +568,7 @@ public function GetStorageUrl() { * * @param string $secret - secret key */ - public function SetDocumentServerSecret($secret) { + public function setDocumentServerSecret($secret) { $secret = trim($secret); if (empty($secret)) { $this->logger->info("Clear secret key", ["app" => $this->appName]); @@ -586,14 +586,14 @@ public function SetDocumentServerSecret($secret) { * * @return string */ - public function GetDocumentServerSecret($origin = false) { - if (!$origin && $this->UseDemo()) { + public function getDocumentServerSecret($origin = false) { + if (!$origin && $this->useDemo()) { return $this->DEMO_PARAM["SECRET"]; } $secret = $this->config->getAppValue($this->appName, $this->_jwtSecret, ""); if (empty($secret)) { - $secret = $this->GetSystemValue($this->_jwtSecret); + $secret = $this->getSystemValue($this->_jwtSecret); } return $secret; } @@ -603,10 +603,10 @@ public function GetDocumentServerSecret($origin = false) { * * @return string */ - public function GetSKey() { - $secret = $this->GetDocumentServerSecret(); + public function getSKey() { + $secret = $this->getDocumentServerSecret(); if (empty($secret)) { - $secret = $this->GetSystemValue($this->_cryptSecret, true); + $secret = $this->getSystemValue($this->_cryptSecret, true); } return $secret; } @@ -616,7 +616,7 @@ public function GetSKey() { * * @param array $formats - formats with status */ - public function SetDefaultFormats($formats) { + public function setDefaultFormats($formats) { $value = json_encode($formats); $this->logger->info("Set default formats: $value", ["app" => $this->appName]); @@ -628,7 +628,7 @@ public function SetDefaultFormats($formats) { * * @return array */ - private function GetDefaultFormats() { + private function getDefaultFormats() { $value = $this->config->getAppValue($this->appName, $this->_defFormats, ""); if (empty($value)) { return array(); @@ -641,7 +641,7 @@ private function GetDefaultFormats() { * * @param array $formats - formats with status */ - public function SetEditableFormats($formats) { + public function setEditableFormats($formats) { $value = json_encode($formats); $this->logger->info("Set editing formats: $value", ["app" => $this->appName]); @@ -653,7 +653,7 @@ public function SetEditableFormats($formats) { * * @return array */ - private function GetEditableFormats() { + private function getEditableFormats() { $value = $this->config->getAppValue($this->appName, $this->_editFormats, ""); if (empty($value)) { return array(); @@ -666,7 +666,7 @@ private function GetEditableFormats() { * * @param bool $value - same tab */ - public function SetSameTab($value) { + public function setSameTab($value) { $this->logger->info("Set opening in a same tab: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_sameTab, json_encode($value)); @@ -677,7 +677,7 @@ public function SetSameTab($value) { * * @return bool */ - public function GetSameTab() { + public function getSameTab() { return $this->config->getAppValue($this->appName, $this->_sameTab, "true") === "true"; } @@ -686,7 +686,7 @@ public function GetSameTab() { * * @param bool $value - preview */ - public function SetPreview($value) { + public function setPreview($value) { $this->logger->info("Set generate preview: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_preview, json_encode($value)); @@ -697,7 +697,7 @@ public function SetPreview($value) { * * @return bool */ - public function GetAdvanced() { + public function getAdvanced() { return $this->config->getAppValue($this->appName, $this->_advanced, "false") === "true"; } @@ -706,7 +706,7 @@ public function GetAdvanced() { * * @param bool $value - advanced */ - public function SetAdvanced($value) { + public function setAdvanced($value) { $this->logger->info("Set advanced: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_advanced, json_encode($value)); @@ -717,7 +717,7 @@ public function SetAdvanced($value) { * * @return bool */ - public function GetPreview() { + public function getPreview() { return $this->config->getAppValue($this->appName, $this->_preview, "true") === "true"; } @@ -726,7 +726,7 @@ public function GetPreview() { * * @param bool $value - version history */ - public function SetVersionHistory($value) { + public function setVersionHistory($value) { $this->logger->info("Set keep versions history: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_versionHistory, json_encode($value)); @@ -737,7 +737,7 @@ public function SetVersionHistory($value) { * * @return bool */ - public function GetVersionHistory() { + public function getVersionHistory() { return $this->config->getAppValue($this->appName, $this->_versionHistory, "true") === "true"; } @@ -746,7 +746,7 @@ public function GetVersionHistory() { * * @param bool $value - version history */ - public function SetProtection($value) { + public function setProtection($value) { $this->logger->info("Set protection: " . $value, ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_protection, $value); @@ -757,7 +757,7 @@ public function SetProtection($value) { * * @return bool */ - public function GetProtection() { + public function getProtection() { $value = $this->config->getAppValue($this->appName, $this->_protection, "owner"); if ($value === "all") { return "all"; @@ -770,7 +770,7 @@ public function GetProtection() { * * @param bool $value - display chat */ - public function SetCustomizationChat($value) { + public function setCustomizationChat($value) { $this->logger->info("Set chat display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationChat, json_encode($value)); @@ -781,7 +781,7 @@ public function SetCustomizationChat($value) { * * @return bool */ - public function GetCustomizationChat() { + public function getCustomizationChat() { return $this->config->getAppValue($this->appName, $this->_customizationChat, "true") === "true"; } @@ -790,7 +790,7 @@ public function GetCustomizationChat() { * * @param bool $value - display compact header */ - public function SetCustomizationCompactHeader($value) { + public function setCustomizationCompactHeader($value) { $this->logger->info("Set compact header display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationCompactHeader, json_encode($value)); @@ -801,7 +801,7 @@ public function SetCustomizationCompactHeader($value) { * * @return bool */ - public function GetCustomizationCompactHeader() { + public function getCustomizationCompactHeader() { return $this->config->getAppValue($this->appName, $this->_customizationCompactHeader, "true") === "true"; } @@ -810,7 +810,7 @@ public function GetCustomizationCompactHeader() { * * @param bool $value - display feedback */ - public function SetCustomizationFeedback($value) { + public function setCustomizationFeedback($value) { $this->logger->info("Set feedback display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationFeedback, json_encode($value)); @@ -821,7 +821,7 @@ public function SetCustomizationFeedback($value) { * * @return bool */ - public function GetCustomizationFeedback() { + public function getCustomizationFeedback() { return $this->config->getAppValue($this->appName, $this->_customizationFeedback, "true") === "true"; } @@ -830,7 +830,7 @@ public function GetCustomizationFeedback() { * * @param bool $value - forcesave */ - public function SetCustomizationForcesave($value) { + public function setCustomizationForcesave($value) { $this->logger->info("Set forcesave: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationForcesave, json_encode($value)); @@ -841,7 +841,7 @@ public function SetCustomizationForcesave($value) { * * @return bool */ - public function GetCustomizationForcesave() { + public function getCustomizationForcesave() { return $this->config->getAppValue($this->appName, $this->_customizationForcesave, "false") === "true"; } @@ -850,7 +850,7 @@ public function GetCustomizationForcesave() { * * @param bool $value - display help */ - public function SetCustomizationHelp($value) { + public function setCustomizationHelp($value) { $this->logger->info("Set help display: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationHelp, json_encode($value)); @@ -861,7 +861,7 @@ public function SetCustomizationHelp($value) { * * @return bool */ - public function GetCustomizationHelp() { + public function getCustomizationHelp() { return $this->config->getAppValue($this->appName, $this->_customizationHelp, "true") === "true"; } @@ -870,7 +870,7 @@ public function GetCustomizationHelp() { * * @param bool $value - without tabs */ - public function SetCustomizationToolbarNoTabs($value) { + public function setCustomizationToolbarNoTabs($value) { $this->logger->info("Set without tabs: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationToolbarNoTabs, json_encode($value)); @@ -881,7 +881,7 @@ public function SetCustomizationToolbarNoTabs($value) { * * @return bool */ - public function GetCustomizationToolbarNoTabs() { + public function getCustomizationToolbarNoTabs() { return $this->config->getAppValue($this->appName, $this->_customizationToolbarNoTabs, "true") === "true"; } @@ -890,7 +890,7 @@ public function GetCustomizationToolbarNoTabs() { * * @param string $value - review mode */ - public function SetCustomizationReviewDisplay($value) { + public function setCustomizationReviewDisplay($value) { $this->logger->info("Set review mode: " . $value, array("app" => $this->appName)); $this->config->setAppValue($this->appName, $this->_customizationReviewDisplay, $value); @@ -901,7 +901,7 @@ public function SetCustomizationReviewDisplay($value) { * * @return string */ - public function GetCustomizationReviewDisplay() { + public function getCustomizationReviewDisplay() { $value = $this->config->getAppValue($this->appName, $this->_customizationReviewDisplay, "original"); if ($value === "markup") { return "markup"; @@ -917,7 +917,7 @@ public function GetCustomizationReviewDisplay() { * * @param string $value - theme */ - public function SetCustomizationTheme($value) { + public function setCustomizationTheme($value) { $this->logger->info("Set theme: " . $value, array("app" => $this->appName)); $this->config->setAppValue($this->appName, $this->_customizationTheme, $value); @@ -928,7 +928,7 @@ public function SetCustomizationTheme($value) { * * @return string */ - public function GetCustomizationTheme() { + public function getCustomizationTheme() { $value = $this->config->getAppValue($this->appName, $this->_customizationTheme, "theme-classic-light"); if ($value === "theme-light") { return "theme-light"; @@ -944,7 +944,7 @@ public function GetCustomizationTheme() { * * @param array $settings - watermark settings */ - public function SetWatermarkSettings($settings) { + public function setWatermarkSettings($settings) { $this->logger->info("Set watermark enabled: " . $settings["enabled"], ["app" => $this->appName]); if ($settings["enabled"] !== "true") { @@ -992,7 +992,7 @@ public function SetWatermarkSettings($settings) { * * @return bool|array */ - public function GetWatermarkSettings() { + public function getWatermarkSettings() { $result = [ "text" => $this->config->getAppValue(AppConfig::WATERMARK_APP_NAMESPACE, "watermark_text", "{userId}, {date}"), ]; @@ -1034,7 +1034,7 @@ public function GetWatermarkSettings() { * * @param array $groups - the list of groups */ - public function SetLimitGroups($groups) { + public function setLimitGroups($groups) { if (!is_array($groups)) { $groups = array(); } @@ -1049,7 +1049,7 @@ public function SetLimitGroups($groups) { * * @return array */ - public function GetLimitGroups() { + public function getLimitGroups() { $value = $this->config->getAppValue($this->appName, $this->_groups, ""); if (empty($value)) { return array(); @@ -1075,7 +1075,7 @@ public function isUserAllowedToUse($userId = null) { return false; } - $groups = $this->GetLimitGroups(); + $groups = $this->getLimitGroups(); // no group set -> all users are allowed if (count($groups) === 0) { return true; @@ -1095,7 +1095,7 @@ public function isUserAllowedToUse($userId = null) { $group = \OC::$server->getGroupManager()->get($groupName); if ($group === null) { \OC::$server->getLogger()->error("Group is unknown $groupName", ["app" => $this->appName]); - $this->SetLimitGroups(array_diff($groups, [$groupName])); + $this->setLimitGroups(array_diff($groups, [$groupName])); } else { if ($group->inGroup($user)) { return true; @@ -1111,8 +1111,8 @@ public function isUserAllowedToUse($userId = null) { * * @param bool $verifyPeerOff - parameter verification setting */ - public function SetVerifyPeerOff($verifyPeerOff) { - $this->logger->info("SetVerifyPeerOff " . json_encode($verifyPeerOff), ["app" => $this->appName]); + public function setVerifyPeerOff($verifyPeerOff) { + $this->logger->info("setVerifyPeerOff " . json_encode($verifyPeerOff), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_verification, json_encode($verifyPeerOff)); } @@ -1122,14 +1122,14 @@ public function SetVerifyPeerOff($verifyPeerOff) { * * @return bool */ - public function GetVerifyPeerOff() { + public function getVerifyPeerOff() { $turnOff = $this->config->getAppValue($this->appName, $this->_verification, ""); if (!empty($turnOff)) { return $turnOff === "true"; } - return $this->GetSystemValue($this->_verification); + return $this->getSystemValue($this->_verification); } /** @@ -1137,8 +1137,8 @@ public function GetVerifyPeerOff() { * * @return int */ - public function GetLimitThumbSize() { - $limitSize = (integer)$this->GetSystemValue($this->_limitThumbSize); + public function getLimitThumbSize() { + $limitSize = (integer)$this->getSystemValue($this->_limitThumbSize); if (!empty($limitSize)) { return $limitSize; @@ -1154,14 +1154,14 @@ public function GetLimitThumbSize() { * * @return string */ - public function JwtHeader($origin = false) { - if (!$origin && $this->UseDemo()) { + public function jwtHeader($origin = false) { + if (!$origin && $this->useDemo()) { return $this->DEMO_PARAM["HEADER"]; } $header = $this->config->getAppValue($this->appName, $this->_jwtHeader, ""); if (empty($header)) { - $header = $this->GetSystemValue($this->_jwtHeader); + $header = $this->getSystemValue($this->_jwtHeader); } if (!$origin && empty($header)) { $header = "Authorization"; @@ -1174,7 +1174,7 @@ public function JwtHeader($origin = false) { * * @param string $value - jwtHeader */ - public function SetJwtHeader($value) { + public function setJwtHeader($value) { $value = trim($value); if (empty($value)) { $this->logger->info("Clear header key", ["app" => $this->appName]); @@ -1190,8 +1190,8 @@ public function SetJwtHeader($value) { * * @return int */ - public function GetJwtLeeway() { - $jwtLeeway = (integer)$this->GetSystemValue($this->_jwtLeeway); + public function getJwtLeeway() { + $jwtLeeway = (integer)$this->getSystemValue($this->_jwtLeeway); return $jwtLeeway; } @@ -1201,7 +1201,7 @@ public function GetJwtLeeway() { * * @param string $value - error */ - public function SetSettingsError($value) { + public function setSettingsError($value) { $this->config->setAppValue($this->appName, $this->_settingsError, $value); } @@ -1210,7 +1210,7 @@ public function SetSettingsError($value) { * * @return bool */ - public function SettingsAreSuccessful() { + public function settingsAreSuccessful() { return empty($this->config->getAppValue($this->appName, $this->_settingsError, "")); } @@ -1221,17 +1221,17 @@ public function SettingsAreSuccessful() { * * @NoAdminRequired */ - public function FormatsSetting() { + public function formatsSetting() { $result = $this->formats; - $defFormats = $this->GetDefaultFormats(); + $defFormats = $this->getDefaultFormats(); foreach ($defFormats as $format => $setting) { if (array_key_exists($format, $result)) { $result[$format]["def"] = ($setting === true || $setting === "true"); } } - $editFormats = $this->GetEditableFormats(); + $editFormats = $this->getEditableFormats(); foreach ($editFormats as $format => $setting) { if (array_key_exists($format, $result)) { $result[$format]["edit"] = ($setting === true || $setting === "true"); @@ -1246,7 +1246,7 @@ public function FormatsSetting() { * * @param bool $value - enable macros */ - public function SetCustomizationMacros($value) { + public function setCustomizationMacros($value) { $this->logger->info("Set macros enabled: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationMacros, json_encode($value)); @@ -1257,7 +1257,7 @@ public function SetCustomizationMacros($value) { * * @return bool */ - public function GetCustomizationMacros() { + public function getCustomizationMacros() { return $this->config->getAppValue($this->appName, $this->_customizationMacros, "true") === "true"; } @@ -1266,7 +1266,7 @@ public function GetCustomizationMacros() { * * @param bool $value - enable macros */ - public function SetCustomizationPlugins($value) { + public function setCustomizationPlugins($value) { $this->logger->info("Set plugins enabled: " . json_encode($value), ["app" => $this->appName]); $this->config->setAppValue($this->appName, $this->_customizationPlugins, json_encode($value)); @@ -1277,7 +1277,7 @@ public function SetCustomizationPlugins($value) { * * @return bool */ - public function GetCustomizationPlugins() { + public function getCustomizationPlugins() { return $this->config->getAppValue($this->appName, $this->_customizationPlugins, "true") === "true"; } @@ -1286,8 +1286,8 @@ public function GetCustomizationPlugins() { * * @return int */ - public function GetEditorsCheckInterval() { - $interval = $this->GetSystemValue($this->_editors_check_interval); + public function getEditorsCheckInterval() { + $interval = $this->getSystemValue($this->_editors_check_interval); if (empty($interval) && $interval !== 0) { $interval = 60 * 60 * 24; @@ -1355,7 +1355,7 @@ public function GetEditorsCheckInterval() { * * @return string */ - public function GetLinkToDocs() { + public function getLinkToDocs() { return $this->linkToDocs; } } diff --git a/lib/command/documentserver.php b/lib/command/documentserver.php index 9ba0ae80..080155a6 100644 --- a/lib/command/documentserver.php +++ b/lib/command/documentserver.php @@ -106,7 +106,7 @@ protected function configure() { protected function execute(InputInterface $input, OutputInterface $output) { $check = $input->getOption("check"); - $documentserver = $this->config->GetDocumentServerUrl(true); + $documentserver = $this->config->getDocumentServerUrl(true); if (empty($documentserver)) { $output->writeln("Document server is not configured"); return 1; @@ -116,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $documentService = new DocumentService($this->trans, $this->config); list($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); - $this->config->SetSettingsError($error); + $this->config->setSettingsError($error); if (!empty($error)) { $output->writeln("Error connection: $error"); diff --git a/lib/cron/editorscheck.php b/lib/cron/editorscheck.php index a82a6273..81edd3d1 100644 --- a/lib/cron/editorscheck.php +++ b/lib/cron/editorscheck.php @@ -112,7 +112,7 @@ public function __construct( $this->trans = $trans; $this->crypt = $crypt; $this->groupManager = $groupManager; - $this->setInterval($this->config->GetEditorsCheckInterval()); + $this->setInterval($this->config->getEditorsCheckInterval()); $this->setTimeSensitivity(IJob::TIME_SENSITIVE); } @@ -122,17 +122,17 @@ public function __construct( * @param array $argument unused argument */ protected function run($argument) { - if (empty($this->config->GetDocumentServerUrl())) { + if (empty($this->config->getDocumentServerUrl())) { $this->logger->debug("Settings are empty", ["app" => $this->appName]); return; } - if (!$this->config->SettingsAreSuccessful()) { + if (!$this->config->settingsAreSuccessful()) { $this->logger->debug("Settings are not correct", ["app" => $this->appName]); return; } $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.emptyfile"); - if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { - $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); + if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) { + $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $fileUrl); } $host = parse_url($fileUrl)["host"]; if ($host === "localhost" || $host === "127.0.0.1") { @@ -147,7 +147,7 @@ protected function run($argument) { if (!empty($error)) { $this->logger->info("ONLYOFFICE server is not available", ["app" => $this->appName]); - $this->config->SetSettingsError($error); + $this->config->setSettingsError($error); $this->notifyAdmins(); } else { $this->logger->debug("ONLYOFFICE server availability check is finished successfully", ["app" => $this->appName]); diff --git a/lib/crypt.php b/lib/crypt.php index f55259bd..7b9cd45a 100644 --- a/lib/crypt.php +++ b/lib/crypt.php @@ -47,8 +47,8 @@ public function __construct(AppConfig $appConfig) { * * @return string */ - public function GetHash($object) { - return \Firebase\JWT\JWT::encode($object, $this->config->GetSKey(), "HS256"); + public function getHash($object) { + return \Firebase\JWT\JWT::encode($object, $this->config->getSKey(), "HS256"); } /** @@ -58,14 +58,14 @@ public function GetHash($object) { * * @return array */ - public function ReadHash($token) { + public function readHash($token) { $result = null; $error = null; if ($token === null) { return [$result, "token is empty"]; } try { - $result = \Firebase\JWT\JWT::decode($token, new \Firebase\JWT\Key($this->config->GetSKey(), "HS256")); + $result = \Firebase\JWT\JWT::decode($token, new \Firebase\JWT\Key($this->config->getSKey(), "HS256")); } catch (\UnexpectedValueException $e) { $error = $e->getMessage(); } diff --git a/lib/directeditor.php b/lib/directeditor.php index 90389d0f..67c9c574 100644 --- a/lib/directeditor.php +++ b/lib/directeditor.php @@ -130,7 +130,7 @@ public function getMimetypes(): array { return $mimes; } - $formats = $this->config->FormatsSetting(); + $formats = $this->config->formatsSetting(); foreach ($formats as $format => $setting) { if (array_key_exists("edit", $setting) && $setting["edit"] && array_key_exists("def", $setting) && $setting["def"]) { @@ -152,7 +152,7 @@ public function getMimetypesOptional(): array { return $mimes; } - $formats = $this->config->FormatsSetting(); + $formats = $this->config->formatsSetting(); foreach ($formats as $format => $setting) { if (array_key_exists("edit", $setting) && $setting["edit"] && (!array_key_exists("def", $setting) || !$setting["def"])) { @@ -213,14 +213,14 @@ public function open(IToken $token): Response { return $this->renderError($this->trans->t("Not permitted")); } - $documentServerUrl = $this->config->GetDocumentServerUrl(); + $documentServerUrl = $this->config->getDocumentServerUrl(); if (empty($documentServerUrl)) { $this->logger->error("documentServerUrl is empty", ["app" => $this->appName]); return $this->renderError($this->trans->t("ONLYOFFICE app is not configured. Please contact admin")); } - $directToken = $this->crypt->GetHash([ + $directToken = $this->crypt->getHash([ "userId" => $userId, "fileId" => $fileId, "action" => "direct", diff --git a/lib/documentservice.php b/lib/documentservice.php index 7d5b9312..bbb96ca9 100644 --- a/lib/documentservice.php +++ b/lib/documentservice.php @@ -65,7 +65,7 @@ public function __construct(IL10N $trans, AppConfig $appConfig) { * * @return string */ - public static function GenerateRevisionId($expected_key) { + public static function generateRevisionId($expected_key) { if (strlen($expected_key) > 20) { $expected_key = crc32($expected_key); } @@ -85,12 +85,12 @@ public static function GenerateRevisionId($expected_key) { * * @return string */ - public function GetConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id, $region = null) { - $responceFromConvertService = $this->SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, false, $region); + public function getConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id, $region = null) { + $responceFromConvertService = $this->sendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, false, $region); $errorElement = $responceFromConvertService->Error; if ($errorElement->count() > 0) { - $this->ProcessConvServResponceError($errorElement . ""); + $this->processConvServResponceError($errorElement . ""); } $isEndConvert = $responceFromConvertService->EndConvert; @@ -114,8 +114,8 @@ public function GetConvertedUri($document_uri, $from_extension, $to_extension, $ * * @return array */ - public function SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, $region = null) { - $documentServerUrl = $this->config->GetDocumentServerInternalUrl(); + public function sendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async, $region = null) { + $documentServerUrl = $this->config->getDocumentServerInternalUrl(); if (empty($documentServerUrl)) { throw new \Exception($this->trans->t("ONLYOFFICE app is not configured. Please contact admin")); @@ -127,7 +127,7 @@ public function SendRequestToConvertService($document_uri, $from_extension, $to_ $document_revision_id = $document_uri; } - $document_revision_id = self::GenerateRevisionId($document_revision_id); + $document_revision_id = self::generateRevisionId($document_revision_id); if (empty($from_extension)) { $from_extension = pathinfo($document_uri)["extension"]; @@ -148,8 +148,8 @@ public function SendRequestToConvertService($document_uri, $from_extension, $to_ $data["region"] = $region; } - if ($this->config->UseDemo()) { - $data["tenant"] = $this->config->GetSystemValue("instanceid", true); + if ($this->config->useDemo()) { + $data["tenant"] = $this->config->getSystemValue("instanceid", true); } $opts = [ @@ -160,19 +160,19 @@ public function SendRequestToConvertService($document_uri, $from_extension, $to_ "body" => json_encode($data) ]; - if (!empty($this->config->GetDocumentServerSecret())) { + if (!empty($this->config->getDocumentServerSecret())) { $params = [ "payload" => $data ]; - $token = \Firebase\JWT\JWT::encode($params, $this->config->GetDocumentServerSecret(), "HS256"); - $opts["headers"][$this->config->JwtHeader()] = "Bearer " . $token; + $token = \Firebase\JWT\JWT::encode($params, $this->config->getDocumentServerSecret(), "HS256"); + $opts["headers"][$this->config->jwtHeader()] = "Bearer " . $token; - $token = \Firebase\JWT\JWT::encode($data, $this->config->GetDocumentServerSecret(), "HS256"); + $token = \Firebase\JWT\JWT::encode($data, $this->config->getDocumentServerSecret(), "HS256"); $data["token"] = $token; $opts["body"] = json_encode($data); } - $response_xml_data = $this->Request($urlToConverter, "post", $opts); + $response_xml_data = $this->request($urlToConverter, "post", $opts); libxml_use_internal_errors(true); if (!function_exists("simplexml_load_file")) { @@ -197,7 +197,7 @@ public function SendRequestToConvertService($document_uri, $from_extension, $to_ * * @return null */ - public function ProcessConvServResponceError($errorCode) { + public function processConvServResponceError($errorCode) { $errorMessageTemplate = $this->trans->t("Error occurred in the document service"); $errorMessage = ""; @@ -244,9 +244,9 @@ public function ProcessConvServResponceError($errorCode) { * * @return bool */ - public function HealthcheckRequest() { + public function healthcheckRequest() { - $documentServerUrl = $this->config->GetDocumentServerInternalUrl(); + $documentServerUrl = $this->config->getDocumentServerInternalUrl(); if (empty($documentServerUrl)) { throw new \Exception($this->trans->t("ONLYOFFICE app is not configured. Please contact admin")); @@ -254,7 +254,7 @@ public function HealthcheckRequest() { $urlHealthcheck = $documentServerUrl . "healthcheck"; - $response = $this->Request($urlHealthcheck); + $response = $this->request($urlHealthcheck); return $response === "true"; } @@ -266,9 +266,9 @@ public function HealthcheckRequest() { * * @return array */ - public function CommandRequest($method) { + public function commandRequest($method) { - $documentServerUrl = $this->config->GetDocumentServerInternalUrl(); + $documentServerUrl = $this->config->getDocumentServerInternalUrl(); if (empty($documentServerUrl)) { throw new \Exception($this->trans->t("ONLYOFFICE app is not configured. Please contact admin")); @@ -287,23 +287,23 @@ public function CommandRequest($method) { "body" => json_encode($data) ]; - if (!empty($this->config->GetDocumentServerSecret())) { + if (!empty($this->config->getDocumentServerSecret())) { $params = [ "payload" => $data ]; - $token = \Firebase\JWT\JWT::encode($params, $this->config->GetDocumentServerSecret(), "HS256"); - $opts["headers"][$this->config->JwtHeader()] = "Bearer " . $token; + $token = \Firebase\JWT\JWT::encode($params, $this->config->getDocumentServerSecret(), "HS256"); + $opts["headers"][$this->config->jwtHeader()] = "Bearer " . $token; - $token = \Firebase\JWT\JWT::encode($data, $this->config->GetDocumentServerSecret(), "HS256"); + $token = \Firebase\JWT\JWT::encode($data, $this->config->getDocumentServerSecret(), "HS256"); $data["token"] = $token; $opts["body"] = json_encode($data); } - $response = $this->Request($urlCommand, "post", $opts); + $response = $this->request($urlCommand, "post", $opts); $data = json_decode($response); - $this->ProcessCommandServResponceError($data->error); + $this->processCommandServResponceError($data->error); return $data; } @@ -315,7 +315,7 @@ public function CommandRequest($method) { * * @return null */ - public function ProcessCommandServResponceError($errorCode) { + public function processCommandServResponceError($errorCode) { $errorMessageTemplate = $this->trans->t("Error occurred in the document service"); $errorMessage = ""; @@ -348,14 +348,14 @@ public function ProcessCommandServResponceError($errorCode) { * * @return string */ - public function Request($url, $method = "get", $opts = null) { + public function request($url, $method = "get", $opts = null) { $httpClientService = \OC::$server->getHTTPClientService(); $client = $httpClientService->newClient(); if (null === $opts) { $opts = array(); } - if (substr($url, 0, strlen("https")) === "https" && $this->config->GetVerifyPeerOff()) { + if (substr($url, 0, strlen("https")) === "https" && $this->config->getVerifyPeerOff()) { $opts["verify"] = false; } if (!array_key_exists("timeout", $opts)) { @@ -389,7 +389,7 @@ public function checkDocServiceUrl($urlGenerator, $crypt) { try { if (preg_match("/^https:\/\//i", $urlGenerator->getAbsoluteURL("/")) - && preg_match("/^http:\/\//i", $this->config->GetDocumentServerUrl())) { + && preg_match("/^http:\/\//i", $this->config->getDocumentServerUrl())) { throw new \Exception($this->trans->t("Mixed Active Content is not allowed. HTTPS address for ONLYOFFICE Docs is required.")); } } catch (\Exception $e) { @@ -398,18 +398,18 @@ public function checkDocServiceUrl($urlGenerator, $crypt) { } try { - $healthcheckResponse = $this->HealthcheckRequest(); + $healthcheckResponse = $this->healthcheckRequest(); if (!$healthcheckResponse) { throw new \Exception($this->trans->t("Bad healthcheck status")); } } catch (\Exception $e) { - $logger->logException($e, ["message" => "HealthcheckRequest on check error", "app" => self::$appName]); + $logger->logException($e, ["message" => "healthcheckRequest on check error", "app" => self::$appName]); return [$e->getMessage(), $version]; } try { - $commandResponse = $this->CommandRequest("version"); - $logger->debug("CommandRequest on check: " . json_encode($commandResponse), ["app" => self::$appName]); + $commandResponse = $this->commandRequest("version"); + $logger->debug("commandRequest on check: " . json_encode($commandResponse), ["app" => self::$appName]); if (empty($commandResponse)) { throw new \Exception($this->trans->t("Error occurred in the document service")); } @@ -419,30 +419,30 @@ public function checkDocServiceUrl($urlGenerator, $crypt) { throw new \Exception($this->trans->t("Not supported version")); } } catch (\Exception $e) { - $logger->logException($e, ["message" => "CommandRequest on check error", "app" => self::$appName]); + $logger->logException($e, ["message" => "commandRequest on check error", "app" => self::$appName]); return [$e->getMessage(), $version]; } $convertedFileUri = null; try { - $hashUrl = $crypt->GetHash(["action" => "empty"]); + $hashUrl = $crypt->getHash(["action" => "empty"]); $fileUrl = $urlGenerator->linkToRouteAbsolute(self::$appName . ".callback.emptyfile", ["doc" => $hashUrl]); - if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { - $fileUrl = str_replace($urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); + if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) { + $fileUrl = str_replace($urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $fileUrl); } - $convertedFileUri = $this->GetConvertedUri($fileUrl, "docx", "docx", "check_" . rand()); + $convertedFileUri = $this->getConvertedUri($fileUrl, "docx", "docx", "check_" . rand()); if (strcmp($convertedFileUri, $fileUrl) === 0) { - $logger->debug("GetConvertedUri skipped", ["app" => self::$appName]); + $logger->debug("getConvertedUri skipped", ["app" => self::$appName]); } } catch (\Exception $e) { - $logger->logException($e, ["message" => "GetConvertedUri on check error", "app" => self::$appName]); + $logger->logException($e, ["message" => "getConvertedUri on check error", "app" => self::$appName]); return [$e->getMessage(), $version]; } try { - $this->Request($convertedFileUri); + $this->request($convertedFileUri); } catch (\Exception $e) { $logger->logException($e, ["message" => "Request converted file on check error", "app" => self::$appName]); return [$e->getMessage(), $version]; diff --git a/lib/extrapermissions.php b/lib/extrapermissions.php index 3f6d9792..2e8c89be 100644 --- a/lib/extrapermissions.php +++ b/lib/extrapermissions.php @@ -401,7 +401,7 @@ private function validation($share, $checkExtra) { $node = $share->getNode(); $ext = strtolower(pathinfo($node->getName(), PATHINFO_EXTENSION)); - $format = !empty($ext) && array_key_exists($ext, $this->config->FormatsSetting()) ? $this->config->FormatsSetting()[$ext] : null; + $format = !empty($ext) && array_key_exists($ext, $this->config->formatsSetting()) ? $this->config->formatsSetting()[$ext] : null; if (!isset($format)) { return [$availableExtra, $defaultExtra]; } diff --git a/lib/filecreator.php b/lib/filecreator.php index 732ef332..6d4c4752 100644 --- a/lib/filecreator.php +++ b/lib/filecreator.php @@ -136,7 +136,7 @@ public function create(File $file, string $creatorId = null, string $templateId $this->logger->debug("FileCreator: " . $file->getId() . " " . $file->getName() . " $creatorId $templateId", ["app" => $this->appName]); $fileName = $file->getName(); - $template = TemplateManager::GetEmptyTemplate($fileName); + $template = TemplateManager::getEmptyTemplate($fileName); if (!$template) { $this->logger->error("FileCreator: Template for file creation not found: $templateId", ["app" => $this->appName]); diff --git a/lib/fileutility.php b/lib/fileutility.php index e4d4b35a..1cf35259 100644 --- a/lib/fileutility.php +++ b/lib/fileutility.php @@ -228,7 +228,7 @@ public function getKey($file, $origin = false) { $key = KeyManager::get($fileId); if (empty($key)) { - $instanceId = $this->config->GetSystemValue("instanceid", true); + $instanceId = $this->config->getSystemValue("instanceid", true); $key = $instanceId . "_" . $this->GUID(); @@ -259,7 +259,7 @@ private function GUID() { * @return string */ public function getVersionKey($version) { - $instanceId = $this->config->GetSystemValue("instanceid", true); + $instanceId = $this->config->getSystemValue("instanceid", true); $key = $instanceId . "_" . $version->getSourceFile()->getEtag() . "_" . $version->getRevisionId(); diff --git a/lib/listeners/directeditorlistener.php b/lib/listeners/directeditorlistener.php index 4c1de5a1..afc9bb89 100644 --- a/lib/listeners/directeditorlistener.php +++ b/lib/listeners/directeditorlistener.php @@ -62,8 +62,8 @@ public function handle(Event $event): void { return; } - if (!empty($this->appConfig->GetDocumentServerUrl()) - && $this->appConfig->SettingsAreSuccessful()) { + if (!empty($this->appConfig->getDocumentServerUrl()) + && $this->appConfig->settingsAreSuccessful()) { $event->register($this->editor); } } diff --git a/lib/listeners/filesharinglistener.php b/lib/listeners/filesharinglistener.php index a2273788..146cee41 100644 --- a/lib/listeners/filesharinglistener.php +++ b/lib/listeners/filesharinglistener.php @@ -76,11 +76,11 @@ public function handle(Event $event): void { return; } - if (!empty($this->appConfig->GetDocumentServerUrl()) - && $this->appConfig->SettingsAreSuccessful()) { + if (!empty($this->appConfig->getDocumentServerUrl()) + && $this->appConfig->settingsAreSuccessful()) { Util::addScript("onlyoffice", "main"); - if ($this->appConfig->GetSameTab()) { + if ($this->appConfig->getSameTab()) { Util::addScript("onlyoffice", "listener"); } diff --git a/lib/listeners/fileslistener.php b/lib/listeners/fileslistener.php index 2d2c15cf..bb9d8928 100644 --- a/lib/listeners/fileslistener.php +++ b/lib/listeners/fileslistener.php @@ -76,18 +76,18 @@ public function handle(Event $event): void { return; } - if (!empty($this->appConfig->GetDocumentServerUrl()) - && $this->appConfig->SettingsAreSuccessful() + if (!empty($this->appConfig->getDocumentServerUrl()) + && $this->appConfig->settingsAreSuccessful() && $this->appConfig->isUserAllowedToUse()) { Util::addScript("onlyoffice", "desktop"); Util::addScript("onlyoffice", "main"); Util::addScript("onlyoffice", "template"); - if ($this->appConfig->GetSameTab()) { + if ($this->appConfig->getSameTab()) { Util::addScript("onlyoffice", "listener"); } - if ($this->appConfig->GetAdvanced() + if ($this->appConfig->getAdvanced() && \OC::$server->getAppManager()->isInstalled("files_sharing")) { Util::addScript("onlyoffice", "share"); Util::addStyle("onlyoffice", "share"); diff --git a/lib/listeners/viewerlistener.php b/lib/listeners/viewerlistener.php index c04b4b69..d4624795 100644 --- a/lib/listeners/viewerlistener.php +++ b/lib/listeners/viewerlistener.php @@ -77,8 +77,8 @@ public function handle(Event $event): void { return; } - if (!empty($this->appConfig->GetDocumentServerUrl()) - && $this->appConfig->SettingsAreSuccessful() + if (!empty($this->appConfig->getDocumentServerUrl()) + && $this->appConfig->settingsAreSuccessful() && $this->appConfig->isUserAllowedToUse()) { Util::addScript("onlyoffice", "viewer", "viewer"); Util::addScript("onlyoffice", "listener", "viewer"); diff --git a/lib/listeners/widgetlistener.php b/lib/listeners/widgetlistener.php index ccd80ebe..4ccc7258 100644 --- a/lib/listeners/widgetlistener.php +++ b/lib/listeners/widgetlistener.php @@ -50,8 +50,8 @@ public function handle(Event $event): void { return; } - if (!empty($this->appConfig->GetDocumentServerUrl()) - && $this->appConfig->SettingsAreSuccessful() + if (!empty($this->appConfig->getDocumentServerUrl()) + && $this->appConfig->settingsAreSuccessful() && $this->appConfig->isUserAllowedToUse()) { Util::addScript("onlyoffice", "desktop"); } diff --git a/lib/preview.php b/lib/preview.php index 0b877bc6..5b280035 100644 --- a/lib/preview.php +++ b/lib/preview.php @@ -221,12 +221,12 @@ public function getMimeType() { * @return bool */ public function isAvailable(FileInfo $fileInfo) { - if ($this->config->GetPreview() !== true) { + if ($this->config->getPreview() !== true) { return false; } if (!$fileInfo || $fileInfo->getSize() === 0 - || $fileInfo->getSize() > $this->config->GetLimitThumbSize()) { + || $fileInfo->getSize() > $this->config->getLimitThumbSize()) { return false; } if (!in_array($fileInfo->getMimetype(), self::$capabilities, true)) { @@ -260,14 +260,14 @@ public function getThumbnail($path, $maxX, $maxY, $scalingup, $view) { $imageUrl = null; $documentService = new DocumentService($this->trans, $this->config); try { - $imageUrl = $documentService->GetConvertedUri($fileUrl, $extension, self::THUMBEXTENSION, $key); + $imageUrl = $documentService->getConvertedUri($fileUrl, $extension, self::THUMBEXTENSION, $key); } catch (\Exception $e) { - $this->logger->logException($e, ["message" => "GetConvertedUri: from $extension to " . self::THUMBEXTENSION, "app" => $this->appName]); + $this->logger->logException($e, ["message" => "getConvertedUri: from $extension to " . self::THUMBEXTENSION, "app" => $this->appName]); return false; } try { - $thumbnail = $documentService->Request($imageUrl); + $thumbnail = $documentService->request($imageUrl); } catch (\Exception $e) { $this->logger->logException($e, ["message" => "Failed to download thumbnail", "app" => $this->appName]); return false; @@ -313,12 +313,12 @@ private function getUrl($file, $user = null, $version = 0, $template = false) { $data["template"] = true; } - $hashUrl = $this->crypt->GetHash($data); + $hashUrl = $this->crypt->getHash($data); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]); - if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { - $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); + if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) { + $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $fileUrl); } return $fileUrl; @@ -369,17 +369,17 @@ private function getFileParam($path, $view) { $versionId = $version->getRevisionId(); if (strcmp($versionId, $fileVersion) === 0) { $key = $this->fileUtility->getVersionKey($version); - $key = DocumentService::GenerateRevisionId($key); + $key = DocumentService::generateRevisionId($key); break; } } } else { $key = $this->fileUtility->getKey($fileInfo); - $key = DocumentService::GenerateRevisionId($key); + $key = DocumentService::generateRevisionId($key); } - if (TemplateManager::IsTemplate($fileInfo->getId())) { + if (TemplateManager::isTemplate($fileInfo->getId())) { $template = true; } diff --git a/lib/settingsdata.php b/lib/settingsdata.php index 506627c7..484496c9 100644 --- a/lib/settingsdata.php +++ b/lib/settingsdata.php @@ -34,8 +34,8 @@ public function __construct(AppConfig $appConfig) { public function jsonSerialize(): array { $data = [ - "formats" => $this->appConfig->FormatsSetting(), - "sameTab" => $this->appConfig->GetSameTab() + "formats" => $this->appConfig->formatsSetting(), + "sameTab" => $this->appConfig->getSameTab() ]; return $data; diff --git a/lib/templatemanager.php b/lib/templatemanager.php index 000b9a2e..d8605ef5 100644 --- a/lib/templatemanager.php +++ b/lib/templatemanager.php @@ -49,8 +49,8 @@ class TemplateManager { * * @return Folder */ - public static function GetGlobalTemplateDir() { - $dirPath = "appdata_" . \OC::$server->getConfig()->GetSystemValue("instanceid", null) + public static function getGlobalTemplateDir() { + $dirPath = "appdata_" . \OC::$server->getConfig()->getSystemValue("instanceid", null) . "/" . self::$appName . "/" . self::$templateFolderName; @@ -72,8 +72,8 @@ public static function GetGlobalTemplateDir() { * * @return array */ - public static function GetGlobalTemplates($mimetype = null) { - $templateDir = self::GetGlobalTemplateDir(); + public static function getGlobalTemplates($mimetype = null) { + $templateDir = self::getGlobalTemplateDir(); $templatesList = $templateDir->getDirectoryListing(); if (!empty($mimetype) @@ -91,7 +91,7 @@ public static function GetGlobalTemplates($mimetype = null) { * * @return File */ - public static function GetTemplate($templateId) { + public static function getTemplate($templateId) { $logger = \OC::$server->getLogger(); if (empty($templateId)) { @@ -99,11 +99,11 @@ public static function GetTemplate($templateId) { return null; } - $templateDir = self::GetGlobalTemplateDir(); + $templateDir = self::getGlobalTemplateDir(); try { $templates = $templateDir->getById($templateId); } catch (\Exception $e) { - $logger->logException($e, ["message" => "GetTemplate: $templateId", "app" => self::$appName]); + $logger->logException($e, ["message" => "getTemplate: $templateId", "app" => self::$appName]); return null; } @@ -121,7 +121,7 @@ public static function GetTemplate($templateId) { * * @return string */ - public static function GetTypeTemplate($mime) { + public static function getTypeTemplate($mime) { switch ($mime) { case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return "document"; @@ -141,7 +141,7 @@ public static function GetTypeTemplate($mime) { * * @return string */ - public static function GetMimeTemplate($type) { + public static function getMimeTemplate($type) { switch ($type) { case "document": return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; @@ -161,7 +161,7 @@ public static function GetMimeTemplate($type) { * * @return bool */ - public static function IsTemplateType($name) { + public static function isTemplateType($name) { $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); switch ($ext) { case "docx": @@ -180,8 +180,8 @@ public static function IsTemplateType($name) { * * @return bool */ - public static function IsTemplate($fileId) { - $template = self::GetTemplate($fileId); + public static function isTemplate($fileId) { + $template = self::getTemplate($fileId); if (empty($template)) { return false; @@ -197,12 +197,12 @@ public static function IsTemplate($fileId) { * * @return string */ - public static function GetEmptyTemplate($name) { + public static function getEmptyTemplate($name) { $ext = strtolower("." . pathinfo($name, PATHINFO_EXTENSION)); $lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode(); - $templatePath = self::GetEmptyTemplatePath($lang, $ext); + $templatePath = self::getEmptyTemplatePath($lang, $ext); if (!file_exists($templatePath)) { return false; } @@ -219,7 +219,7 @@ public static function GetEmptyTemplate($name) { * * @return string */ - public static function GetEmptyTemplatePath($lang, $ext) { + public static function getEmptyTemplatePath($lang, $ext) { if (!array_key_exists($lang, self::$localPath)) { $lang = "en"; } diff --git a/lib/templateprovider.php b/lib/templateprovider.php index fd80ec8a..b33735c3 100644 --- a/lib/templateprovider.php +++ b/lib/templateprovider.php @@ -59,7 +59,7 @@ public function __construct($AppName, IURLGenerator $urlGenerator) { public function getCustomTemplates($mimetype) : array { $templates = []; - $templateFiles = TemplateManager::GetGlobalTemplates($mimetype); + $templateFiles = TemplateManager::getGlobalTemplates($mimetype); foreach ($templateFiles as $templateFile) { $template = new Template( @@ -84,6 +84,6 @@ public function getCustomTemplates($mimetype) : array { * @return File */ public function getCustomTemplate($templateId) : File { - return TemplateManager::GetTemplate($templateId); + return TemplateManager::getTemplate($templateId); } } From ed1e8e7f30516acfd473d2ae273f95e020ee3451 Mon Sep 17 00:00:00 2001 From: Stepan Mayorov Date: Tue, 10 Oct 2023 17:16:32 +0300 Subject: [PATCH 025/209] Update lint-phpcs.yml branches changed --- .github/workflows/lint-phpcs.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-phpcs.yml b/.github/workflows/lint-phpcs.yml index 082af8ed..0b293661 100644 --- a/.github/workflows/lint-phpcs.yml +++ b/.github/workflows/lint-phpcs.yml @@ -2,8 +2,9 @@ name: Lint on: push: + branches: [master] pull_request: - branches: [refactor/linter-formatting] + branches: [master, develop] permissions: contents: read From db8725f02bb1b8fb22ac4752e574638faa1f3c6d Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 13 Oct 2023 11:32:03 +0300 Subject: [PATCH 026/209] fixed color of app icon for dark theme --- css/main.css | 6 +++++- css/share.css | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/css/main.css b/css/main.css index 4bec6848..c96905cd 100644 --- a/css/main.css +++ b/css/main.css @@ -33,7 +33,11 @@ .icon-onlyoffice-download, .icon-onlyoffice-fill, .icon-onlyoffice-create { - background-image: url("../img/app-dark.svg"); + background-color: var(--color-main-text); + mask: url("../img/app-dark.svg") no-repeat 50% 50%; + mask-size: 16px 16px; + -webkit-mask: url("../img/app-dark.svg") no-repeat 50% 50%; + -webkit-mask-size: 16px 16px; } /* onlyoffice-inline */ diff --git a/css/share.css b/css/share.css index 754c4897..9cab5212 100644 --- a/css/share.css +++ b/css/share.css @@ -17,7 +17,11 @@ */ .icon-onlyoffice-sharing { - background-image: url("../img/app-dark.svg"); + background-color: var(--color-main-text); + mask: url("../img/app-dark.svg") no-repeat 50% 50%; + mask-size: 16px 16px; + -webkit-mask: url("../img/app-dark.svg") no-repeat 50% 50%; + -webkit-mask-size: 16px 16px; } .onlyoffice-share-item { display: flex; From 888df490579e0e52bb02350bced11fa13fff7f29 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 13 Oct 2023 14:17:51 +0300 Subject: [PATCH 027/209] phpcs workflow_dispatch --- .github/workflows/lint-phpcs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint-phpcs.yml b/.github/workflows/lint-phpcs.yml index 0b293661..9ec5bd6b 100644 --- a/.github/workflows/lint-phpcs.yml +++ b/.github/workflows/lint-phpcs.yml @@ -1,6 +1,7 @@ name: Lint on: + workflow_dispatch: push: branches: [master] pull_request: From e03bdc11193a0f35c4052c5988b4512f42c4301a Mon Sep 17 00:00:00 2001 From: rivexe Date: Fri, 13 Oct 2023 14:58:22 +0300 Subject: [PATCH 028/209] no blank lines in use statements --- appinfo/application.php | 4 ---- controller/callbackcontroller.php | 2 -- controller/editorapicontroller.php | 2 -- controller/editorcontroller.php | 2 -- controller/federationcontroller.php | 1 - controller/joblistcontroller.php | 1 - controller/settingscontroller.php | 1 - controller/sharingapicontroller.php | 2 -- controller/templatecontroller.php | 1 - lib/adminsettings.php | 1 - lib/appconfig.php | 1 - lib/command/documentserver.php | 2 -- lib/cron/editorscheck.php | 1 - lib/fileversions.php | 2 -- lib/hooks.php | 1 - lib/listeners/directeditorlistener.php | 1 - lib/listeners/filesharinglistener.php | 2 -- lib/listeners/fileslistener.php | 2 -- lib/listeners/viewerlistener.php | 2 -- lib/listeners/widgetlistener.php | 1 - lib/preview.php | 2 -- lib/remoteinstance.php | 1 - lib/templatemanager.php | 1 - 23 files changed, 36 deletions(-) diff --git a/appinfo/application.php b/appinfo/application.php index c59d1752..75621c0b 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -20,7 +20,6 @@ namespace OCA\Onlyoffice\AppInfo; use OC\EventDispatcher\SymfonyAdapter; - use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; @@ -38,10 +37,8 @@ use OCP\IPreview; use OCP\ITagManager; use OCP\Notification\IManager; - use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent; use OCA\Viewer\Event\LoadViewer; - use OCA\Onlyoffice\AppConfig; use OCA\Onlyoffice\Controller\CallbackController; use OCA\Onlyoffice\Controller\EditorController; @@ -63,7 +60,6 @@ use OCA\Onlyoffice\TemplateManager; use OCA\Onlyoffice\TemplateProvider; use OCA\Onlyoffice\SettingsData; - use Psr\Container\ContainerInterface; class Application extends App implements IBootstrap { diff --git a/controller/callbackcontroller.php b/controller/callbackcontroller.php index 8c48d69b..2a48fa5c 100644 --- a/controller/callbackcontroller.php +++ b/controller/callbackcontroller.php @@ -44,9 +44,7 @@ use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\IL10N; - use OCP\ILogger; - use OCP\IRequest; use OCP\IUserManager; use OCP\IUserSession; diff --git a/controller/editorapicontroller.php b/controller/editorapicontroller.php index 6d341779..4e2442a0 100644 --- a/controller/editorapicontroller.php +++ b/controller/editorapicontroller.php @@ -42,9 +42,7 @@ use OCP\IRequest; use OCP\ISession; use OCP\ITagManager; - use OCP\ITags; - use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 69ce397b..6e475945 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -41,10 +41,8 @@ use OCP\IGroupManager; use OCP\IL10N; use OCP\ILogger; - use OCP\IRequest; use OCP\ISession; - use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; diff --git a/controller/federationcontroller.php b/controller/federationcontroller.php index 55e32b8c..81b5cc2b 100644 --- a/controller/federationcontroller.php +++ b/controller/federationcontroller.php @@ -26,7 +26,6 @@ use OCA\Onlyoffice\RemoteInstance; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; - use OCP\IL10N; use OCP\ILogger; use OCP\IRequest; diff --git a/controller/joblistcontroller.php b/controller/joblistcontroller.php index 8d536034..de2100a3 100644 --- a/controller/joblistcontroller.php +++ b/controller/joblistcontroller.php @@ -23,7 +23,6 @@ use OCA\Onlyoffice\Cron\EditorsCheck; use OCP\AppFramework\Controller; use OCP\BackgroundJob\IJob; - use OCP\BackgroundJob\IJobList; use OCP\IRequest; diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php index 5895d0e8..563b62fb 100644 --- a/controller/settingscontroller.php +++ b/controller/settingscontroller.php @@ -25,7 +25,6 @@ use OCA\Onlyoffice\FileVersions; use OCA\Onlyoffice\TemplateManager; use OCP\AppFramework\Controller; - use OCP\AppFramework\Http\TemplateResponse; use OCP\IL10N; use OCP\ILogger; diff --git a/controller/sharingapicontroller.php b/controller/sharingapicontroller.php index 65b9f6e1..f6b90cf8 100644 --- a/controller/sharingapicontroller.php +++ b/controller/sharingapicontroller.php @@ -30,8 +30,6 @@ use OCP\IRequest; use OCP\IUserManager; use OCP\IUserSession; - - use OCP\Share\IManager; use OCP\Share\IShare; diff --git a/controller/templatecontroller.php b/controller/templatecontroller.php index 215074f9..5861cd92 100644 --- a/controller/templatecontroller.php +++ b/controller/templatecontroller.php @@ -28,7 +28,6 @@ use OCP\IL10N; use OCP\ILogger; use OCP\IPreview; - use OCP\IRequest; /** diff --git a/lib/adminsettings.php b/lib/adminsettings.php index a79af0e3..20d6bd9a 100644 --- a/lib/adminsettings.php +++ b/lib/adminsettings.php @@ -20,7 +20,6 @@ namespace OCA\Onlyoffice; use OCA\Onlyoffice\AppInfo\Application; - use OCA\Onlyoffice\Controller\SettingsController; use OCP\Settings\ISettings; diff --git a/lib/appconfig.php b/lib/appconfig.php index 3d568d3d..55eeba00 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -21,7 +21,6 @@ use \DateInterval; use \DateTime; - use OCP\IConfig; use OCP\ILogger; diff --git a/lib/command/documentserver.php b/lib/command/documentserver.php index 080155a6..621e3636 100644 --- a/lib/command/documentserver.php +++ b/lib/command/documentserver.php @@ -23,10 +23,8 @@ use OCA\Onlyoffice\Crypt; use OCA\Onlyoffice\DocumentService; use OCP\IL10N; - use OCP\IURLGenerator; use Symfony\Component\Console\Command\Command; - use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; diff --git a/lib/cron/editorscheck.php b/lib/cron/editorscheck.php index 81edd3d1..3e3ac69b 100644 --- a/lib/cron/editorscheck.php +++ b/lib/cron/editorscheck.php @@ -26,7 +26,6 @@ use OCP\BackgroundJob\IJob; use OCP\BackgroundJob\TimedJob; use OCP\IGroup; - use OCP\IGroupManager; use OCP\IL10N; use OCP\IURLGenerator; diff --git a/lib/fileversions.php b/lib/fileversions.php index 66c31d56..4ab5ac2a 100644 --- a/lib/fileversions.php +++ b/lib/fileversions.php @@ -22,11 +22,9 @@ use OC\Files\Node\File; use OC\Files\View; use OC\User\Database; - use OCA\Files_Sharing\External\Storage as SharingExternalStorage; use OCP\Files\FileInfo; use OCP\Files\IRootFolder; - use OCP\IUser; /** diff --git a/lib/hooks.php b/lib/hooks.php index b4906d75..24343623 100644 --- a/lib/hooks.php +++ b/lib/hooks.php @@ -20,7 +20,6 @@ namespace OCA\Onlyoffice; use OC\Files\Filesystem; - use OCP\Util; /** diff --git a/lib/listeners/directeditorlistener.php b/lib/listeners/directeditorlistener.php index afc9bb89..6bf9690e 100644 --- a/lib/listeners/directeditorlistener.php +++ b/lib/listeners/directeditorlistener.php @@ -22,7 +22,6 @@ use OCA\Onlyoffice\AppConfig; use OCA\Onlyoffice\DirectEditor; use OCP\DirectEditing\RegisterDirectEditorEvent; - use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; diff --git a/lib/listeners/filesharinglistener.php b/lib/listeners/filesharinglistener.php index 146cee41..26c59e22 100644 --- a/lib/listeners/filesharinglistener.php +++ b/lib/listeners/filesharinglistener.php @@ -24,9 +24,7 @@ use OCA\Onlyoffice\SettingsData; use OCP\AppFramework\Services\IInitialState; use OCP\EventDispatcher\Event; - use OCP\EventDispatcher\IEventListener; - use OCP\IServerContainer; use OCP\Util; diff --git a/lib/listeners/fileslistener.php b/lib/listeners/fileslistener.php index bb9d8928..9f3aa569 100644 --- a/lib/listeners/fileslistener.php +++ b/lib/listeners/fileslistener.php @@ -24,9 +24,7 @@ use OCA\Onlyoffice\SettingsData; use OCP\AppFramework\Services\IInitialState; use OCP\EventDispatcher\Event; - use OCP\EventDispatcher\IEventListener; - use OCP\IServerContainer; use OCP\Util; diff --git a/lib/listeners/viewerlistener.php b/lib/listeners/viewerlistener.php index d4624795..9d478676 100644 --- a/lib/listeners/viewerlistener.php +++ b/lib/listeners/viewerlistener.php @@ -25,9 +25,7 @@ use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Services\IInitialState; use OCP\EventDispatcher\Event; - use OCP\EventDispatcher\IEventListener; - use OCP\IServerContainer; use OCP\Util; diff --git a/lib/listeners/widgetlistener.php b/lib/listeners/widgetlistener.php index 4ccc7258..e8e80956 100644 --- a/lib/listeners/widgetlistener.php +++ b/lib/listeners/widgetlistener.php @@ -23,7 +23,6 @@ use OCP\Dashboard\RegisterWidgetEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; - use OCP\Util; /** diff --git a/lib/preview.php b/lib/preview.php index 5b280035..b2279d67 100644 --- a/lib/preview.php +++ b/lib/preview.php @@ -21,7 +21,6 @@ use OC\Files\View; use OC\Preview\Provider; - use OCA\Files_Sharing\External\Storage as SharingExternalStorage; use OCA\Files_Versions\Versions\IVersionManager; use OCP\AppFramework\QueryException; @@ -31,7 +30,6 @@ use OCP\ILogger; use OCP\Image; use OCP\ISession; - use OCP\IURLGenerator; use OCP\Share\IManager; diff --git a/lib/remoteinstance.php b/lib/remoteinstance.php index 55422a06..996bd3ed 100644 --- a/lib/remoteinstance.php +++ b/lib/remoteinstance.php @@ -20,7 +20,6 @@ namespace OCA\Onlyoffice; use OCA\Files_Sharing\External\Storage as SharingExternalStorage; - use OCP\Files\File; /** diff --git a/lib/templatemanager.php b/lib/templatemanager.php index d8605ef5..80a47f94 100644 --- a/lib/templatemanager.php +++ b/lib/templatemanager.php @@ -20,7 +20,6 @@ namespace OCA\Onlyoffice; use OCP\Files\File; - use OCP\Files\NotFoundException; /** From 61f572960adb4c8c47660c28df15e439686e3602 Mon Sep 17 00:00:00 2001 From: Kseniya Fedoruk Date: Mon, 16 Oct 2023 14:07:18 +0300 Subject: [PATCH 029/209] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 51e38915..4f3fbb03 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,8 @@ When the _Log-in credentials, save in session_ authentication type is used, the ``` To disable this check running, enter 0 value. +* When accessing a document without download permission, file printing and using the system clipboard are not available. Copying and pasting within the editor is available via buttons in the editor toolbar and in the context menu. + ## ONLYOFFICE Docs editions ONLYOFFICE offers different versions of its online document editors that can be deployed on your own servers. From daef648aeb3a79b4000cad873feba6cb34e6cac5 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Mon, 16 Oct 2023 15:49:29 +0300 Subject: [PATCH 030/209] format --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4f3fbb03..b12ff56f 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ When the _Log-in credentials, save in session_ authentication type is used, the You can check the '**Disable certificate verification (insecure)**' box on the ONLYOFFICE administration page, Server settings section, within your Nextcloud. Another option is to change the Nextcloud config file manually. Locate the Nextcloud config file (_/nextcloud/config/config.php_) and open it. Insert the following section to it: - + ```php 'onlyoffice' => array ( 'verify_peer_off' => true @@ -176,7 +176,7 @@ When the _Log-in credentials, save in session_ authentication type is used, the ) ``` To disable this check running, enter 0 value. - + * When accessing a document without download permission, file printing and using the system clipboard are not available. Copying and pasting within the editor is available via buttons in the editor toolbar and in the context menu. ## ONLYOFFICE Docs editions From efa5883c2334a48470b1c2dc94415ff96907f939 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Mon, 6 Nov 2023 13:56:12 +0300 Subject: [PATCH 031/209] Fix log comment --- controller/editorcontroller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 6e475945..48d79f10 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -1079,7 +1079,7 @@ public function url($filePath) { return ["error" => $this->trans->t("File not found")]; } if (!$file->isReadable()) { - $this->logger->error("Folder for saving file without permission: $filePath", ["app" => $this->appName]); + $this->logger->error("File without permission: $filePath", ["app" => $this->appName]); return ["error" => $this->trans->t("You do not have enough permissions to view the file")]; } From 7a12de660001ca497845edf32fed7fc9eaba08c8 Mon Sep 17 00:00:00 2001 From: TUCAOEVER <43756134+TUCAOEVER@users.noreply.github.com> Date: Tue, 7 Nov 2023 09:15:37 +0800 Subject: [PATCH 032/209] zh_CN updated --- l10n/zh_CN.js | 42 +++++++++++++++++++++--------------------- l10n/zh_CN.json | 46 +++++++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/l10n/zh_CN.js b/l10n/zh_CN.js index 03e8b2f5..b4e87a56 100644 --- a/l10n/zh_CN.js +++ b/l10n/zh_CN.js @@ -2,24 +2,24 @@ OC.L10N.register( "onlyoffice", { "Access denied" : "禁止访问", - "Invalid request" : "非法请求", + "Invalid request" : "无效请求", "Files not found" : "文件未找到", "File not found" : "文件未找到", "Not permitted" : "没有权限", "Download failed" : "下载失败", - "The required folder was not found" : "必须的文件夹未找到", - "You don't have enough permission to create" : "没有足够权限创建文件", + "The required folder was not found" : "未找到所需文件夹", + "You don't have enough permission to create" : "没有足够权限创建文档", "Template not found" : "模板未找到", "Can't create file" : "无法创建文件", - "Format is not supported" : "文件格式不支持", - "Conversion is not required" : "无需文件转换", - "Failed to download converted file" : "转换后的文件下载失败", + "Format is not supported" : "格式不支持", + "Conversion is not required" : "无需转换", + "Failed to download converted file" : "无法下载转换后的文件", "ONLYOFFICE app is not configured. Please contact admin" : "ONLYOFFICE未配置,请联系管理员。", "FileId is empty" : "文件ID为空", "You do not have enough permissions to view the file" : "您没有足够权限浏览该文件", "Error occurred in the document service" : "文档服务内部发生异常", "Not supported version" : "不支持的版本", - "ONLYOFFICE cannot be reached. Please contact admin" : "ONLYOFFICE服务器无法连接,请联系管理员。", + "ONLYOFFICE cannot be reached. Please contact admin" : "ONLYOFFICE 服务器无法连接,请联系管理员。", "Loading, please wait." : "载入中,请稍后...", "File created" : "文件已创建", "Open in ONLYOFFICE" : "用 ONLYOFFICE 打开", @@ -27,7 +27,7 @@ OC.L10N.register( "New document" : "新建文档", "New spreadsheet" : "新建表格", "New presentation" : "新建幻灯片", - "Error when trying to connect" : "连接是发生异常", + "Error when trying to connect" : "连接时发生异常", "Settings have been successfully updated" : "设置已保存", "Server can't read xml" : "服务器无法读取XML", "Bad Response. Errors: " : "错误的返回: ", @@ -35,10 +35,10 @@ OC.L10N.register( "ONLYOFFICE Docs Location specifies the address of the server with the document services installed. Please change the '' for the server address in the below line." : "ONLYOFFICE Docs 位置指定了安装了文档服务的服务器的地址,请将''改为下面一行中的服务器地址。", "ONLYOFFICE Docs address" : "ONLYOFFICE Docs地址", "Advanced server settings" : "更多设置", - "ONLYOFFICE Docs address for internal requests from the server" : "用于服务器内部的ONLYOFFICE Docs的地址", - "Server address for internal requests from ONLYOFFICE Docs" : "用于ONLYOFFICE Docs内部请求的服务器的地址", + "ONLYOFFICE Docs address for internal requests from the server" : "服务器内部请求 ONLYOFFICE Docs 的地址", + "Server address for internal requests from ONLYOFFICE Docs" : "ONLYOFFICE Docs 内部请求服务器的地址", "Secret key (leave blank to disable)" : "秘钥(留空为关闭)", - "Open file in the same tab" : "在相同的切签中打开", + "Open file in the same tab" : "在相同的标签页中打开", "The default application for opening the format": "默认关联的文件格式", "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "默认的文件编辑器 (由于文件格式限制,保存为下列格式时,数据可能会缺失)", "View details" : "查看详情", @@ -58,14 +58,14 @@ OC.L10N.register( "File saved" : "文件已保存", "Insert image" : "插入图片", "Select recipients" : "选择接收者", - "Connect to demo ONLYOFFICE Docs server" : "连接到 ONLYOFFICE Docs 服务器的演示", - "This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period." : "这是公开的测试服务器,请勿用于隐私数据。服务器试用期限为30天。", - "The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server." : "30天试用期已结束,无法连接ONLYOFFICE Docs 服务器的演示。", - "You are using public demo ONLYOFFICE Docs server. Please do not store private sensitive data." : "您正在使用公开ONLYOFFICE Docs服务器的演示,请勿存储隐私数据。", - "Secure view enables you to secure documents by embedding a watermark" : "启用安全视图可通过水印来保障文档安全", + "Connect to demo ONLYOFFICE Docs server" : "连接到 ONLYOFFICE Docs 演示服务器", + "This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period." : "这是公开的测试服务器,请勿存储隐私数据。服务器试用期限为30天。", + "The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server." : "30天试用期已结束,无法连接ONLYOFFICE Docs 演示服务器。", + "You are using public demo ONLYOFFICE Docs server. Please do not store private sensitive data." : "您正在使用 ONLYOFFICE Docs 公开的演示服务器,请勿存储隐私数据。", + "Secure view enables you to secure documents by embedding a watermark" : "启用安全视图以通过水印来保障文档安全", "Enable watermarking" : "启用水印", "Watermark text" : "水印文本", - "DO NOT SHARE THIS" : "请勿散播此文件", + "DO NOT SHARE THIS" : "请勿分享此文件", "Show watermark on tagged files" : "在标记的文件上展示水印", "Show watermark for users of groups" : "在组内用户中展示水印", "Supported placeholders" : "支持的占位符", @@ -73,8 +73,8 @@ OC.L10N.register( "Show watermark for read only shares" : "在只读共享中展示水印", "Link shares" : "分享链接", "Show watermark for all link shares" : "在分享链接中展示水印", - "Show watermark for download hidden shares" : "在隐藏的下载分享链接中展示水印", - "Show watermark for read only link shares" : "在只读分享链接中展示水印", + "Show watermark for download hidden shares" : "在下载的隐藏分享文件中展示水印", + "Show watermark for read only link shares" : "在只读的分享链接中展示水印", "Show watermark on link shares with specific system tags" : "在有特定系统标签的分享链接中展示水印", "Select tag" : "选择标签", "Select file to compare" : "选择文件比较", @@ -104,12 +104,12 @@ OC.L10N.register( "File has been converted. Its content might look different.": "文件已被转换。其内容可能看起来有所不同。", "Download as": "下载为", "Download": "下载", - "Origin format": "原产地格式", + "Origin format": "原格式", "Failed to send notification": "发送通知失败", "Notification sent successfully": "通知发送成功", "%1\$s mentioned in the %2\$s: \"%3\$s\".": "%1\$s 提到 %2\$s: \"%3\$s\".", "{notifier} mentioned in the {file}: \"%1\$s\".": "{notifier} 在 {file}: \"%1\$s\"中提到了您.", - "Choose a format to convert {fileName}": "选择要转换{fileName}的格式", + "Choose a format to convert {fileName}": "转换 {fileName} 为选中的格式", "New form template": "新表单模板", "Blank": "空白", "From text document": "从文本文件", diff --git a/l10n/zh_CN.json b/l10n/zh_CN.json index cfbf243e..f25b522f 100644 --- a/l10n/zh_CN.json +++ b/l10n/zh_CN.json @@ -1,23 +1,23 @@ { "translations": { "Access denied" : "禁止访问", - "Invalid request" : "非法请求", + "Invalid request" : "无效请求", "Files not found" : "文件未找到", "File not found" : "文件未找到", "Not permitted" : "没有权限", "Download failed" : "下载失败", - "The required folder was not found" : "必须的文件夹未找到", - "You don't have enough permission to create" : "没有足够权限创建文件", + "The required folder was not found" : "未找到所需文件夹", + "You don't have enough permission to create" : "没有足够权限创建文档", "Template not found" : "模板未找到", "Can't create file" : "无法创建文件", - "Format is not supported" : "文件格式不支持", - "Conversion is not required" : "无需文件转换", - "Failed to download converted file" : "转换后的文件下载失败", + "Format is not supported" : "格式不支持", + "Conversion is not required" : "无需转换", + "Failed to download converted file" : "无法下载转换后的文件", "ONLYOFFICE app is not configured. Please contact admin" : "ONLYOFFICE未配置,请联系管理员。", "FileId is empty" : "文件ID为空", "You do not have enough permissions to view the file" : "您没有足够权限浏览该文件", "Error occurred in the document service" : "文档服务内部发生异常", "Not supported version" : "不支持的版本", - "ONLYOFFICE cannot be reached. Please contact admin" : "ONLYOFFICE服务器无法连接,请联系管理员。", + "ONLYOFFICE cannot be reached. Please contact admin" : "ONLYOFFICE 服务器无法连接,请联系管理员。", "Loading, please wait." : "载入中,请稍后...", "File created" : "文件已创建", "Open in ONLYOFFICE" : "用 ONLYOFFICE 打开", @@ -25,7 +25,7 @@ "New document" : "新建文档", "New spreadsheet" : "新建表格", "New presentation" : "新建幻灯片", - "Error when trying to connect" : "连接是发生异常", + "Error when trying to connect" : "连接时发生异常", "Settings have been successfully updated" : "设置已保存", "Server can't read xml" : "服务器无法读取XML", "Bad Response. Errors: " : "错误的返回: ", @@ -33,10 +33,10 @@ "ONLYOFFICE Docs Location specifies the address of the server with the document services installed. Please change the '' for the server address in the below line." : "ONLYOFFICE Docs 位置指定了安装了文档服务的服务器的地址,请将''改为下面一行中的服务器地址。", "ONLYOFFICE Docs address" : "ONLYOFFICE Docs地址", "Advanced server settings" : "更多设置", - "ONLYOFFICE Docs address for internal requests from the server" : "用于服务器内部的ONLYOFFICE Docs的地址", - "Server address for internal requests from ONLYOFFICE Docs" : "用于ONLYOFFICE Docs内部请求的服务器的地址", + "ONLYOFFICE Docs address for internal requests from the server" : "服务器内部请求 ONLYOFFICE Docs 的地址", + "Server address for internal requests from ONLYOFFICE Docs" : "ONLYOFFICE Docs 内部请求服务器的地址", "Secret key (leave blank to disable)" : "秘钥(留空为关闭)", - "Open file in the same tab" : "在相同的切签中打开", + "Open file in the same tab" : "在相同的标签页中打开", "The default application for opening the format": "默认关联的文件格式", "Open the file for editing (due to format restrictions, the data might be lost when saving to the formats from the list below)" : "默认的文件编辑器 (由于文件格式限制,保存为下列格式时,数据可能会缺失)", "View details" : "查看详情", @@ -56,23 +56,23 @@ "File saved" : "文件已保存", "Insert image" : "插入图片", "Select recipients" : "选择接收者", - "Connect to demo ONLYOFFICE Docs server" : "连接到 ONLYOFFICE Docs 服务器的演示", - "This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period.": "这是公开的测试服务器,请勿用于隐私数据。服务器试用期限为30天。", - "The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server." : "30天试用期已结束,无法连接ONLYOFFICE Docs 服务器的演示。", - "You are using public demo ONLYOFFICE Docs server. Please do not store private sensitive data." : "您正在使用公开ONLYOFFICE Docs服务器的演示,请勿存储隐私数据。", - "Secure view enables you to secure documents by embedding a watermark" : "启用安全视图可通过水印来保障文档安全", + "Connect to demo ONLYOFFICE Docs server" : "连接到 ONLYOFFICE Docs 演示服务器", + "This is a public test server, please do not use it for private sensitive data. The server will be available during a 30-day period.": "这是公开的测试服务器,请勿存储隐私数据。服务器试用期限为30天。", + "The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server." : "30天试用期已结束,无法连接ONLYOFFICE Docs 演示服务器。", + "You are using public demo ONLYOFFICE Docs server. Please do not store private sensitive data." : "您正在使用 ONLYOFFICE Docs 公开的演示服务器,请勿存储隐私数据。", + "Secure view enables you to secure documents by embedding a watermark" : "启用安全视图以通过水印来保障文档安全", "Enable watermarking" : "启用水印", "Watermark text" : "水印文本", - "DO NOT SHARE THIS" : "请勿散播此文件", + "DO NOT SHARE THIS" : "请勿分享此文件", "Show watermark on tagged files" : "在标记的文件上展示水印", "Show watermark for users of groups" : "在组内用户中展示水印", "Supported placeholders" : "支持的占位符", - "Show watermark for all shares" : "在所有的共享中展示水印", - "Show watermark for read only shares" : "在只读共享中展示水印", + "Show watermark for all shares" : "在所有的分享中展示水印", + "Show watermark for read only shares" : "在只读分享中展示水印", "Link shares" : "分享链接", "Show watermark for all link shares" : "在分享链接中展示水印", - "Show watermark for download hidden shares" : "在隐藏的下载分享链接中展示水印", - "Show watermark for read only link shares" : "在只读分享链接中展示水印", + "Show watermark for download hidden shares" : "在下载的隐藏分享文件中展示水印", + "Show watermark for read only link shares" : "在只读的分享链接中展示水印", "Show watermark on link shares with specific system tags" : "在有特定系统标签的分享链接中展示水印", "Select tag" : "选择标签", "Select file to compare" : "选择文件比较", @@ -102,12 +102,12 @@ "File has been converted. Its content might look different.": "文件已被转换。其内容可能看起来有所不同。", "Download as": "下载为", "Download": "下载", - "Origin format": "原产地格式", + "Origin format": "原格式", "Failed to send notification": "发送通知失败", "Notification sent successfully": "通知发送成功", "%1$s mentioned in the %2$s: \"%3$s\".": "%1$s 提到 %2$s: \"%3$s\".", "{notifier} mentioned in the {file}: \"%1$s\".": "{notifier} 在 {file}: \"%1$s\"中提到了您.", - "Choose a format to convert {fileName}": "选择要转换{fileName}的格式", + "Choose a format to convert {fileName}": "转换 {fileName} 为选中的格式", "New form template": "新表单模板", "Blank": "空白", "From text document": "从文本文件", From e889c45de2aaffad5e51114ba6ae3e2367cacd9a Mon Sep 17 00:00:00 2001 From: Git'Fellow <12234510+solracsf@users.noreply.github.com> Date: Sun, 12 Nov 2023 22:36:21 +0100 Subject: [PATCH 033/209] Import ShareNotFound namespace --- lib/FileUtility.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FileUtility.php b/lib/FileUtility.php index 1da46e9a..247e1e07 100644 --- a/lib/FileUtility.php +++ b/lib/FileUtility.php @@ -25,6 +25,7 @@ use OCP\IL10N; use OCP\ILogger; use OCP\ISession; +use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager; use OCA\Onlyoffice\AppConfig; @@ -187,7 +188,6 @@ public function getShare($shareToken) { return [null, $this->trans->t("FileId is empty")]; } - $share = null; try { $share = $this->shareManager->getShareByToken($shareToken); } catch (ShareNotFound $e) { From 9287255af87873d4a066681911b5ceab6b8793c5 Mon Sep 17 00:00:00 2001 From: rivexe Date: Tue, 14 Nov 2023 11:09:33 +0300 Subject: [PATCH 034/209] if jwt header is used, show advanced settings --- js/settings.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/settings.js b/js/settings.js index 80978758..3d32d194 100644 --- a/js/settings.js +++ b/js/settings.js @@ -32,7 +32,8 @@ }; if ($("#onlyofficeInternalUrl").val().length - || $("#onlyofficeStorageUrl").val().length) { + || $("#onlyofficeStorageUrl").val().length + || $("#onlyofficeJwtHeader").val().length) { advToogle(); } From f7db14ba57f1369f0fe6333b8b443eef7883cf01 Mon Sep 17 00:00:00 2001 From: Stepan Mayorov Date: Tue, 14 Nov 2023 16:19:28 +0300 Subject: [PATCH 035/209] Update lint-phpcs.yml feature/nc-27 branch added to lint-phpcs.yml --- .github/workflows/lint-phpcs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-phpcs.yml b/.github/workflows/lint-phpcs.yml index 9ec5bd6b..75a9f9a7 100644 --- a/.github/workflows/lint-phpcs.yml +++ b/.github/workflows/lint-phpcs.yml @@ -5,7 +5,7 @@ on: push: branches: [master] pull_request: - branches: [master, develop] + branches: [master, develop, feature/nc-27] permissions: contents: read From 7865de2d3aaf3647ef0dd80b5ac88c2bd02d3cba Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Sat, 18 Nov 2023 18:48:05 +0300 Subject: [PATCH 036/209] fixed loader when creating file --- js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index ef064643..35aa7b28 100644 --- a/js/main.js +++ b/js/main.js @@ -33,8 +33,8 @@ var dir = fileList.getCurrentDirectory(); if ((!OCA.Onlyoffice.setting.sameTab || OCA.Onlyoffice.mobile || OCA.Onlyoffice.Desktop) && open) { - $loaderUrl = OCA.Onlyoffice.Desktop ? "" : OC.filePath(OCA.Onlyoffice.AppName, "templates", "loader.html"); - var winEditor = window.open($loaderUrl); + var loaderUrl = OCA.Onlyoffice.Desktop ? "" : OC.filePath(OCA.Onlyoffice.AppName, "templates", "loader.html"); + var winEditor = window.open(loaderUrl); } var createData = { From 04b12d6a1dc0f3c107057f1f282d0586fa2c6fec Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Wed, 15 Nov 2023 16:46:05 +0300 Subject: [PATCH 037/209] allowInlineScript is deprecated --- controller/editorcontroller.php | 1 - lib/directeditor.php | 1 - 2 files changed, 2 deletions(-) diff --git a/controller/editorcontroller.php b/controller/editorcontroller.php index 48d79f10..25d7e919 100644 --- a/controller/editorcontroller.php +++ b/controller/editorcontroller.php @@ -1270,7 +1270,6 @@ public function index($fileId, $filePath = null, $shareToken = null, $version = \OCP\Util::addHeader("meta", ["name" => "apple-touch-fullscreen", "content" => "yes"]); $csp = new ContentSecurityPolicy(); - $csp->allowInlineScript(true); if (preg_match("/^https?:\/\//i", $documentServerUrl)) { $csp->addAllowedScriptDomain($documentServerUrl); diff --git a/lib/directeditor.php b/lib/directeditor.php index 67c9c574..97607732 100644 --- a/lib/directeditor.php +++ b/lib/directeditor.php @@ -247,7 +247,6 @@ public function open(IToken $token): Response { $response = new TemplateResponse($this->appName, "editor", $params, "base"); $csp = new ContentSecurityPolicy(); - $csp->allowInlineScript(true); if (preg_match("/^https?:\/\//i", $documentServerUrl)) { $csp->addAllowedScriptDomain($documentServerUrl); From 2164b0da2ba2988bc363f35e52ebc6ce17335dba Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Mon, 13 Nov 2023 18:11:32 +0300 Subject: [PATCH 038/209] changed listener registration for file created from template --- lib/AppInfo/Application.php | 22 +-------- lib/Listeners/CreateFromTemplateListener.php | 47 ++++++++++++++++++++ 2 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 lib/Listeners/CreateFromTemplateListener.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 07068b7d..0b1ebaaf 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -47,6 +47,7 @@ use OCA\Onlyoffice\Controller\SharingApiController; use OCA\Onlyoffice\Controller\SettingsController; use OCA\Onlyoffice\Controller\TemplateController; +use OCA\Onlyoffice\Listeners\CreateFromTemplateListener; use OCA\Onlyoffice\Listeners\FilesListener; use OCA\Onlyoffice\Listeners\FileSharingListener; use OCA\Onlyoffice\Listeners\DirectEditorListener; @@ -57,7 +58,6 @@ use OCA\Onlyoffice\Hooks; use OCA\Onlyoffice\Notifier; use OCA\Onlyoffice\Preview; -use OCA\Onlyoffice\TemplateManager; use OCA\Onlyoffice\TemplateProvider; use OCA\Onlyoffice\SettingsData; use Psr\Container\ContainerInterface; @@ -241,6 +241,7 @@ public function register(IRegistrationContext $context): void { ); }); + $context->registerEventListener(FileCreatedFromTemplateEvent::class, CreateFromTemplateListener::class); $context->registerEventListener(LoadAdditionalScriptsEvent::class, FilesListener::class); $context->registerEventListener(RegisterDirectEditorEvent::class, DirectEditorListener::class); $context->registerEventListener(LoadViewer::class, ViewerListener::class); @@ -276,25 +277,6 @@ public function register(IRegistrationContext $context): void { public function boot(IBootContext $context): void { - $context->injectFn(function (SymfonyAdapter $eventDispatcher) { - - if (class_exists("OCP\Files\Template\FileCreatedFromTemplateEvent")) { - $eventDispatcher->addListener( - FileCreatedFromTemplateEvent::class, - function (FileCreatedFromTemplateEvent $event) { - $template = $event->getTemplate(); - if ($template === null) { - $targetFile = $event->getTarget(); - $templateEmpty = TemplateManager::getEmptyTemplate($targetFile->getName()); - if ($templateEmpty) { - $targetFile->putContent($templateEmpty); - } - } - } - ); - } - }); - $context->injectFn(function (IManager $notificationsManager) { $notificationsManager->registerNotifierService(Notifier::class); }); diff --git a/lib/Listeners/CreateFromTemplateListener.php b/lib/Listeners/CreateFromTemplateListener.php new file mode 100644 index 00000000..11b66ea3 --- /dev/null +++ b/lib/Listeners/CreateFromTemplateListener.php @@ -0,0 +1,47 @@ +getTemplate(); + if ($template === null) { + $targetFile = $event->getTarget(); + $templateEmpty = TemplateManager::GetEmptyTemplate($targetFile->getName()); + if ($templateEmpty) { + $targetFile->putContent($templateEmpty); + } + } + } +} From 22ef6ebe34b073a10f9b18cf257cd5cc3a738bfe Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Thu, 16 Nov 2023 16:04:30 +0300 Subject: [PATCH 039/209] moved scripts to src --- {js => src}/desktop.js | 0 {js => src}/directeditor.js | 0 {js => src}/editor.js | 0 {js => src}/listener.js | 0 {js => src}/main.js | 0 {js => src}/settings.js | 0 {js => src}/share.js | 0 {js => src}/template.js | 0 {js => src}/viewer.js | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename {js => src}/desktop.js (100%) rename {js => src}/directeditor.js (100%) rename {js => src}/editor.js (100%) rename {js => src}/listener.js (100%) rename {js => src}/main.js (100%) rename {js => src}/settings.js (100%) rename {js => src}/share.js (100%) rename {js => src}/template.js (100%) rename {js => src}/viewer.js (100%) diff --git a/js/desktop.js b/src/desktop.js similarity index 100% rename from js/desktop.js rename to src/desktop.js diff --git a/js/directeditor.js b/src/directeditor.js similarity index 100% rename from js/directeditor.js rename to src/directeditor.js diff --git a/js/editor.js b/src/editor.js similarity index 100% rename from js/editor.js rename to src/editor.js diff --git a/js/listener.js b/src/listener.js similarity index 100% rename from js/listener.js rename to src/listener.js diff --git a/js/main.js b/src/main.js similarity index 100% rename from js/main.js rename to src/main.js diff --git a/js/settings.js b/src/settings.js similarity index 100% rename from js/settings.js rename to src/settings.js diff --git a/js/share.js b/src/share.js similarity index 100% rename from js/share.js rename to src/share.js diff --git a/js/template.js b/src/template.js similarity index 100% rename from js/template.js rename to src/template.js diff --git a/js/viewer.js b/src/viewer.js similarity index 100% rename from js/viewer.js rename to src/viewer.js From d904774615baee34047ee90e4e9490627f32cf3e Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Thu, 16 Nov 2023 17:06:46 +0300 Subject: [PATCH 040/209] added webpack --- package.json | 24 ++++++++++++++++++++++++ webpack.js | 16 ++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 package.json create mode 100644 webpack.js diff --git a/package.json b/package.json new file mode 100644 index 00000000..80726aae --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "onlyoffice", + "description": "ONLYOFFICE connector allows you to view, edit and collaborate on text documents, spreadsheets and presentations within Nextcloud using ONLYOFFICE Docs. This will create a new Edit in ONLYOFFICE action within the document library for Office documents. This allows multiple users to co-author documents in real time from the familiar web interface and save the changes back to your file storage.", + "version": "8.2.4", + "authors": [ + { + "name": "Ascensio System SIA", + "email": "dev@onlyoffice.com", + "role": "Developer" + } + ], + "license": "Apache-2.0", + "private": true, + "scripts": { + "build": "NODE_ENV=production webpack --progress --config webpack.js", + "dev": "NODE_ENV=development webpack --progress --config webpack.js" + }, + "dependencies": { + }, + "devDependencies": { + "@nextcloud/webpack-vue-config": "^6.0.0", + "@nextcloud/browserslist-config": "^3.0.0" + } +} \ No newline at end of file diff --git a/webpack.js b/webpack.js new file mode 100644 index 00000000..f2b3bc01 --- /dev/null +++ b/webpack.js @@ -0,0 +1,16 @@ +const path = require('path'); +const webpackConfig = require('@nextcloud/webpack-vue-config'); + +webpackConfig.entry = { + desktop: path.join(__dirname, 'src', 'desktop.js'), + directeditor: path.join(__dirname, 'src', 'directeditor.js'), + editor: path.join(__dirname, 'src', 'editor.js'), + listener: path.join(__dirname, 'src', 'listener.js'), + main: path.join(__dirname, 'src', 'main.js'), + settings: path.join(__dirname, 'src', 'settings.js'), + share: path.join(__dirname, 'src', 'share.js'), + template: path.join(__dirname, 'src', 'template.js'), + viewer: path.join(__dirname, 'src', 'viewer.js') +}; + +module.exports = webpackConfig; \ No newline at end of file From b9643a385a1bd173f8d924b278d5a34c0b0b003a Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Thu, 16 Nov 2023 17:07:42 +0300 Subject: [PATCH 041/209] added prefix to scripts --- lib/Listeners/FileSharingListener.php | 4 ++-- lib/Listeners/FilesListener.php | 10 +++++----- lib/Listeners/ViewerListener.php | 4 ++-- lib/Listeners/WidgetListener.php | 2 +- templates/editor.php | 6 +++--- templates/settings.php | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/Listeners/FileSharingListener.php b/lib/Listeners/FileSharingListener.php index 26c59e22..1a66b3bc 100644 --- a/lib/Listeners/FileSharingListener.php +++ b/lib/Listeners/FileSharingListener.php @@ -76,10 +76,10 @@ public function handle(Event $event): void { if (!empty($this->appConfig->getDocumentServerUrl()) && $this->appConfig->settingsAreSuccessful()) { - Util::addScript("onlyoffice", "main"); + Util::addScript("onlyoffice", "onlyoffice-main"); if ($this->appConfig->getSameTab()) { - Util::addScript("onlyoffice", "listener"); + Util::addScript("onlyoffice", "onlyoffice-listener"); } $container = $this->serverContainer; diff --git a/lib/Listeners/FilesListener.php b/lib/Listeners/FilesListener.php index 9f3aa569..9047e84e 100644 --- a/lib/Listeners/FilesListener.php +++ b/lib/Listeners/FilesListener.php @@ -77,17 +77,17 @@ public function handle(Event $event): void { if (!empty($this->appConfig->getDocumentServerUrl()) && $this->appConfig->settingsAreSuccessful() && $this->appConfig->isUserAllowedToUse()) { - Util::addScript("onlyoffice", "desktop"); - Util::addScript("onlyoffice", "main"); - Util::addScript("onlyoffice", "template"); + Util::addScript("onlyoffice", "onlyoffice-desktop"); + Util::addScript("onlyoffice", "onlyoffice-main"); + Util::addScript("onlyoffice", "onlyoffice-template"); if ($this->appConfig->getSameTab()) { - Util::addScript("onlyoffice", "listener"); + Util::addScript("onlyoffice", "onlyoffice-listener"); } if ($this->appConfig->getAdvanced() && \OC::$server->getAppManager()->isInstalled("files_sharing")) { - Util::addScript("onlyoffice", "share"); + Util::addScript("onlyoffice", "onlyoffice-share"); Util::addStyle("onlyoffice", "share"); } diff --git a/lib/Listeners/ViewerListener.php b/lib/Listeners/ViewerListener.php index 9d478676..524ac341 100644 --- a/lib/Listeners/ViewerListener.php +++ b/lib/Listeners/ViewerListener.php @@ -78,8 +78,8 @@ public function handle(Event $event): void { if (!empty($this->appConfig->getDocumentServerUrl()) && $this->appConfig->settingsAreSuccessful() && $this->appConfig->isUserAllowedToUse()) { - Util::addScript("onlyoffice", "viewer", "viewer"); - Util::addScript("onlyoffice", "listener", "viewer"); + Util::addScript("onlyoffice", "onlyoffice-viewer", "viewer"); + Util::addScript("onlyoffice", "onlyoffice-listener", "viewer"); Util::addStyle("onlyoffice", "viewer"); diff --git a/lib/Listeners/WidgetListener.php b/lib/Listeners/WidgetListener.php index e8e80956..3e5ba49a 100644 --- a/lib/Listeners/WidgetListener.php +++ b/lib/Listeners/WidgetListener.php @@ -52,7 +52,7 @@ public function handle(Event $event): void { if (!empty($this->appConfig->getDocumentServerUrl()) && $this->appConfig->settingsAreSuccessful() && $this->appConfig->isUserAllowedToUse()) { - Util::addScript("onlyoffice", "desktop"); + Util::addScript("onlyoffice", "onlyoffice-desktop"); } } } diff --git a/templates/editor.php b/templates/editor.php index 112dc071..4d4b5a7d 100644 --- a/templates/editor.php +++ b/templates/editor.php @@ -18,10 +18,10 @@ */ style("onlyoffice", "editor"); - script("onlyoffice", "desktop"); - script("onlyoffice", "editor"); + script("onlyoffice", "onlyoffice-desktop"); + script("onlyoffice", "onlyoffice-editor"); if (!empty($_["directToken"])) { - script("onlyoffice", "directeditor"); + script("onlyoffice", "onlyoffice-directeditor"); } ?> diff --git a/templates/settings.php b/templates/settings.php index fc66cab2..75fe1355 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -19,8 +19,8 @@ style("onlyoffice", "settings"); style("onlyoffice", "template"); - script("onlyoffice", "settings"); - script("onlyoffice", "template"); + script("onlyoffice", "onlyoffice-settings"); + script("onlyoffice", "onlyoffice-template"); if ($_["tagsEnabled"]) { script("core", [ From ba2224e2ca106ed4dc68bb227b16ef74c211a602 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 28 Nov 2023 17:22:15 +0300 Subject: [PATCH 042/209] format --- js/editor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/editor.js b/js/editor.js index 43978446..2933af32 100644 --- a/js/editor.js +++ b/js/editor.js @@ -183,7 +183,7 @@ config.events.onRequestHistory = OCA.Onlyoffice.onRequestHistory; config.events.onRequestHistoryData = OCA.Onlyoffice.onRequestHistoryData; config.events.onRequestRestore = OCA.Onlyoffice.onRequestRestore; - + if (!OCA.Onlyoffice.version) { config.events.onRequestHistoryClose = OCA.Onlyoffice.onRequestHistoryClose; } From ef95ba9893904c8b24487c98a649e7a4cbf6274e Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Fri, 24 Nov 2023 18:14:16 +0300 Subject: [PATCH 043/209] webpack to CHANGELOG --- CHANGELOG.md | 3 +++ package.json | 9 ++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b3046c1..8d76f1b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## Changed +- added webpack build + ## 8.2.4 ## Changed - remove link to docs cloud diff --git a/package.json b/package.json index 80726aae..b98153b9 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,9 @@ "name": "onlyoffice", "description": "ONLYOFFICE connector allows you to view, edit and collaborate on text documents, spreadsheets and presentations within Nextcloud using ONLYOFFICE Docs. This will create a new Edit in ONLYOFFICE action within the document library for Office documents. This allows multiple users to co-author documents in real time from the familiar web interface and save the changes back to your file storage.", "version": "8.2.4", - "authors": [ - { - "name": "Ascensio System SIA", - "email": "dev@onlyoffice.com", - "role": "Developer" - } - ], + "author": "Ascensio System SIA (https://www.onlyoffice.com)", "license": "Apache-2.0", + "homepage": "https://www.onlyoffice.com", "private": true, "scripts": { "build": "NODE_ENV=production webpack --progress --config webpack.js", From 58c79cd8ca5eef247e84d3deb861042c31d1ae35 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Thu, 16 Nov 2023 19:19:47 +0300 Subject: [PATCH 044/209] added file open action --- package.json | 4 +- src/main.js | 121 +++++++++++++++++++++++++++++++-------------------- 2 files changed, 76 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index b98153b9..9dfb4264 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,11 @@ "dev": "NODE_ENV=development webpack --progress --config webpack.js" }, "dependencies": { + "@nextcloud/files": "^3.0.0" }, "devDependencies": { "@nextcloud/webpack-vue-config": "^6.0.0", - "@nextcloud/browserslist-config": "^3.0.0" + "@nextcloud/browserslist-config": "^3.0.0", + "raw-loader": "^4.0.2" } } \ No newline at end of file diff --git a/src/main.js b/src/main.js index ef064643..80fdb39d 100644 --- a/src/main.js +++ b/src/main.js @@ -16,6 +16,9 @@ * */ +import { FileAction, registerFileAction, FileType, Permission, DefaultType } from "@nextcloud/files"; +import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; + (function (OCA) { OCA.Onlyoffice = _.extend({ @@ -322,61 +325,83 @@ if (!config.mime) { return true; } - OCA.Files.fileActions.registerAction({ - name: "onlyofficeOpen", - displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"), - mime: config.mime, - permissions: OC.PERMISSION_READ, - iconClass: "icon-onlyoffice-open", - actionHandler: OCA.Onlyoffice.FileClick - }); - - if (config.def) { - OCA.Files.fileActions.setDefault(config.mime, "onlyofficeOpen"); - } - - if (config.conv) { - OCA.Files.fileActions.registerAction({ - name: "onlyofficeConvert", - displayName: t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"), - mime: config.mime, - permissions: ($("#isPublic").val() ? OC.PERMISSION_UPDATE : OC.PERMISSION_READ), - iconClass: "icon-onlyoffice-convert", - actionHandler: OCA.Onlyoffice.FileConvertClick - }); - } - if (config.fillForms) { + if (OCA.Files && OCA.Files.fileActions) { OCA.Files.fileActions.registerAction({ - name: "onlyofficeFill", - displayName: t(OCA.Onlyoffice.AppName, "Fill in form in ONLYOFFICE"), + name: "onlyofficeOpen", + displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"), mime: config.mime, - permissions: OC.PERMISSION_UPDATE, - iconClass: "icon-onlyoffice-fill", + permissions: OC.PERMISSION_READ, + iconClass: "icon-onlyoffice-open", actionHandler: OCA.Onlyoffice.FileClick }); - } - if (config.createForm) { - OCA.Files.fileActions.registerAction({ - name: "onlyofficeCreateForm", - displayName: t(OCA.Onlyoffice.AppName, "Create form"), - mime: config.mime, - permissions: ($("#isPublic").val() ? OC.PERMISSION_UPDATE : OC.PERMISSION_READ), - iconClass: "icon-onlyoffice-create", - actionHandler: OCA.Onlyoffice.CreateFormClick - }); - } + if (config.def) { + OCA.Files.fileActions.setDefault(config.mime, "onlyofficeOpen"); + } - if (config.saveas && !$("#isPublic").val()) { - OCA.Files.fileActions.registerAction({ - name: "onlyofficeDownload", - displayName: t(OCA.Onlyoffice.AppName, "Download as"), - mime: config.mime, - permissions: OC.PERMISSION_READ, - iconClass: "icon-onlyoffice-download", - actionHandler: OCA.Onlyoffice.DownloadClick - }); + if (config.conv) { + OCA.Files.fileActions.registerAction({ + name: "onlyofficeConvert", + displayName: t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"), + mime: config.mime, + permissions: ($("#isPublic").val() ? OC.PERMISSION_UPDATE : OC.PERMISSION_READ), + iconClass: "icon-onlyoffice-convert", + actionHandler: OCA.Onlyoffice.FileConvertClick + }); + } + + if (config.fillForms) { + OCA.Files.fileActions.registerAction({ + name: "onlyofficeFill", + displayName: t(OCA.Onlyoffice.AppName, "Fill in form in ONLYOFFICE"), + mime: config.mime, + permissions: OC.PERMISSION_UPDATE, + iconClass: "icon-onlyoffice-fill", + actionHandler: OCA.Onlyoffice.FileClick + }); + } + + if (config.createForm) { + OCA.Files.fileActions.registerAction({ + name: "onlyofficeCreateForm", + displayName: t(OCA.Onlyoffice.AppName, "Create form"), + mime: config.mime, + permissions: ($("#isPublic").val() ? OC.PERMISSION_UPDATE : OC.PERMISSION_READ), + iconClass: "icon-onlyoffice-create", + actionHandler: OCA.Onlyoffice.CreateFormClick + }); + } + + if (config.saveas && !$("#isPublic").val()) { + OCA.Files.fileActions.registerAction({ + name: "onlyofficeDownload", + displayName: t(OCA.Onlyoffice.AppName, "Download as"), + mime: config.mime, + permissions: OC.PERMISSION_READ, + iconClass: "icon-onlyoffice-download", + actionHandler: OCA.Onlyoffice.DownloadClick + }); + } + } else { + registerFileAction(new FileAction({ + id: "onlyoffice-open-" + ext, + displayName: () => t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"), + iconSvgInline: () => AppDarkSvg, + enabled: (files, view) => { + if (files[0]?.extension?.replace(".", "") == ext) + return true; + + return false; + }, + exec: async (file, view, dir) => { + var winEditor = !OCA.Onlyoffice.setting.sameTab ? document : null; + OCA.Onlyoffice.OpenEditor(file.fileid, dir, file.basename, 0, winEditor); + + return null; + }, + default: config.def ? DefaultType.HIDDEN : null + })); } }); }; From 9d1d4bee64ced57adbbd94230c6b6e82a46efe1a Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Sat, 18 Nov 2023 01:16:53 +0300 Subject: [PATCH 045/209] added convert file action --- src/main.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/src/main.js b/src/main.js index 80fdb39d..5a8144db 100644 --- a/src/main.js +++ b/src/main.js @@ -16,7 +16,8 @@ * */ -import { FileAction, registerFileAction, FileType, Permission, DefaultType } from "@nextcloud/files"; +import { FileAction, registerFileAction, FileType, Permission, DefaultType, File } from "@nextcloud/files"; +import { emit } from '@nextcloud/event-bus'; import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; (function (OCA) { @@ -181,9 +182,18 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; OCA.Onlyoffice.FileConvertClick = function (fileName, context) { var fileInfoModel = context.fileInfoModel || context.fileList.getModelForFile(fileName); var fileList = context.fileList; + var fileId = context.$file[0].dataset.id || fileInfoModel.id; + OCA.Onlyoffice.FileConvert(fileId, (response) => { + if (response.parentId == fileList.dirInfo.id) { + fileList.add(response, { animate: true }); + } + }); + }; + + OCA.Onlyoffice.FileConvert = function (fileId, callback) { var convertData = { - fileId: context.$file[0].dataset.id || fileInfoModel.id + fileId: fileId }; if ($("#isPublic").val()) { @@ -198,9 +208,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; return; } - if (response.parentId == fileList.dirInfo.id) { - fileList.add(response, { animate: true }); - } + callback(response); OCP.Toast.success(t(OCA.Onlyoffice.AppName, "File has been converted. Its content might look different.")); }); @@ -402,6 +410,41 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; }, default: config.def ? DefaultType.HIDDEN : null })); + + if (config.conv) { + registerFileAction(new FileAction({ + id: "onlyoffice-convert-" + ext, + displayName: () => t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"), + iconSvgInline: () => AppDarkSvg, + enabled: (files, view) => { + if (files[0]?.extension?.replace(".", "") == ext) + return true; + + return false; + }, + exec: async (file, view, dir) => { + OCA.Onlyoffice.FileConvert(file.fileid, async (response) => { + let viewContents = await view.getContents(dir); + + if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { + let newFile = viewContents.contents.find(node => node.fileid == response.id); + if (newFile) { + emit("files:node:created", new File({ + source: newFile.source, + id: newFile.fileid, + mtime: newFile.mtime, + mime: newFile.mime, + permissions: newFile.permissions, + size: newFile.size + })); + } + } + }); + + return null; + } + })); + } } }); }; From 061ed26850542b1dc3d87c7cbb9032cae0a662cb Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Sat, 18 Nov 2023 16:49:26 +0300 Subject: [PATCH 046/209] added fill form action --- src/main.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.js b/src/main.js index 5a8144db..7b695e73 100644 --- a/src/main.js +++ b/src/main.js @@ -445,6 +445,26 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; } })); } + + if (config.fillForms) { + registerFileAction(new FileAction({ + id: "onlyoffice-fill-" + ext, + displayName: () => t(OCA.Onlyoffice.AppName, "Fill in form in ONLYOFFICE"), + iconSvgInline: () => AppDarkSvg, + enabled: (files, view) => { + if (files[0]?.extension?.replace(".", "") == ext) + return true; + + return false; + }, + exec: async (file, view, dir) => { + var winEditor = !OCA.Onlyoffice.setting.sameTab ? document : null; + OCA.Onlyoffice.OpenEditor(file.fileid, dir, file.basename, 0, winEditor); + + return null; + } + })); + } } }); }; From 1b275a06f1d64ea876fd12138c5c55121680fb57 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Mon, 20 Nov 2023 13:32:26 +0300 Subject: [PATCH 047/209] added create form action --- src/main.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 7b695e73..bdbbf88a 100644 --- a/src/main.js +++ b/src/main.js @@ -33,8 +33,8 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; OCA.Onlyoffice.mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini|Macintosh/i.test(navigator.userAgent) && navigator.maxTouchPoints && navigator.maxTouchPoints > 1; - OCA.Onlyoffice.CreateFile = function (name, fileList, templateId, targetId, open = true) { - var dir = fileList.getCurrentDirectory(); + OCA.Onlyoffice.CreateFile = function (name, fileList, templateId, targetId, open = true, callback = null) { + var dir = fileList.getCurrentDirectory ? fileList.getCurrentDirectory() : fileList.dir; if ((!OCA.Onlyoffice.setting.sameTab || OCA.Onlyoffice.mobile || OCA.Onlyoffice.Desktop) && open) { $loaderUrl = OCA.Onlyoffice.Desktop ? "" : OC.filePath(OCA.Onlyoffice.AppName, "templates", "loader.html"); @@ -69,7 +69,14 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; return; } - fileList.add(response, { animate: true }); + if (fileList.add) { + fileList.add(response, { animate: true }); + } + + if (callback) { + callback(response); + } + if (open) { OCA.Onlyoffice.OpenEditor(response.id, dir, response.name, 0, winEditor); @@ -465,6 +472,47 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; } })); } + + if (config.createForm) { + registerFileAction(new FileAction({ + id: "onlyoffice-create-form-" + ext, + displayName: () => t(OCA.Onlyoffice.AppName, "Create form"), + iconSvgInline: () => AppDarkSvg, + enabled: (files, view) => { + if (files[0]?.extension?.replace(".", "") == ext) + return true; + + return false; + }, + exec: async (file, view, dir) => { + let fileList = { + dir: dir + }; + + var name = file.basename.replace(/\.[^.]+$/, ".oform"); + + OCA.Onlyoffice.CreateFile(name, fileList, 0, file.fileid, false, async (response) => { + let viewContents = await view.getContents(dir); + + if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { + let newFile = viewContents.contents.find(node => node.fileid == response.id); + if (newFile) { + emit("files:node:created", new File({ + source: newFile.source, + id: newFile.fileid, + mtime: newFile.mtime, + mime: newFile.mime, + permissions: newFile.permissions, + size: newFile.size + })); + } + } + }); + + return null; + } + })); + } } }); }; From f40276954dd95b8c0eb16f12e9e001b223f309d4 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Mon, 20 Nov 2023 13:42:38 +0300 Subject: [PATCH 048/209] added download as action --- src/main.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index bdbbf88a..bf83618a 100644 --- a/src/main.js +++ b/src/main.js @@ -222,6 +222,12 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; }; OCA.Onlyoffice.DownloadClick = function (fileName, context) { + var fileId = context.fileInfoModel.id; + + OCA.Onlyoffice.Download(fileName, fileId); + }; + + OCA.Onlyoffice.Download = function (fileName, fileId) { $.get(OC.filePath(OCA.Onlyoffice.AppName, "templates", "downloadPicker.html"), function (tmpl) { var dialog = $(tmpl).octemplate({ @@ -268,7 +274,6 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; classes: "primary", click: function() { var format = this.dataset.format; - var fileId = context.fileInfoModel.id; var downloadLink = OC.generateUrl("apps/" + OCA.Onlyoffice.AppName + "/downloadas?fileId={fileId}&toExtension={toExtension}",{ fileId: fileId, toExtension: format @@ -513,6 +518,25 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; } })); } + + if (config.saveas && !$("#isPublic").val()) { + registerFileAction(new FileAction({ + id: "onlyoffice-download-as-" + ext, + displayName: () => t(OCA.Onlyoffice.AppName, "Download as"), + iconSvgInline: () => AppDarkSvg, + enabled: (files, view) => { + if (files[0]?.extension?.replace(".", "") == ext) + return true; + + return false; + }, + exec: async (file, view, dir) => { + OCA.Onlyoffice.Download(file.basename, file.fileid); + + return null; + } + })); + } } }); }; From 6246f87da152ebdd1cdd54ef6d48412e069b9e76 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Mon, 20 Nov 2023 13:47:41 +0300 Subject: [PATCH 049/209] pass file object to emit --- src/main.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/main.js b/src/main.js index bf83618a..26acf635 100644 --- a/src/main.js +++ b/src/main.js @@ -440,16 +440,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { let newFile = viewContents.contents.find(node => node.fileid == response.id); - if (newFile) { - emit("files:node:created", new File({ - source: newFile.source, - id: newFile.fileid, - mtime: newFile.mtime, - mime: newFile.mime, - permissions: newFile.permissions, - size: newFile.size - })); - } + if (newFile) emit("files:node:created", new File(newFile)); } }); @@ -501,16 +492,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { let newFile = viewContents.contents.find(node => node.fileid == response.id); - if (newFile) { - emit("files:node:created", new File({ - source: newFile.source, - id: newFile.fileid, - mtime: newFile.mtime, - mime: newFile.mime, - permissions: newFile.permissions, - size: newFile.size - })); - } + if (newFile) emit("files:node:created", new File(newFile)); } }); From f35deea00a490d70acbafb7d7db4d34e3ae6ca77 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Mon, 20 Nov 2023 20:32:03 +0300 Subject: [PATCH 050/209] fileList is unused in the context (a3533c2716e356fd0e75bc4147d9c8579c1a4864) --- src/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 26acf635..1ba20961 100644 --- a/src/main.js +++ b/src/main.js @@ -80,9 +80,10 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; if (open) { OCA.Onlyoffice.OpenEditor(response.id, dir, response.name, 0, winEditor); - OCA.Onlyoffice.context = { fileList: fileList }; - OCA.Onlyoffice.context.fileName = response.name; - OCA.Onlyoffice.context.dir = dir; + OCA.Onlyoffice.context = { + fileName: response.name, + dir: dir + }; } OCP.Toast.success(t(OCA.Onlyoffice.AppName, "File created")); From a2ae6143541b249cf68ce145f11446e72c40ac1d Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Tue, 21 Nov 2023 10:56:15 +0300 Subject: [PATCH 051/209] separated file actions functions --- src/main.js | 104 ++++++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/src/main.js b/src/main.js index 1ba20961..d879e7c5 100644 --- a/src/main.js +++ b/src/main.js @@ -33,9 +33,15 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; OCA.Onlyoffice.mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini|Macintosh/i.test(navigator.userAgent) && navigator.maxTouchPoints && navigator.maxTouchPoints > 1; - OCA.Onlyoffice.CreateFile = function (name, fileList, templateId, targetId, open = true, callback = null) { - var dir = fileList.getCurrentDirectory ? fileList.getCurrentDirectory() : fileList.dir; + OCA.Onlyoffice.CreateFile = function (name, fileList, templateId, targetId, open = true) { + var dir = fileList.getCurrentDirectory(); + OCA.Onlyoffice.CreateFileProcess(name, dir, templateId, targetId, open, (response) => { + fileList.add(response, { animate: true }); + }); + }; + + OCA.Onlyoffice.CreateFileProcess = function (name, dir, templateId, targetId, open, callback) { if ((!OCA.Onlyoffice.setting.sameTab || OCA.Onlyoffice.mobile || OCA.Onlyoffice.Desktop) && open) { $loaderUrl = OCA.Onlyoffice.Desktop ? "" : OC.filePath(OCA.Onlyoffice.AppName, "templates", "loader.html"); var winEditor = window.open($loaderUrl); @@ -69,13 +75,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; return; } - if (fileList.add) { - fileList.add(response, { animate: true }); - } - - if (callback) { - callback(response); - } + callback(response); if (open) { OCA.Onlyoffice.OpenEditor(response.id, dir, response.name, 0, winEditor); @@ -187,6 +187,18 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; OCA.Onlyoffice.context.fileName = fileName; }; + OCA.Onlyoffice.FileClickExec = async function (file, view, dir) { + var winEditor = !OCA.Onlyoffice.setting.sameTab ? document : null; + OCA.Onlyoffice.OpenEditor(file.fileid, dir, file.basename, 0, winEditor); + + OCA.Onlyoffice.context = { + fileName: file.basename, + dir: dir + }; + + return null; + }; + OCA.Onlyoffice.FileConvertClick = function (fileName, context) { var fileInfoModel = context.fileInfoModel || context.fileList.getModelForFile(fileName); var fileList = context.fileList; @@ -199,6 +211,19 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; }); }; + OCA.Onlyoffice.FileConvertClickExec = async function (file, view, dir) { + OCA.Onlyoffice.FileConvert(file.fileid, async (response) => { + let viewContents = await view.getContents(dir); + + if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { + let newFile = viewContents.contents.find(node => node.fileid == response.id); + if (newFile) emit("files:node:created", new File(newFile)); + } + }); + + return null; + }; + OCA.Onlyoffice.FileConvert = function (fileId, callback) { var convertData = { fileId: fileId @@ -339,6 +364,21 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; OCA.Onlyoffice.CreateFile(name, fileList, 0, targetId, false); }; + OCA.Onlyoffice.CreateFormClickExec = async function (file, view, dir) { + var name = file.basename.replace(/\.[^.]+$/, ".oform"); + + OCA.Onlyoffice.CreateFileProcess(name, dir, 0, file.fileid, false, async (response) => { + let viewContents = await view.getContents(dir); + + if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { + let newFile = viewContents.contents.find(node => node.fileid == response.id); + if (newFile) emit("files:node:created", new File(newFile)); + } + }); + + return null; + }; + OCA.Onlyoffice.registerAction = function() { var formats = OCA.Onlyoffice.setting.formats; @@ -415,12 +455,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; return false; }, - exec: async (file, view, dir) => { - var winEditor = !OCA.Onlyoffice.setting.sameTab ? document : null; - OCA.Onlyoffice.OpenEditor(file.fileid, dir, file.basename, 0, winEditor); - - return null; - }, + exec: OCA.Onlyoffice.FileClickExec, default: config.def ? DefaultType.HIDDEN : null })); @@ -435,18 +470,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; return false; }, - exec: async (file, view, dir) => { - OCA.Onlyoffice.FileConvert(file.fileid, async (response) => { - let viewContents = await view.getContents(dir); - - if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { - let newFile = viewContents.contents.find(node => node.fileid == response.id); - if (newFile) emit("files:node:created", new File(newFile)); - } - }); - - return null; - } + exec: OCA.Onlyoffice.FileConvertClickExec })); } @@ -461,12 +485,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; return false; }, - exec: async (file, view, dir) => { - var winEditor = !OCA.Onlyoffice.setting.sameTab ? document : null; - OCA.Onlyoffice.OpenEditor(file.fileid, dir, file.basename, 0, winEditor); - - return null; - } + exec: OCA.Onlyoffice.FileClickExec })); } @@ -481,24 +500,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; return false; }, - exec: async (file, view, dir) => { - let fileList = { - dir: dir - }; - - var name = file.basename.replace(/\.[^.]+$/, ".oform"); - - OCA.Onlyoffice.CreateFile(name, fileList, 0, file.fileid, false, async (response) => { - let viewContents = await view.getContents(dir); - - if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { - let newFile = viewContents.contents.find(node => node.fileid == response.id); - if (newFile) emit("files:node:created", new File(newFile)); - } - }); - - return null; - } + exec: OCA.Onlyoffice.CreateFormClickExec })); } From b5f477bf4510b2352cd99e1d725e5cfecf892ce5 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Tue, 21 Nov 2023 16:31:48 +0300 Subject: [PATCH 052/209] checking permissions for file actions --- src/main.js | 57 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/src/main.js b/src/main.js index d879e7c5..73ee4842 100644 --- a/src/main.js +++ b/src/main.js @@ -450,10 +450,15 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; displayName: () => t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"), iconSvgInline: () => AppDarkSvg, enabled: (files, view) => { - if (files[0]?.extension?.replace(".", "") == ext) - return true; + if (files[0]?.extension?.replace(".", "") !== ext) + return false; + + if (Permission.READ !== (files[0].permissions & Permission.READ)) + return false; + if (Permission.READ !== (files[0].attributes["share-permissions"] & Permission.READ)) + return false; - return false; + return true; }, exec: OCA.Onlyoffice.FileClickExec, default: config.def ? DefaultType.HIDDEN : null @@ -465,10 +470,16 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; displayName: () => t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"), iconSvgInline: () => AppDarkSvg, enabled: (files, view) => { - if (files[0]?.extension?.replace(".", "") == ext) - return true; + if (files[0]?.extension?.replace(".", "") !== ext) + return false; - return false; + var required = $("#isPublic").val() ? Permission.UPDATE : Permission.READ; + if (required !== (files[0].permissions & required)) + return false; + if (required !== (files[0].attributes["share-permissions"] & required)) + return false; + + return true; }, exec: OCA.Onlyoffice.FileConvertClickExec })); @@ -480,10 +491,15 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; displayName: () => t(OCA.Onlyoffice.AppName, "Fill in form in ONLYOFFICE"), iconSvgInline: () => AppDarkSvg, enabled: (files, view) => { - if (files[0]?.extension?.replace(".", "") == ext) - return true; + if (files[0]?.extension?.replace(".", "") !== ext) + return false; - return false; + if (Permission.UPDATE !== (files[0].permissions & Permission.UPDATE)) + return false; + if (Permission.UPDATE !== (files[0].attributes["share-permissions"] & Permission.UPDATE)) + return false; + + return true; }, exec: OCA.Onlyoffice.FileClickExec })); @@ -495,10 +511,16 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; displayName: () => t(OCA.Onlyoffice.AppName, "Create form"), iconSvgInline: () => AppDarkSvg, enabled: (files, view) => { - if (files[0]?.extension?.replace(".", "") == ext) - return true; + if (files[0]?.extension?.replace(".", "") !== ext) + return false; - return false; + var required = $("#isPublic").val() ? Permission.UPDATE : Permission.READ; + if (required !== (files[0].permissions & required)) + return false; + if (required !== (files[0].attributes["share-permissions"] & required)) + return false; + + return true; }, exec: OCA.Onlyoffice.CreateFormClickExec })); @@ -510,10 +532,15 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; displayName: () => t(OCA.Onlyoffice.AppName, "Download as"), iconSvgInline: () => AppDarkSvg, enabled: (files, view) => { - if (files[0]?.extension?.replace(".", "") == ext) - return true; + if (files[0]?.extension?.replace(".", "") !== ext) + return false; - return false; + if (Permission.READ !== (files[0].permissions & Permission.READ)) + return false; + if (Permission.READ !== (files[0].attributes["share-permissions"] & Permission.READ)) + return false; + + return true; }, exec: async (file, view, dir) => { OCA.Onlyoffice.Download(file.basename, file.fileid); From df18e6310f267062f4b1ccd757c064fa7e8b8555 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Tue, 21 Nov 2023 16:33:56 +0300 Subject: [PATCH 053/209] cut unused code --- src/main.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.js b/src/main.js index 73ee4842..e72d07e3 100644 --- a/src/main.js +++ b/src/main.js @@ -16,7 +16,7 @@ * */ -import { FileAction, registerFileAction, FileType, Permission, DefaultType, File } from "@nextcloud/files"; +import { FileAction, registerFileAction, Permission, DefaultType, File } from "@nextcloud/files"; import { emit } from '@nextcloud/event-bus'; import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; @@ -449,7 +449,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; id: "onlyoffice-open-" + ext, displayName: () => t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"), iconSvgInline: () => AppDarkSvg, - enabled: (files, view) => { + enabled: (files) => { if (files[0]?.extension?.replace(".", "") !== ext) return false; @@ -469,7 +469,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; id: "onlyoffice-convert-" + ext, displayName: () => t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"), iconSvgInline: () => AppDarkSvg, - enabled: (files, view) => { + enabled: (files) => { if (files[0]?.extension?.replace(".", "") !== ext) return false; @@ -490,7 +490,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; id: "onlyoffice-fill-" + ext, displayName: () => t(OCA.Onlyoffice.AppName, "Fill in form in ONLYOFFICE"), iconSvgInline: () => AppDarkSvg, - enabled: (files, view) => { + enabled: (files) => { if (files[0]?.extension?.replace(".", "") !== ext) return false; @@ -510,7 +510,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; id: "onlyoffice-create-form-" + ext, displayName: () => t(OCA.Onlyoffice.AppName, "Create form"), iconSvgInline: () => AppDarkSvg, - enabled: (files, view) => { + enabled: (files) => { if (files[0]?.extension?.replace(".", "") !== ext) return false; @@ -531,7 +531,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; id: "onlyoffice-download-as-" + ext, displayName: () => t(OCA.Onlyoffice.AppName, "Download as"), iconSvgInline: () => AppDarkSvg, - enabled: (files, view) => { + enabled: (files) => { if (files[0]?.extension?.replace(".", "") !== ext) return false; @@ -542,7 +542,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; return true; }, - exec: async (file, view, dir) => { + exec: async (file) => { OCA.Onlyoffice.Download(file.basename, file.fileid); return null; From e5656c1c5948b6c228323e4ae0810e3ad0c92732 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Wed, 29 Nov 2023 18:28:43 +0300 Subject: [PATCH 054/209] download action to separate handler --- src/main.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.js b/src/main.js index e72d07e3..1ea89d1c 100644 --- a/src/main.js +++ b/src/main.js @@ -253,6 +253,12 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; OCA.Onlyoffice.Download(fileName, fileId); }; + OCA.Onlyoffice.DownloadClickExec = async function (file) { + OCA.Onlyoffice.Download(file.basename, file.fileid); + + return null; + }; + OCA.Onlyoffice.Download = function (fileName, fileId) { $.get(OC.filePath(OCA.Onlyoffice.AppName, "templates", "downloadPicker.html"), function (tmpl) { @@ -542,11 +548,7 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; return true; }, - exec: async (file) => { - OCA.Onlyoffice.Download(file.basename, file.fileid); - - return null; - } + exec: OCA.Onlyoffice.DownloadClickExec })); } } From bf81e31902497c71fc28b0e8afc800ab01e2cb76 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Wed, 22 Nov 2023 14:03:33 +0300 Subject: [PATCH 055/209] added newFileMenu registration (new form template) --- src/main.js | 91 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 15 deletions(-) diff --git a/src/main.js b/src/main.js index 1ea89d1c..d4bcff30 100644 --- a/src/main.js +++ b/src/main.js @@ -16,9 +16,19 @@ * */ -import { FileAction, registerFileAction, Permission, DefaultType, File } from "@nextcloud/files"; +import { FileAction, + registerFileAction, + Permission, + DefaultType, + File, + addNewFileMenuEntry, + davGetClient, + davRootPath, + davGetDefaultPropfind, + davResultToNode } from "@nextcloud/files"; import { emit } from '@nextcloud/event-bus'; import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; +import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg"; (function (OCA) { @@ -41,6 +51,21 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; }); }; + OCA.Onlyoffice.CreateFileOverload = function (name, context, templateId, targetId, open = true) { + if (!context.view) { + context.view = OCP.Files.Router._router.app.currentView; + } + + OCA.Onlyoffice.CreateFileProcess(name, context.dir, templateId, targetId, open, async (response) => { + let viewContents = await context.view.getContents(context.dir); + + if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { + let newFile = viewContents.contents.find(node => node.fileid == response.id); + if (newFile) emit("files:node:created", new File(newFile)); + } + }); + } + OCA.Onlyoffice.CreateFileProcess = function (name, dir, templateId, targetId, open, callback) { if ((!OCA.Onlyoffice.setting.sameTab || OCA.Onlyoffice.mobile || OCA.Onlyoffice.Desktop) && open) { $loaderUrl = OCA.Onlyoffice.Desktop ? "" : OC.filePath(OCA.Onlyoffice.AppName, "templates", "loader.html"); @@ -337,26 +362,41 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; ]; OC.dialogs.filepicker(t(OCA.Onlyoffice.AppName, "Create new Form template"), - function (filePath, type) { + async function (filePath, type) { var dialogFileList = OC.dialogs.filelist; var targetId = 0; + var targetFileName = OC.basename(filePath); + var targetFolderPath = OC.dirname(filePath); + + if (!dialogFileList) { + var results = await davGetClient().getDirectoryContents(davRootPath + targetFolderPath, { + details: true, + data: davGetDefaultPropfind(), + }); + dialogFileList = results.data.map((result) => davResultToNode(result)); + } + if (type === "target") { - var targetFileName = filePath.split("/").pop(); dialogFileList.forEach(item => { - if (item.name === targetFileName) { - targetId = item.id; + let itemName = item.name ? item.name : item.basename; + if (itemName === targetFileName) { + targetId = item.id ? item.id : item.fileid; } }) } - OCA.Onlyoffice.CreateFile(name, filelist, 0, targetId); + if (filelist.getCurrentDirectory) { + OCA.Onlyoffice.CreateFile(name, filelist, 0, targetId); + } else { + OCA.Onlyoffice.CreateFileOverload(name, filelist, 0, targetId) + } }, false, filterMimes, true, OC.dialogs.FILEPICKER_TYPE_CUSTOM, - filelist.getCurrentDirectory(), + filelist.getCurrentDirectory ? filelist.getCurrentDirectory() : filelist.dir, { buttons: buttons }); @@ -372,15 +412,12 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; OCA.Onlyoffice.CreateFormClickExec = async function (file, view, dir) { var name = file.basename.replace(/\.[^.]+$/, ".oform"); + var context = { + dir: dir, + view: view + }; - OCA.Onlyoffice.CreateFileProcess(name, dir, 0, file.fileid, false, async (response) => { - let viewContents = await view.getContents(dir); - - if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { - let newFile = viewContents.contents.find(node => node.fileid == response.id); - if (newFile) emit("files:node:created", new File(newFile)); - } - }); + OCA.Onlyoffice.CreateFileOverload(name, context, 0, file.fileid, false); return null; }; @@ -555,6 +592,28 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; }); }; + OCA.Onlyoffice.registerNewFileMenu = function () { + addNewFileMenuEntry({ + id: "new-onlyoffice-docxf", + displayName: t(OCA.Onlyoffice.AppName, "New form template"), + enabled: (folder) => { + if (Permission.CREATE !== (folder.permissions & Permission.CREATE)) + return false; + if (Permission.CREATE !== (folder.attributes["share-permissions"] & Permission.CREATE)) + return false; + + return true; + }, + iconSvgInline: NewDocxfSvg, + handler: (folder) => { + var name = t(OCA.Onlyoffice.AppName, "New form template"); + var context = { dir: folder.path }; + + OCA.Onlyoffice.OpenFormPicker(name + ".docxf", context); + } + }); + }; + OCA.Onlyoffice.NewFileMenu = { attach: function (menu) { var fileList = menu.fileList; @@ -723,6 +782,8 @@ import AppDarkSvg from "!!raw-loader!../img/app-dark.svg"; OC.Plugins.register("OCA.Files.FileList", OCA.Onlyoffice.TabView); + OCA.Onlyoffice.registerNewFileMenu(); + OCA.Onlyoffice.registerAction(); OCA.Onlyoffice.bindVersionClick(); From 00424fb7a412f8c251532a85c24f3a19f9b518d2 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Wed, 29 Nov 2023 19:11:19 +0300 Subject: [PATCH 056/209] format file object for emit --- src/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index d4bcff30..493872a1 100644 --- a/src/main.js +++ b/src/main.js @@ -61,7 +61,7 @@ import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg"; if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { let newFile = viewContents.contents.find(node => node.fileid == response.id); - if (newFile) emit("files:node:created", new File(newFile)); + if (newFile) emit("files:node:created", newFile); } }); } @@ -242,7 +242,7 @@ import NewDocxfSvg from "!!raw-loader!../img/new-docxf.svg"; if (viewContents.folder && (viewContents.folder.fileid == response.parentId)) { let newFile = viewContents.contents.find(node => node.fileid == response.id); - if (newFile) emit("files:node:created", new File(newFile)); + if (newFile) emit("files:node:created", newFile); } }); From ad3f5d74fff299c91df8fa712109984c06930703 Mon Sep 17 00:00:00 2001 From: Antipkin-A Date: Mon, 27 Nov 2023 12:41:20 +0300 Subject: [PATCH 057/209] detecting frame container --- src/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index ef064643..4650b1d6 100644 --- a/src/main.js +++ b/src/main.js @@ -111,7 +111,9 @@ } else { OCA.Onlyoffice.frameSelector = "#onlyofficeFrame"; var $iframe = $("