1
0
mirror of https://github.com/ONLYOFFICE/onlyoffice-owncloud.git synced 2025-08-08 05:42:07 +03:00

camelCase format for methods names, no prefixes with an underscore for variables

This commit is contained in:
rivexe
2023-12-20 13:14:38 +03:00
parent c568f47c16
commit 198e86aa1e
18 changed files with 375 additions and 375 deletions

View File

@@ -80,8 +80,8 @@ class Application extends App {
$eventDispatcher->addListener( $eventDispatcher->addListener(
"OCA\Files::loadAdditionalScripts", "OCA\Files::loadAdditionalScripts",
function () { function () {
if (!empty($this->appConfig->GetDocumentServerUrl()) if (!empty($this->appConfig->getDocumentServerUrl())
&& $this->appConfig->SettingsAreSuccessful() && $this->appConfig->settingsAreSuccessful()
&& $this->appConfig->isUserAllowedToUse() && $this->appConfig->isUserAllowedToUse()
) { ) {
Util::addScript("onlyoffice", "desktop"); Util::addScript("onlyoffice", "desktop");
@@ -89,7 +89,7 @@ class Application extends App {
Util::addScript("onlyoffice", "share"); Util::addScript("onlyoffice", "share");
Util::addScript("onlyoffice", "template"); Util::addScript("onlyoffice", "template");
if ($this->appConfig->GetSameTab()) { if ($this->appConfig->getSameTab()) {
Util::addScript("onlyoffice", "listener"); Util::addScript("onlyoffice", "listener");
} }
@@ -110,7 +110,7 @@ class Application extends App {
include_once __DIR__ . "/../3rdparty/jwt/Key.php"; include_once __DIR__ . "/../3rdparty/jwt/Key.php";
// Set the leeway for the JWT library in case the system clock is a second off // 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();
$container = $this->getContainer(); $container = $this->getContainer();
@@ -123,7 +123,7 @@ class Application extends App {
$detector->registerType("oform", "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform"); $detector->registerType("oform", "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform");
$previewManager = $container->query(IPreview::class); $previewManager = $container->query(IPreview::class);
if ($this->appConfig->GetPreview()) { if ($this->appConfig->getPreview()) {
$previewManager->registerProvider( $previewManager->registerProvider(
Preview::getMimeTypeRegex(), function () use ($container) { Preview::getMimeTypeRegex(), function () use ($container) {
return $container->query(Preview::class); return $container->query(Preview::class);

View File

@@ -177,7 +177,7 @@ class CallbackController extends Controller {
* @CORS * @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) { if ($hashData === null) {
$this->logger->error("Download with empty or not correct hash: $error", ["app" => $this->appName]); $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); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
@@ -196,8 +196,8 @@ class CallbackController extends Controller {
if (!$this->userSession->isLoggedIn() if (!$this->userSession->isLoggedIn()
&& !$changes && !$changes
) { ) {
if (!empty($this->config->GetDocumentServerSecret())) { if (!empty($this->config->getDocumentServerSecret())) {
$header = \OC::$server->getRequest()->getHeader($this->config->JwtHeader()); $header = \OC::$server->getRequest()->getHeader($this->config->jwtHeader());
if (empty($header)) { if (empty($header)) {
$this->logger->error("Download without jwt", ["app" => $this->appName]); $this->logger->error("Download without jwt", ["app" => $this->appName]);
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
@@ -206,7 +206,7 @@ class CallbackController extends Controller {
$header = substr($header, \strlen("Bearer ")); $header = substr($header, \strlen("Bearer "));
try { 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) { } catch (\UnexpectedValueException $e) {
$this->logger->logException($e, ["message" => "Download with invalid jwt", "app" => $this->appName]); $this->logger->logException($e, ["message" => "Download with invalid jwt", "app" => $this->appName]);
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
@@ -324,7 +324,7 @@ class CallbackController extends Controller {
public function emptyfile($doc) { public function emptyfile($doc) {
$this->logger->debug("Download empty", ["app" => $this->appName]); $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) { if ($hashData === null) {
$this->logger->error("Download empty with empty or not correct hash: $error", ["app" => $this->appName]); $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); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
@@ -334,8 +334,8 @@ class CallbackController extends Controller {
return new JSONResponse(["message" => $this->trans->t("Invalid request")], Http::STATUS_BAD_REQUEST); return new JSONResponse(["message" => $this->trans->t("Invalid request")], Http::STATUS_BAD_REQUEST);
} }
if (!empty($this->config->GetDocumentServerSecret())) { if (!empty($this->config->getDocumentServerSecret())) {
$header = \OC::$server->getRequest()->getHeader($this->config->JwtHeader()); $header = \OC::$server->getRequest()->getHeader($this->config->jwtHeader());
if (empty($header)) { if (empty($header)) {
$this->logger->error("Download empty without jwt", ["app" => $this->appName]); $this->logger->error("Download empty without jwt", ["app" => $this->appName]);
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
@@ -344,14 +344,14 @@ class CallbackController extends Controller {
$header = substr($header, \strlen("Bearer ")); $header = substr($header, \strlen("Bearer "));
try { 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) { } catch (\UnexpectedValueException $e) {
$this->logger->logException($e, ["message" => "Download empty with invalid jwt", "app" => $this->appName]); $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); 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); $template = file_get_contents($templatePath);
if (!$template) { if (!$template) {
@@ -391,7 +391,7 @@ class CallbackController extends Controller {
* @CORS * @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) { if ($hashData === null) {
$this->logger->error("Track with empty or not correct hash: $error", ["app" => $this->appName]); $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); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
@@ -404,16 +404,16 @@ class CallbackController extends Controller {
$fileId = $hashData->fileId; $fileId = $hashData->fileId;
$this->logger->debug("Track: $fileId status $status", ["app" => $this->appName]); $this->logger->debug("Track: $fileId status $status", ["app" => $this->appName]);
if (!empty($this->config->GetDocumentServerSecret())) { if (!empty($this->config->getDocumentServerSecret())) {
if (!empty($token)) { if (!empty($token)) {
try { 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) { } catch (\UnexpectedValueException $e) {
$this->logger->logException($e, ["message" => "Track with invalid jwt in body", "app" => $this->appName]); $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); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
} }
} else { } else {
$header = \OC::$server->getRequest()->getHeader($this->config->JwtHeader()); $header = \OC::$server->getRequest()->getHeader($this->config->jwtHeader());
if (empty($header)) { if (empty($header)) {
$this->logger->error("Track without jwt", ["app" => $this->appName]); $this->logger->error("Track without jwt", ["app" => $this->appName]);
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN); return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
@@ -422,7 +422,7 @@ class CallbackController extends Controller {
$header = substr($header, \strlen("Bearer ")); $header = substr($header, \strlen("Bearer "));
try { 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; $payload = $decodedHeader->payload;
} catch (\UnexpectedValueException $e) { } catch (\UnexpectedValueException $e) {
@@ -511,7 +511,7 @@ class CallbackController extends Controller {
return $error; return $error;
} }
$url = $this->config->ReplaceDocumentServerUrlToInternal($url); $url = $this->config->replaceDocumentServerUrlToInternal($url);
$prevVersion = $file->getFileInfo()->getMtime(); $prevVersion = $file->getFileInfo()->getMtime();
$fileName = $file->getName(); $fileName = $file->getName();
@@ -520,18 +520,18 @@ class CallbackController extends Controller {
$documentService = new DocumentService($this->trans, $this->config); $documentService = new DocumentService($this->trans, $this->config);
if ($downloadExt !== $curExt) { if ($downloadExt !== $curExt) {
$key = DocumentService::GenerateRevisionId($fileId . $url); $key = DocumentService::generateRevisionId($fileId . $url);
try { try {
$this->logger->debug("Converted from $downloadExt to $curExt", ["app" => $this->appName]); $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) { } catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Converted on save error", "app" => $this->appName]); $this->logger->logException($e, ["message" => "Converted on save error", "app" => $this->appName]);
return new JSONResponse(["message" => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR); return new JSONResponse(["message" => $e->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
} }
} }
$newData = $documentService->Request($url); $newData = $documentService->request($url);
$prevIsForcesave = KeyManager::wasForcesave($fileId); $prevIsForcesave = KeyManager::wasForcesave($fileId);
@@ -563,17 +563,17 @@ class CallbackController extends Controller {
if (!$isForcesave if (!$isForcesave
&& !$prevIsForcesave && !$prevIsForcesave
&& $this->versionManager->available && $this->versionManager->available
&& $this->config->GetVersionHistory() && $this->config->getVersionHistory()
) { ) {
$changes = null; $changes = null;
if (!empty($changesurl)) { if (!empty($changesurl)) {
$changesurl = $this->config->ReplaceDocumentServerUrlToInternal($changesurl); $changesurl = $this->config->replaceDocumentServerUrlToInternal($changesurl);
$changes = $documentService->Request($changesurl); $changes = $documentService->request($changesurl);
} }
FileVersions::saveHistory($file->getFileInfo(), $history, $changes, $prevVersion); FileVersions::saveHistory($file->getFileInfo(), $history, $changes, $prevVersion);
} }
if (!empty($user) && $this->config->GetVersionHistory()) { if (!empty($user) && $this->config->getVersionHistory()) {
FileVersions::saveAuthor($file->getFileInfo(), $user); FileVersions::saveAuthor($file->getFileInfo(), $user);
} }
@@ -617,7 +617,7 @@ class CallbackController extends Controller {
} }
try { try {
$folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::GetGlobalTemplateDir(); $folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::getGlobalTemplateDir();
$files = $folder->getById($fileId); $files = $folder->getById($fileId);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]); $this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]);
@@ -760,7 +760,7 @@ class CallbackController extends Controller {
* @return string * @return string
*/ */
private function parseUserId($userId) { private function parseUserId($userId) {
$instanceId = $this->config->GetSystemValue("instanceid", true); $instanceId = $this->config->getSystemValue("instanceid", true);
$instanceId = $instanceId . "_"; $instanceId = $instanceId . "_";
if (substr($userId, 0, \strlen($instanceId)) === $instanceId) { if (substr($userId, 0, \strlen($instanceId)) === $instanceId) {

View File

@@ -206,7 +206,7 @@ class EditorApiController extends OCSController {
} }
$name = $file->getName(); $name = $file->getName();
$template = TemplateManager::GetEmptyTemplate($name); $template = TemplateManager::getEmptyTemplate($name);
if (!$template) { if (!$template) {
$this->logger->error("Template for file filling not found: $name ($fileId)", ["app" => $this->appName]); $this->logger->error("Template for file filling not found: $name ($fileId)", ["app" => $this->appName]);
@@ -267,7 +267,7 @@ class EditorApiController extends OCSController {
$fileName = $file->getName(); $fileName = $file->getName();
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); $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)) { if (!isset($format)) {
$this->logger->info("Format is not supported for editing: $fileName", ["app" => $this->appName]); $this->logger->info("Format is not supported for editing: $fileName", ["app" => $this->appName]);
return new JSONResponse(["error" => $this->trans->t("Format is not supported")]); return new JSONResponse(["error" => $this->trans->t("Format is not supported")]);
@@ -293,7 +293,7 @@ class EditorApiController extends OCSController {
if ($key === null) { if ($key === null) {
$key = $this->fileUtility->getKey($file, true); $key = $this->fileUtility->getKey($file, true);
} }
$key = DocumentService::GenerateRevisionId($key); $key = DocumentService::generateRevisionId($key);
$params = [ $params = [
"document" => [ "document" => [
@@ -304,7 +304,7 @@ class EditorApiController extends OCSController {
"url" => $fileUrl, "url" => $fileUrl,
"referenceData" => [ "referenceData" => [
"fileKey" => $file->getId(), "fileKey" => $file->getId(),
"instanceId" => $this->config->GetSystemValue("instanceid", true), "instanceId" => $this->config->getSystemValue("instanceid", true),
], ],
], ],
"documentType" => $format["type"], "documentType" => $format["type"],
@@ -391,7 +391,7 @@ class EditorApiController extends OCSController {
} }
$canProtect = true; $canProtect = true;
if ($this->config->GetProtection() === "owner") { if ($this->config->getProtection() === "owner") {
$canProtect = $ownerId === $userId; $canProtect = $ownerId === $userId;
} }
$params["document"]["permissions"]["protect"] = $canProtect; $params["document"]["permissions"]["protect"] = $canProtect;
@@ -401,11 +401,11 @@ class EditorApiController extends OCSController {
$params["document"]["permissions"]["protect"] = false; $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]); $callback = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.track", ["doc" => $hashCallback]);
if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) {
$callback = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $callback); $callback = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $callback);
} }
$params["editorConfig"]["callbackUrl"] = $callback; $params["editorConfig"]["callbackUrl"] = $callback;
@@ -487,7 +487,7 @@ class EditorApiController extends OCSController {
$params["editorConfig"]["createUrl"] = urldecode($createUrl); $params["editorConfig"]["createUrl"] = urldecode($createUrl);
$templatesList = TemplateManager::GetGlobalTemplates($file->getMimeType()); $templatesList = TemplateManager::getGlobalTemplates($file->getMimeType());
if (!empty($templatesList)) { if (!empty($templatesList)) {
$templates = []; $templates = [];
foreach ($templatesList as $templateItem) { foreach ($templatesList as $templateItem) {
@@ -513,14 +513,14 @@ class EditorApiController extends OCSController {
} }
if ($folderLink !== null if ($folderLink !== null
&& $this->config->GetSystemValue($this->config->_customization_goback) !== false && $this->config->getSystemValue($this->config->customization_goback) !== false
) { ) {
$params["editorConfig"]["customization"]["goback"] = [ $params["editorConfig"]["customization"]["goback"] = [
"url" => $folderLink "url" => $folderLink
]; ];
if (!$desktop) { if (!$desktop) {
if ($this->config->GetSameTab()) { if ($this->config->getSameTab()) {
$params["editorConfig"]["customization"]["goback"]["blank"] = false; $params["editorConfig"]["customization"]["goback"]["blank"] = false;
if ($inframe === true) { if ($inframe === true) {
$params["editorConfig"]["customization"]["goback"]["requestClose"] = true; $params["editorConfig"]["customization"]["goback"]["requestClose"] = true;
@@ -535,8 +535,8 @@ class EditorApiController extends OCSController {
$params = $this->setCustomization($params); $params = $this->setCustomization($params);
if ($this->config->UseDemo()) { if ($this->config->useDemo()) {
$params["editorConfig"]["tenant"] = $this->config->GetSystemValue("instanceid", true); $params["editorConfig"]["tenant"] = $this->config->getSystemValue("instanceid", true);
} }
if ($anchor !== null) { if ($anchor !== null) {
@@ -549,8 +549,8 @@ class EditorApiController extends OCSController {
} }
} }
if (!empty($this->config->GetDocumentServerSecret())) { if (!empty($this->config->getDocumentServerSecret())) {
$token = \Firebase\JWT\JWT::encode($params, $this->config->GetDocumentServerSecret(), "HS256"); $token = \Firebase\JWT\JWT::encode($params, $this->config->getDocumentServerSecret(), "HS256");
$params["token"] = $token; $params["token"] = $token;
} }
@@ -575,7 +575,7 @@ class EditorApiController extends OCSController {
} }
try { try {
$folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::GetGlobalTemplateDir(); $folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::getGlobalTemplateDir();
$files = $folder->getById($fileId); $files = $folder->getById($fileId);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]); $this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]);
@@ -642,12 +642,12 @@ class EditorApiController extends OCSController {
$data["template"] = true; $data["template"] = true;
} }
$hashUrl = $this->crypt->GetHash($data); $hashUrl = $this->crypt->getHash($data);
$fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]);
if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) {
$fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $fileUrl);
} }
return $fileUrl; return $fileUrl;
@@ -661,7 +661,7 @@ class EditorApiController extends OCSController {
* @return string * @return string
*/ */
private function buildUserId($userId) { private function buildUserId($userId) {
$instanceId = $this->config->GetSystemValue("instanceid", true); $instanceId = $this->config->getSystemValue("instanceid", true);
$userId = $instanceId . "_" . $userId; $userId = $instanceId . "_" . $userId;
return $userId; return $userId;
} }
@@ -675,84 +675,84 @@ class EditorApiController extends OCSController {
*/ */
private function setCustomization($params) { private function setCustomization($params) {
//default is true //default is true
if ($this->config->GetCustomizationChat() === false) { if ($this->config->getCustomizationChat() === false) {
$params["editorConfig"]["customization"]["chat"] = false; $params["editorConfig"]["customization"]["chat"] = false;
} }
//default is false //default is false
if ($this->config->GetCustomizationCompactHeader() === true) { if ($this->config->getCustomizationCompactHeader() === true) {
$params["editorConfig"]["customization"]["compactHeader"] = true; $params["editorConfig"]["customization"]["compactHeader"] = true;
} }
//default is false //default is false
if ($this->config->GetCustomizationFeedback() === true) { if ($this->config->getCustomizationFeedback() === true) {
$params["editorConfig"]["customization"]["feedback"] = true; $params["editorConfig"]["customization"]["feedback"] = true;
} }
//default is false //default is false
if ($this->config->GetCustomizationForcesave() === true) { if ($this->config->getCustomizationForcesave() === true) {
$params["editorConfig"]["customization"]["forcesave"] = true; $params["editorConfig"]["customization"]["forcesave"] = true;
} }
//default is true //default is true
if ($this->config->GetCustomizationHelp() === false) { if ($this->config->getCustomizationHelp() === false) {
$params["editorConfig"]["customization"]["help"] = false; $params["editorConfig"]["customization"]["help"] = false;
} }
//default is original //default is original
$reviewDisplay = $this->config->GetCustomizationReviewDisplay(); $reviewDisplay = $this->config->getCustomizationReviewDisplay();
if ($reviewDisplay !== "original") { if ($reviewDisplay !== "original") {
$params["editorConfig"]["customization"]["reviewDisplay"] = $reviewDisplay; $params["editorConfig"]["customization"]["reviewDisplay"] = $reviewDisplay;
} }
$theme = $this->config->GetCustomizationTheme(); $theme = $this->config->getCustomizationTheme();
if (isset($theme)) { if (isset($theme)) {
$params["editorConfig"]["customization"]["uiTheme"] = $theme; $params["editorConfig"]["customization"]["uiTheme"] = $theme;
} }
//default is false //default is false
if ($this->config->GetCustomizationToolbarNoTabs() === true) { if ($this->config->getCustomizationToolbarNoTabs() === true) {
$params["editorConfig"]["customization"]["toolbarNoTabs"] = true; $params["editorConfig"]["customization"]["toolbarNoTabs"] = true;
} }
//default is true //default is true
if ($this->config->GetCustomizationMacros() === false) { if ($this->config->getCustomizationMacros() === false) {
$params["editorConfig"]["customization"]["macros"] = false; $params["editorConfig"]["customization"]["macros"] = false;
} }
//default is true //default is true
if ($this->config->GetCustomizationPlugins() === false) { if ($this->config->getCustomizationPlugins() === false) {
$params["editorConfig"]["customization"]["plugins"] = false; $params["editorConfig"]["customization"]["plugins"] = false;
} }
/* from system config */ /* from system config */
$autosave = $this->config->GetSystemValue($this->config->_customization_autosave); $autosave = $this->config->getSystemValue($this->config->customization_autosave);
if (isset($autosave)) { if (isset($autosave)) {
$params["editorConfig"]["customization"]["autosave"] = $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)) { if (isset($customer)) {
$params["editorConfig"]["customization"]["customer"] = $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)) { if (isset($loaderLogo)) {
$params["editorConfig"]["customization"]["loaderLogo"] = $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)) { if (isset($loaderName)) {
$params["editorConfig"]["customization"]["loaderName"] = $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)) { if (isset($logo)) {
$params["editorConfig"]["customization"]["logo"] = $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)) { if (isset($zoom)) {
$params["editorConfig"]["customization"]["zoom"] = $zoom; $params["editorConfig"]["customization"]["zoom"] = $zoom;
} }

View File

@@ -249,7 +249,7 @@ class EditorController extends Controller {
} }
if (!empty($templateId)) { if (!empty($templateId)) {
$templateFile = TemplateManager::GetTemplate($templateId); $templateFile = TemplateManager::getTemplate($templateId);
if ($templateFile) { if ($templateFile) {
$template = $templateFile->getContent(); $template = $templateFile->getContent();
} }
@@ -271,14 +271,14 @@ class EditorController extends Controller {
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
$documentService = new DocumentService($this->trans, $this->config); $documentService = new DocumentService($this->trans, $this->config);
try { try {
$newFileUri = $documentService->GetConvertedUri($fileUrl, $targetExt, $ext, $targetKey); $newFileUri = $documentService->getConvertedUri($fileUrl, $targetExt, $ext, $targetKey);
} catch (\Exception $e) { } 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()]; return ["error" => $e->getMessage()];
} }
$template = $documentService->Request($newFileUri); $template = $documentService->request($newFileUri);
} else { } else {
$template = TemplateManager::GetEmptyTemplate($name); $template = TemplateManager::getEmptyTemplate($name);
} }
if (!$template) { if (!$template) {
@@ -570,7 +570,7 @@ class EditorController extends Controller {
$file = null; $file = null;
$fileId = (integer)($referenceData["fileKey"] ?? 0); $fileId = (integer)($referenceData["fileKey"] ?? 0);
if (!empty($fileId) 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); list($file, $error, $share) = $this->getFile($userId, $fileId);
} }
@@ -601,13 +601,13 @@ class EditorController extends Controller {
"path" => $userFolder->getRelativePath($file->getPath()), "path" => $userFolder->getRelativePath($file->getPath()),
"referenceData" => [ "referenceData" => [
"fileKey" => $file->getId(), "fileKey" => $file->getId(),
"instanceId" => $this->config->GetSystemValue("instanceid", true), "instanceId" => $this->config->getSystemValue("instanceid", true),
], ],
"url" => $this->getUrl($file, $user), "url" => $this->getUrl($file, $user),
]; ];
if (!empty($this->config->GetDocumentServerSecret())) { if (!empty($this->config->getDocumentServerSecret())) {
$token = \Firebase\JWT\JWT::encode($response, $this->config->GetDocumentServerSecret(), "HS256"); $token = \Firebase\JWT\JWT::encode($response, $this->config->getDocumentServerSecret(), "HS256");
$response["token"] = $token; $response["token"] = $token;
} }
@@ -657,7 +657,7 @@ class EditorController extends Controller {
$fileName = $file->getName(); $fileName = $file->getName();
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
$format = $this->config->FormatsSetting()[$ext]; $format = $this->config->formatsSetting()[$ext];
if (!isset($format)) { if (!isset($format)) {
$this->logger->info("Format for convertion not supported: $fileName", ["app" => $this->appName]); $this->logger->info("Format for convertion not supported: $fileName", ["app" => $this->appName]);
return ["error" => $this->trans->t("Format is not supported")]; return ["error" => $this->trans->t("Format is not supported")];
@@ -683,9 +683,9 @@ class EditorController extends Controller {
$key = $this->fileUtility->getKey($file); $key = $this->fileUtility->getKey($file);
$fileUrl = $this->getUrl($file, $user, $shareToken); $fileUrl = $this->getUrl($file, $user, $shareToken);
try { try {
$newFileUri = $documentService->GetConvertedUri($fileUrl, $ext, $internalExtension, $key); $newFileUri = $documentService->getConvertedUri($fileUrl, $ext, $internalExtension, $key);
} catch (\Exception $e) { } 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()]; return ["error" => $e->getMessage()];
} }
@@ -695,7 +695,7 @@ class EditorController extends Controller {
} }
try { try {
$newData = $documentService->Request($newFileUri); $newData = $documentService->request($newFileUri);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Failed to download converted file", "app" => $this->appName]); $this->logger->logException($e, ["message" => "Failed to download converted file", "app" => $this->appName]);
return ["error" => $this->trans->t("Failed to download converted file")]; return ["error" => $this->trans->t("Failed to download converted file")];
@@ -755,11 +755,11 @@ class EditorController extends Controller {
return ["error" => $this->trans->t("You don't have enough permission to create")]; return ["error" => $this->trans->t("You don't have enough permission to create")];
} }
$url = $this->config->ReplaceDocumentServerUrlToInternal($url); $url = $this->config->replaceDocumentServerUrlToInternal($url);
try { try {
$documentService = new DocumentService($this->trans, $this->config); $documentService = new DocumentService($this->trans, $this->config);
$newData = $documentService->Request($url); $newData = $documentService->request($url);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Failed to download file for saving", "app" => $this->appName]); $this->logger->logException($e, ["message" => "Failed to download file for saving", "app" => $this->appName]);
return ["error" => $this->trans->t("Download failed")]; return ["error" => $this->trans->t("Download failed")];
@@ -795,7 +795,7 @@ class EditorController extends Controller {
* @NoAdminRequired * @NoAdminRequired
*/ */
public function history($fileId) { public function history($fileId) {
$this->logger->debug("Request history for: $fileId", ["app" => $this->appName]); $this->logger->debug("request history for: $fileId", ["app" => $this->appName]);
if (!$this->config->isUserAllowedToUse()) { if (!$this->config->isUserAllowedToUse()) {
return ["error" => $this->trans->t("Not permitted")]; return ["error" => $this->trans->t("Not permitted")];
@@ -839,7 +839,7 @@ class EditorController extends Controller {
$versionNum = $versionNum + 1; $versionNum = $versionNum + 1;
$key = $this->fileUtility->getVersionKey($version); $key = $this->fileUtility->getVersionKey($version);
$key = DocumentService::GenerateRevisionId($key); $key = DocumentService::generateRevisionId($key);
$historyItem = [ $historyItem = [
"created" => $version->getTimestamp(), "created" => $version->getTimestamp(),
@@ -870,7 +870,7 @@ class EditorController extends Controller {
} }
$key = $this->fileUtility->getKey($file, true); $key = $this->fileUtility->getKey($file, true);
$key = DocumentService::GenerateRevisionId($key); $key = DocumentService::generateRevisionId($key);
$historyItem = [ $historyItem = [
"created" => $file->getMTime(), "created" => $file->getMTime(),
@@ -915,7 +915,7 @@ class EditorController extends Controller {
* @NoAdminRequired * @NoAdminRequired
*/ */
public function version($fileId, $version) { public function version($fileId, $version) {
$this->logger->debug("Request version for: $fileId ($version)", ["app" => $this->appName]); $this->logger->debug("request version for: $fileId ($version)", ["app" => $this->appName]);
if (!$this->config->isUserAllowedToUse()) { if (!$this->config->isUserAllowedToUse()) {
return ["error" => $this->trans->t("Not permitted")]; return ["error" => $this->trans->t("Not permitted")];
@@ -967,7 +967,7 @@ class EditorController extends Controller {
$fileUrl = $this->getUrl($file, $user, null, $version); $fileUrl = $this->getUrl($file, $user, null, $version);
} }
$key = DocumentService::GenerateRevisionId($key); $key = DocumentService::generateRevisionId($key);
$fileName = $file->getName(); $fileName = $file->getName();
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); $ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
@@ -987,7 +987,7 @@ class EditorController extends Controller {
$prevVersion = array_values($versions)[$version - 2]; $prevVersion = array_values($versions)[$version - 2];
$prevVersionKey = $this->fileUtility->getVersionKey($prevVersion); $prevVersionKey = $this->fileUtility->getVersionKey($prevVersion);
$prevVersionKey = DocumentService::GenerateRevisionId($prevVersionKey); $prevVersionKey = DocumentService::generateRevisionId($prevVersionKey);
$prevVersionUrl = $this->getUrl($file, $user, null, $version - 1); $prevVersionUrl = $this->getUrl($file, $user, null, $version - 1);
@@ -998,8 +998,8 @@ class EditorController extends Controller {
]; ];
} }
if (!empty($this->config->GetDocumentServerSecret())) { if (!empty($this->config->getDocumentServerSecret())) {
$token = \Firebase\JWT\JWT::encode($result, $this->config->GetDocumentServerSecret(), "HS256"); $token = \Firebase\JWT\JWT::encode($result, $this->config->getDocumentServerSecret(), "HS256");
$result["token"] = $token; $result["token"] = $token;
} }
@@ -1018,7 +1018,7 @@ class EditorController extends Controller {
* @PublicPage * @PublicPage
*/ */
public function restore($fileId, $version) { public function restore($fileId, $version) {
$this->logger->debug("Request restore version for: $fileId ($version)", ["app" => $this->appName]); $this->logger->debug("request restore version for: $fileId ($version)", ["app" => $this->appName]);
if (!$this->config->isUserAllowedToUse()) { if (!$this->config->isUserAllowedToUse()) {
return ["error" => $this->trans->t("Not permitted")]; return ["error" => $this->trans->t("Not permitted")];
@@ -1070,7 +1070,7 @@ class EditorController extends Controller {
* @NoAdminRequired * @NoAdminRequired
*/ */
public function url($filePath) { public function url($filePath) {
$this->logger->debug("Request url for: $filePath", ["app" => $this->appName]); $this->logger->debug("request url for: $filePath", ["app" => $this->appName]);
if (!$this->config->isUserAllowedToUse()) { if (!$this->config->isUserAllowedToUse()) {
return ["error" => $this->trans->t("Not permitted")]; return ["error" => $this->trans->t("Not permitted")];
@@ -1100,8 +1100,8 @@ class EditorController extends Controller {
"url" => $fileUrl "url" => $fileUrl
]; ];
if (!empty($this->config->GetDocumentServerSecret())) { if (!empty($this->config->getDocumentServerSecret())) {
$token = \Firebase\JWT\JWT::encode($result, $this->config->GetDocumentServerSecret(), "HS256"); $token = \Firebase\JWT\JWT::encode($result, $this->config->getDocumentServerSecret(), "HS256");
$result["token"] = $token; $result["token"] = $token;
} }
@@ -1128,7 +1128,7 @@ class EditorController extends Controller {
} }
if ($template) { if ($template) {
$templateFile = TemplateManager::GetTemplate($fileId); $templateFile = TemplateManager::getTemplate($fileId);
if (empty($templateFile)) { if (empty($templateFile)) {
$this->logger->info("Download: template not found: $fileId", ["app" => $this->appName]); $this->logger->info("Download: template not found: $fileId", ["app" => $this->appName]);
@@ -1172,14 +1172,14 @@ class EditorController extends Controller {
$key = $this->fileUtility->getKey($file); $key = $this->fileUtility->getKey($file);
$fileUrl = $this->getUrl($file, $user); $fileUrl = $this->getUrl($file, $user);
try { try {
$newFileUri = $documentService->GetConvertedUri($fileUrl, $ext, $toExtension, $key); $newFileUri = $documentService->getConvertedUri($fileUrl, $ext, $toExtension, $key);
} catch (\Exception $e) { } 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()); return $this->renderError($e->getMessage());
} }
try { try {
$newData = $documentService->Request($newFileUri); $newData = $documentService->request($newFileUri);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Failed to download converted file", "app" => $this->appName]); $this->logger->logException($e, ["message" => "Failed to download converted file", "app" => $this->appName]);
return $this->renderError($this->trans->t("Failed to download converted file")); return $this->renderError($this->trans->t("Failed to download converted file"));
@@ -1188,7 +1188,7 @@ class EditorController extends Controller {
$fileNameWithoutExt = substr($fileName, 0, \strlen($fileName) - \strlen($ext) - 1); $fileNameWithoutExt = substr($fileName, 0, \strlen($fileName) - \strlen($ext) - 1);
$newFileName = $fileNameWithoutExt . "." . $toExtension; $newFileName = $fileNameWithoutExt . "." . $toExtension;
$formats = $this->config->FormatsSetting(); $formats = $this->config->formatsSetting();
return new DataDownloadResponse($newData, $newFileName, $formats[$toExtension]["mime"]); return new DataDownloadResponse($newData, $newFileName, $formats[$toExtension]["mime"]);
} }
@@ -1233,7 +1233,7 @@ class EditorController extends Controller {
return $this->renderError($this->trans->t("Not permitted")); return $this->renderError($this->trans->t("Not permitted"));
} }
$documentServerUrl = $this->config->GetDocumentServerUrl(); $documentServerUrl = $this->config->getDocumentServerUrl();
if (empty($documentServerUrl)) { if (empty($documentServerUrl)) {
$this->logger->error("documentServerUrl is empty", ["app" => $this->appName]); $this->logger->error("documentServerUrl is empty", ["app" => $this->appName]);
@@ -1286,7 +1286,7 @@ class EditorController extends Controller {
* @NoCSRFRequired * @NoCSRFRequired
* @PublicPage * @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); return $this->index($fileId, null, $shareToken, $version, $inframe);
} }
@@ -1306,7 +1306,7 @@ class EditorController extends Controller {
} }
try { try {
$folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::GetGlobalTemplateDir(); $folder = !$template ? $this->root->getUserFolder($userId) : TemplateManager::getGlobalTemplateDir();
$files = $folder->getById($fileId); $files = $folder->getById($fileId);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]); $this->logger->logException($e, ["message" => "getFile: $fileId", "app" => $this->appName]);
@@ -1373,12 +1373,12 @@ class EditorController extends Controller {
$data["template"] = true; $data["template"] = true;
} }
$hashUrl = $this->crypt->GetHash($data); $hashUrl = $this->crypt->getHash($data);
$fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]);
if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) {
$fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $fileUrl);
} }
return $fileUrl; return $fileUrl;
@@ -1392,7 +1392,7 @@ class EditorController extends Controller {
* @return string * @return string
*/ */
private function buildUserId($userId) { private function buildUserId($userId) {
$instanceId = $this->config->GetSystemValue("instanceid", true); $instanceId = $this->config->getSystemValue("instanceid", true);
$userId = $instanceId . "_" . $userId; $userId = $instanceId . "_" . $userId;
return $userId; return $userId;
} }

View File

@@ -106,7 +106,7 @@ class FederationController extends OCSController {
$key = $this->fileUtility->getKey($file, true); $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]); $this->logger->debug("Federated request get for " . $file->getId() . " key $key", ["app" => $this->appName]);

View File

@@ -111,7 +111,7 @@ class JobListController extends Controller {
* @return void * @return void
*/ */
private function checkEditorsCheckJob() { private function checkEditorsCheckJob() {
if ($this->config->GetEditorsCheckInterval() > 0) { if ($this->config->getEditorsCheckInterval() > 0) {
$this->addJob(EditorsCheck::class); $this->addJob(EditorsCheck::class);
} else { } else {
$this->removeJob(EditorsCheck::class); $this->removeJob(EditorsCheck::class);

View File

@@ -71,9 +71,9 @@ class SettingsApiController extends OCSController {
* @NoAdminRequired * @NoAdminRequired
* @CORS * @CORS
*/ */
public function GetDocServerUrl() { public function getDocServerUrl() {
$url = $this->config->GetDocumentServerUrl(); $url = $this->config->getDocumentServerUrl();
if (!$this->config->SettingsAreSuccessful()) { if (!$this->config->settingsAreSuccessful()) {
$url = ""; $url = "";
} elseif (!preg_match("/^https?:\/\//i", $url)) { } elseif (!preg_match("/^https?:\/\//i", $url)) {
$url = $this->urlGenerator->getAbsoluteURL($url); $url = $this->urlGenerator->getAbsoluteURL($url);

View File

@@ -106,34 +106,34 @@ class SettingsController extends Controller {
*/ */
public function index() { public function index() {
$data = [ $data = [
"documentserver" => $this->config->GetDocumentServerUrl(true), "documentserver" => $this->config->getDocumentServerUrl(true),
"documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true), "documentserverInternal" => $this->config->getDocumentServerInternalUrl(true),
"storageUrl" => $this->config->GetStorageUrl(), "storageUrl" => $this->config->getStorageUrl(),
"verifyPeerOff" => $this->config->GetVerifyPeerOff(), "verifyPeerOff" => $this->config->getVerifyPeerOff(),
"secret" => $this->config->GetDocumentServerSecret(true), "secret" => $this->config->getDocumentServerSecret(true),
"jwtHeader" => $this->config->JwtHeader(true), "jwtHeader" => $this->config->jwtHeader(true),
"demo" => $this->config->GetDemoData(), "demo" => $this->config->getDemoData(),
"currentServer" => $this->urlGenerator->getAbsoluteURL("/"), "currentServer" => $this->urlGenerator->getAbsoluteURL("/"),
"formats" => $this->config->FormatsSetting(), "formats" => $this->config->formatsSetting(),
"sameTab" => $this->config->GetSameTab(), "sameTab" => $this->config->getSameTab(),
"preview" => $this->config->GetPreview(), "preview" => $this->config->getPreview(),
"versionHistory" => $this->config->GetVersionHistory(), "versionHistory" => $this->config->getVersionHistory(),
"protection" => $this->config->GetProtection(), "protection" => $this->config->getProtection(),
"encryption" => $this->config->checkEncryptionModule(), "encryption" => $this->config->checkEncryptionModule(),
"limitGroups" => $this->config->GetLimitGroups(), "limitGroups" => $this->config->getLimitGroups(),
"chat" => $this->config->GetCustomizationChat(), "chat" => $this->config->getCustomizationChat(),
"compactHeader" => $this->config->GetCustomizationCompactHeader(), "compactHeader" => $this->config->getCustomizationCompactHeader(),
"feedback" => $this->config->GetCustomizationFeedback(), "feedback" => $this->config->getCustomizationFeedback(),
"forcesave" => $this->config->GetCustomizationForcesave(), "forcesave" => $this->config->getCustomizationForcesave(),
"help" => $this->config->GetCustomizationHelp(), "help" => $this->config->getCustomizationHelp(),
"toolbarNoTabs" => $this->config->GetCustomizationToolbarNoTabs(), "toolbarNoTabs" => $this->config->getCustomizationToolbarNoTabs(),
"successful" => $this->config->SettingsAreSuccessful(), "successful" => $this->config->settingsAreSuccessful(),
"plugins" => $this->config->GetCustomizationPlugins(), "plugins" => $this->config->getCustomizationPlugins(),
"macros" => $this->config->GetCustomizationMacros(), "macros" => $this->config->getCustomizationMacros(),
"reviewDisplay" => $this->config->GetCustomizationReviewDisplay(), "reviewDisplay" => $this->config->getCustomizationReviewDisplay(),
"theme" => $this->config->GetCustomizationTheme(), "theme" => $this->config->getCustomizationTheme(),
"templates" => $this->GetGlobalTemplates(), "templates" => $this->getGlobalTemplates(),
"linkToDocs" => $this->config->GetLinkToDocs() "linkToDocs" => $this->config->getLinkToDocs()
]; ];
return new TemplateResponse($this->appName, "settings", $data, "blank"); return new TemplateResponse($this->appName, "settings", $data, "blank");
} }
@@ -151,7 +151,7 @@ class SettingsController extends Controller {
* *
* @return array * @return array
*/ */
public function SaveAddress( public function saveAddress(
$documentserver, $documentserver,
$documentserverInternal, $documentserverInternal,
$storageUrl, $storageUrl,
@@ -161,25 +161,25 @@ class SettingsController extends Controller {
$demo $demo
) { ) {
$error = null; $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."); $error = $this->trans->t("The 30-day test period is over, you can no longer connect to demo ONLYOFFICE Docs server.");
} }
if ($demo !== true) { if ($demo !== true) {
$this->config->SetDocumentServerUrl($documentserver); $this->config->setDocumentServerUrl($documentserver);
$this->config->SetVerifyPeerOff($verifyPeerOff); $this->config->setVerifyPeerOff($verifyPeerOff);
$this->config->SetDocumentServerInternalUrl($documentserverInternal); $this->config->setDocumentServerInternalUrl($documentserverInternal);
$this->config->SetDocumentServerSecret($secret); $this->config->setDocumentServerSecret($secret);
$this->config->SetJwtHeader($jwtHeader); $this->config->setJwtHeader($jwtHeader);
} }
$this->config->SetStorageUrl($storageUrl); $this->config->setStorageUrl($storageUrl);
$version = null; $version = null;
if (empty($error)) { if (empty($error)) {
$documentserver = $this->config->GetDocumentServerUrl(); $documentserver = $this->config->getDocumentServerUrl();
if (!empty($documentserver)) { if (!empty($documentserver)) {
$documentService = new DocumentService($this->trans, $this->config); $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); $this->config->setSettingsError($error);
} }
if ($this->config->checkEncryptionModule() === true) { if ($this->config->checkEncryptionModule() === true) {
@@ -188,12 +188,12 @@ class SettingsController extends Controller {
} }
return [ return [
"documentserver" => $this->config->GetDocumentServerUrl(true), "documentserver" => $this->config->getDocumentServerUrl(true),
"verifyPeerOff" => $this->config->GetVerifyPeerOff(), "verifyPeerOff" => $this->config->getVerifyPeerOff(),
"documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true), "documentserverInternal" => $this->config->getDocumentServerInternalUrl(true),
"storageUrl" => $this->config->GetStorageUrl(), "storageUrl" => $this->config->getStorageUrl(),
"secret" => $this->config->GetDocumentServerSecret(true), "secret" => $this->config->getDocumentServerSecret(true),
"jwtHeader" => $this->config->JwtHeader(true), "jwtHeader" => $this->config->jwtHeader(true),
"error" => $error, "error" => $error,
"version" => $version, "version" => $version,
]; ];
@@ -219,7 +219,7 @@ class SettingsController extends Controller {
* *
* @return array * @return array
*/ */
public function SaveCommon( public function saveCommon(
$defFormats, $defFormats,
$editFormats, $editFormats,
$sameTab, $sameTab,
@@ -235,20 +235,20 @@ class SettingsController extends Controller {
$reviewDisplay, $reviewDisplay,
$theme $theme
) { ) {
$this->config->SetDefaultFormats($defFormats); $this->config->setDefaultFormats($defFormats);
$this->config->SetEditableFormats($editFormats); $this->config->setEditableFormats($editFormats);
$this->config->SetSameTab($sameTab); $this->config->setSameTab($sameTab);
$this->config->SetPreview($preview); $this->config->setPreview($preview);
$this->config->SetVersionHistory($versionHistory); $this->config->setVersionHistory($versionHistory);
$this->config->SetLimitGroups($limitGroups); $this->config->setLimitGroups($limitGroups);
$this->config->SetCustomizationChat($chat); $this->config->setCustomizationChat($chat);
$this->config->SetCustomizationCompactHeader($compactHeader); $this->config->setCustomizationCompactHeader($compactHeader);
$this->config->SetCustomizationFeedback($feedback); $this->config->setCustomizationFeedback($feedback);
$this->config->SetCustomizationForcesave($forcesave); $this->config->setCustomizationForcesave($forcesave);
$this->config->SetCustomizationHelp($help); $this->config->setCustomizationHelp($help);
$this->config->SetCustomizationToolbarNoTabs($toolbarNoTabs); $this->config->setCustomizationToolbarNoTabs($toolbarNoTabs);
$this->config->SetCustomizationReviewDisplay($reviewDisplay); $this->config->setCustomizationReviewDisplay($reviewDisplay);
$this->config->SetCustomizationTheme($theme); $this->config->setCustomizationTheme($theme);
return [ return [
]; ];
@@ -263,14 +263,14 @@ class SettingsController extends Controller {
* *
* @return array * @return array
*/ */
public function SaveSecurity( public function saveSecurity(
$plugins, $plugins,
$macros, $macros,
$protection $protection
) { ) {
$this->config->SetCustomizationPlugins($plugins); $this->config->setCustomizationPlugins($plugins);
$this->config->SetCustomizationMacros($macros); $this->config->setCustomizationMacros($macros);
$this->config->SetProtection($protection); $this->config->setProtection($protection);
return [ return [
]; ];
@@ -281,7 +281,7 @@ class SettingsController extends Controller {
* *
* @return array * @return array
*/ */
public function ClearHistory() { public function clearHistory() {
FileVersions::clearHistory(); FileVersions::clearHistory();
return [ return [
@@ -296,11 +296,11 @@ class SettingsController extends Controller {
* @NoAdminRequired * @NoAdminRequired
* @PublicPage * @PublicPage
*/ */
public function GetSettings() { public function getSettings() {
$result = [ $result = [
"formats" => $this->config->FormatsSetting(), "formats" => $this->config->formatsSetting(),
"sameTab" => $this->config->GetSameTab(), "sameTab" => $this->config->getSameTab(),
"shareAttributesVersion" => $this->config->ShareAttributesVersion() "shareAttributesVersion" => $this->config->shareAttributesVersion()
]; ];
return $result; return $result;
} }
@@ -310,15 +310,15 @@ class SettingsController extends Controller {
* *
* @return array * @return array
*/ */
private function GetGlobalTemplates() { private function getGlobalTemplates() {
$templates = []; $templates = [];
$templatesList = TemplateManager::GetGlobalTemplates(); $templatesList = TemplateManager::getGlobalTemplates();
foreach ($templatesList as $templateItem) { foreach ($templatesList as $templateItem) {
$template = [ $template = [
"id" => $templateItem->getId(), "id" => $templateItem->getId(),
"name" => $templateItem->getName(), "name" => $templateItem->getName(),
"type" => TemplateManager::GetTypeTemplate($templateItem->getMimeType()) "type" => TemplateManager::getTypeTemplate($templateItem->getMimeType())
]; ];
array_push($templates, $template); array_push($templates, $template);
} }

View File

@@ -70,15 +70,15 @@ class TemplateController extends Controller {
* *
* @NoAdminRequired * @NoAdminRequired
*/ */
public function GetTemplates() { public function getTemplates() {
$templatesList = TemplateManager::GetGlobalTemplates(); $templatesList = TemplateManager::getGlobalTemplates();
$templates = []; $templates = [];
foreach ($templatesList as $templatesItem) { foreach ($templatesList as $templatesItem) {
$template = [ $template = [
"id" => $templatesItem->getId(), "id" => $templatesItem->getId(),
"name" => $templatesItem->getName(), "name" => $templatesItem->getName(),
"type" => TemplateManager::GetTypeTemplate($templatesItem->getMimeType()) "type" => TemplateManager::getTypeTemplate($templatesItem->getMimeType())
]; ];
array_push($templates, $template); array_push($templates, $template);
} }
@@ -91,18 +91,18 @@ class TemplateController extends Controller {
* *
* @return array * @return array
*/ */
public function AddTemplate() { public function addTemplate() {
$file = $this->request->getUploadedFile("file"); $file = $this->request->getUploadedFile("file");
if ($file !== null) { if ($file !== null) {
if (is_uploaded_file($file["tmp_name"]) && $file["error"] === 0) { if (is_uploaded_file($file["tmp_name"]) && $file["error"] === 0) {
if (!TemplateManager::IsTemplateType($file["name"])) { if (!TemplateManager::isTemplateType($file["name"])) {
return [ return [
"error" => $this->trans->t("Template must be in OOXML format") "error" => $this->trans->t("Template must be in OOXML format")
]; ];
} }
$templateDir = TemplateManager::GetGlobalTemplateDir(); $templateDir = TemplateManager::getGlobalTemplateDir();
if ($templateDir->nodeExists($file["name"])) { if ($templateDir->nodeExists($file["name"])) {
return [ return [
"error" => $this->trans->t("Template already exists") "error" => $this->trans->t("Template already exists")
@@ -117,7 +117,7 @@ class TemplateController extends Controller {
$result = [ $result = [
"id" => $fileInfo->getId(), "id" => $fileInfo->getId(),
"name" => $fileInfo->getName(), "name" => $fileInfo->getName(),
"type" => TemplateManager::GetTypeTemplate($fileInfo->getMimeType()) "type" => TemplateManager::getTypeTemplate($fileInfo->getMimeType())
]; ];
$this->logger->debug("Template: added " . $fileInfo->getName(), ["app" => $this->appName]); $this->logger->debug("Template: added " . $fileInfo->getName(), ["app" => $this->appName]);
@@ -138,13 +138,13 @@ class TemplateController extends Controller {
* *
* @return array * @return array
*/ */
public function DeleteTemplate($templateId) { public function deleteTemplate($templateId) {
$templateDir = TemplateManager::GetGlobalTemplateDir(); $templateDir = TemplateManager::getGlobalTemplateDir();
try { try {
$templates = $templateDir->getById($templateId); $templates = $templateDir->getById($templateId);
} catch(\Exception $e) { } catch(\Exception $e) {
$this->logger->logException($e, ["message" => "DeleteTemplate: $templateId", "app" => $this->AppName]); $this->logger->logException($e, ["message" => "deleteTemplate: $templateId", "app" => $this->AppName]);
return [ return [
"error" => $this->trans->t("Failed to delete template") "error" => $this->trans->t("Failed to delete template")
]; ];

View File

@@ -233,70 +233,70 @@ class AppConfig {
* *
* @var string * @var string
*/ */
public $_limitThumbSize = "limit_thumb_size"; public $limitThumbSize = "limit_thumb_size";
/** /**
* The config key for the customer * The config key for the customer
* *
* @var string * @var string
*/ */
public $_customization_customer = "customization_customer"; public $customization_customer = "customization_customer";
/** /**
* The config key for the loaderLogo * The config key for the loaderLogo
* *
* @var string * @var string
*/ */
public $_customization_loaderLogo = "customization_loaderLogo"; public $customization_loaderLogo = "customization_loaderLogo";
/** /**
* The config key for the loaderName * The config key for the loaderName
* *
* @var string * @var string
*/ */
public $_customization_loaderName = "customization_loaderName"; public $customization_loaderName = "customization_loaderName";
/** /**
* The config key for the logo * The config key for the logo
* *
* @var string * @var string
*/ */
public $_customization_logo = "customization_logo"; public $customization_logo = "customization_logo";
/** /**
* The config key for the zoom * The config key for the zoom
* *
* @var string * @var string
*/ */
public $_customization_zoom = "customization_zoom"; public $customization_zoom = "customization_zoom";
/** /**
* The config key for the autosave * The config key for the autosave
* *
* @var string * @var string
*/ */
public $_customization_autosave = "customization_autosave"; public $customization_autosave = "customization_autosave";
/** /**
* The config key for the goback * The config key for the goback
* *
* @var string * @var string
*/ */
public $_customization_goback = "customization_goback"; public $customization_goback = "customization_goback";
/** /**
* The config key for the macros * The config key for the macros
* *
* @var string * @var string
*/ */
public $_customization_macros = "customization_macros"; public $customization_macros = "customization_macros";
/** /**
* The config key for the plugins * The config key for the plugins
* *
* @var string * @var string
*/ */
public $_customizationPlugins = "customization_plugins"; public $customizationPlugins = "customization_plugins";
/** /**
* The config key for the interval of editors availability check by cron * The config key for the interval of editors availability check by cron
@@ -323,7 +323,7 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetSystemValue($key, $system = false) { public function getSystemValue($key, $system = false) {
if ($system) { if ($system) {
return $this->config->getSystemValue($key); return $this->config->getSystemValue($key);
} }
@@ -342,10 +342,10 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function SelectDemo($value) { public function selectDemo($value) {
$this->logger->info("Select demo: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Select demo: " . json_encode($value), ["app" => $this->appName]);
$data = $this->GetDemoData(); $data = $this->getDemoData();
if ($value === true && !$data["available"]) { if ($value === true && !$data["available"]) {
$this->logger->info("Trial demo is overdue: " . json_encode($data), ["app" => $this->appName]); $this->logger->info("Trial demo is overdue: " . json_encode($data), ["app" => $this->appName]);
@@ -366,7 +366,7 @@ class AppConfig {
* *
* @return array * @return array
*/ */
public function GetDemoData() { public function getDemoData() {
$data = $this->config->getAppValue($this->appName, $this->_demo, ""); $data = $this->config->getAppValue($this->appName, $this->_demo, "");
if (empty($data)) { if (empty($data)) {
@@ -395,8 +395,8 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function UseDemo() { public function useDemo() {
return $this->GetDemoData()["enabled"] === true; return $this->getDemoData()["enabled"] === true;
} }
/** /**
@@ -406,7 +406,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetDocumentServerUrl($documentServer) { public function setDocumentServerUrl($documentServer) {
$documentServer = trim($documentServer); $documentServer = trim($documentServer);
if (\strlen($documentServer) > 0) { if (\strlen($documentServer) > 0) {
$documentServer = rtrim($documentServer, "/") . "/"; $documentServer = rtrim($documentServer, "/") . "/";
@@ -415,7 +415,7 @@ class AppConfig {
} }
} }
$this->logger->info("SetDocumentServerUrl: $documentServer", ["app" => $this->appName]); $this->logger->info("setDocumentServerUrl: $documentServer", ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_documentserver, $documentServer); $this->config->setAppValue($this->appName, $this->_documentserver, $documentServer);
} }
@@ -427,14 +427,14 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetDocumentServerUrl($origin = false) { public function getDocumentServerUrl($origin = false) {
if (!$origin && $this->UseDemo()) { if (!$origin && $this->useDemo()) {
return $this->DEMO_PARAM["ADDR"]; return $this->DEMO_PARAM["ADDR"];
} }
$url = $this->config->getAppValue($this->appName, $this->_documentserver, ""); $url = $this->config->getAppValue($this->appName, $this->_documentserver, "");
if (empty($url)) { if (empty($url)) {
$url = $this->GetSystemValue($this->_documentserver); $url = $this->getSystemValue($this->_documentserver);
} }
if ($url !== "/") { if ($url !== "/") {
$url = rtrim($url, "/"); $url = rtrim($url, "/");
@@ -452,7 +452,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetDocumentServerInternalUrl($documentServerInternal) { public function setDocumentServerInternalUrl($documentServerInternal) {
$documentServerInternal = rtrim(trim($documentServerInternal), "/"); $documentServerInternal = rtrim(trim($documentServerInternal), "/");
if (\strlen($documentServerInternal) > 0) { if (\strlen($documentServerInternal) > 0) {
$documentServerInternal = $documentServerInternal . "/"; $documentServerInternal = $documentServerInternal . "/";
@@ -461,7 +461,7 @@ class AppConfig {
} }
} }
$this->logger->info("SetDocumentServerInternalUrl: $documentServerInternal", ["app" => $this->appName]); $this->logger->info("setDocumentServerInternalUrl: $documentServerInternal", ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_documentserverInternal, $documentServerInternal); $this->config->setAppValue($this->appName, $this->_documentserverInternal, $documentServerInternal);
} }
@@ -473,17 +473,17 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetDocumentServerInternalUrl($origin = false) { public function getDocumentServerInternalUrl($origin = false) {
if (!$origin && $this->UseDemo()) { if (!$origin && $this->useDemo()) {
return $this->GetDocumentServerUrl(); return $this->getDocumentServerUrl();
} }
$url = $this->config->getAppValue($this->appName, $this->_documentserverInternal, ""); $url = $this->config->getAppValue($this->appName, $this->_documentserverInternal, "");
if (empty($url)) { if (empty($url)) {
$url = $this->GetSystemValue($this->_documentserverInternal); $url = $this->getSystemValue($this->_documentserverInternal);
} }
if (!$origin && empty($url)) { if (!$origin && empty($url)) {
$url = $this->GetDocumentServerUrl(); $url = $this->getDocumentServerUrl();
} }
return $url; return $url;
} }
@@ -495,10 +495,10 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function ReplaceDocumentServerUrlToInternal($url) { public function replaceDocumentServerUrlToInternal($url) {
$documentServerUrl = $this->GetDocumentServerInternalUrl(); $documentServerUrl = $this->getDocumentServerInternalUrl();
if (!empty($documentServerUrl)) { if (!empty($documentServerUrl)) {
$from = $this->GetDocumentServerUrl(); $from = $this->getDocumentServerUrl();
if (!preg_match("/^https?:\/\//i", $from)) { if (!preg_match("/^https?:\/\//i", $from)) {
$parsedUrl = parse_url($url); $parsedUrl = parse_url($url);
@@ -517,11 +517,11 @@ class AppConfig {
/** /**
* Save the ownCloud address available from document server to the application configuration * Save the ownCloud address available from document server to the application configuration
* *
* @param string $documentServer - document service address * @param string $storageUrl - storage url
* *
* @return void * @return void
*/ */
public function SetStorageUrl($storageUrl) { public function setStorageUrl($storageUrl) {
$storageUrl = rtrim(trim($storageUrl), "/"); $storageUrl = rtrim(trim($storageUrl), "/");
if (\strlen($storageUrl) > 0) { if (\strlen($storageUrl) > 0) {
$storageUrl = $storageUrl . "/"; $storageUrl = $storageUrl . "/";
@@ -530,7 +530,7 @@ class AppConfig {
} }
} }
$this->logger->info("SetStorageUrl: $storageUrl", ["app" => $this->appName]); $this->logger->info("setStorageUrl: $storageUrl", ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_storageUrl, $storageUrl); $this->config->setAppValue($this->appName, $this->_storageUrl, $storageUrl);
} }
@@ -540,10 +540,10 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetStorageUrl() { public function getStorageUrl() {
$url = $this->config->getAppValue($this->appName, $this->_storageUrl, ""); $url = $this->config->getAppValue($this->appName, $this->_storageUrl, "");
if (empty($url)) { if (empty($url)) {
$url = $this->GetSystemValue($this->_storageUrl); $url = $this->getSystemValue($this->_storageUrl);
} }
return $url; return $url;
} }
@@ -555,7 +555,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetDocumentServerSecret($secret) { public function setDocumentServerSecret($secret) {
$secret = trim($secret); $secret = trim($secret);
if (empty($secret)) { if (empty($secret)) {
$this->logger->info("Clear secret key", ["app" => $this->appName]); $this->logger->info("Clear secret key", ["app" => $this->appName]);
@@ -573,14 +573,14 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetDocumentServerSecret($origin = false) { public function getDocumentServerSecret($origin = false) {
if (!$origin && $this->UseDemo()) { if (!$origin && $this->useDemo()) {
return $this->DEMO_PARAM["SECRET"]; return $this->DEMO_PARAM["SECRET"];
} }
$secret = $this->config->getAppValue($this->appName, $this->_jwtSecret, ""); $secret = $this->config->getAppValue($this->appName, $this->_jwtSecret, "");
if (empty($secret)) { if (empty($secret)) {
$secret = $this->GetSystemValue($this->_jwtSecret); $secret = $this->getSystemValue($this->_jwtSecret);
} }
return $secret; return $secret;
} }
@@ -590,10 +590,10 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetSKey() { public function getSKey() {
$secret = $this->GetDocumentServerSecret(); $secret = $this->getDocumentServerSecret();
if (empty($secret)) { if (empty($secret)) {
$secret = $this->GetSystemValue($this->_cryptSecret, true); $secret = $this->getSystemValue($this->_cryptSecret, true);
} }
return $secret; return $secret;
} }
@@ -605,7 +605,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetDefaultFormats($formats) { public function setDefaultFormats($formats) {
$value = json_encode($formats); $value = json_encode($formats);
$this->logger->info("Set default formats: $value", ["app" => $this->appName]); $this->logger->info("Set default formats: $value", ["app" => $this->appName]);
@@ -617,7 +617,7 @@ class AppConfig {
* *
* @return array * @return array
*/ */
private function GetDefaultFormats() { private function getDefaultFormats() {
$value = $this->config->getAppValue($this->appName, $this->_defFormats, ""); $value = $this->config->getAppValue($this->appName, $this->_defFormats, "");
if (empty($value)) { if (empty($value)) {
return []; return [];
@@ -632,7 +632,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetEditableFormats($formats) { public function setEditableFormats($formats) {
$value = json_encode($formats); $value = json_encode($formats);
$this->logger->info("Set editing formats: $value", ["app" => $this->appName]); $this->logger->info("Set editing formats: $value", ["app" => $this->appName]);
@@ -644,7 +644,7 @@ class AppConfig {
* *
* @return array * @return array
*/ */
private function GetEditableFormats() { private function getEditableFormats() {
$value = $this->config->getAppValue($this->appName, $this->_editFormats, ""); $value = $this->config->getAppValue($this->appName, $this->_editFormats, "");
if (empty($value)) { if (empty($value)) {
return []; return [];
@@ -659,7 +659,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetSameTab($value) { public function setSameTab($value) {
$this->logger->info("Set opening in a same tab: " . json_encode($value), ["app" => $this->appName]); $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)); $this->config->setAppValue($this->appName, $this->_sameTab, json_encode($value));
@@ -670,7 +670,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetSameTab() { public function getSameTab() {
return $this->config->getAppValue($this->appName, $this->_sameTab, "false") === "true"; return $this->config->getAppValue($this->appName, $this->_sameTab, "false") === "true";
} }
@@ -681,7 +681,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function SetPreview($value) { public function setPreview($value) {
$this->logger->info("Set generate preview: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set generate preview: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_preview, json_encode($value)); $this->config->setAppValue($this->appName, $this->_preview, json_encode($value));
@@ -692,7 +692,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetPreview() { public function getPreview() {
return $this->config->getAppValue($this->appName, $this->_preview, "true") === "true"; return $this->config->getAppValue($this->appName, $this->_preview, "true") === "true";
} }
@@ -703,7 +703,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetVersionHistory($value) { public function setVersionHistory($value) {
$this->logger->info("Set keep versions history: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set keep versions history: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_versionHistory, json_encode($value)); $this->config->setAppValue($this->appName, $this->_versionHistory, json_encode($value));
@@ -714,7 +714,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetVersionHistory() { public function getVersionHistory() {
return $this->config->getAppValue($this->appName, $this->_versionHistory, "true") === "true"; return $this->config->getAppValue($this->appName, $this->_versionHistory, "true") === "true";
} }
@@ -725,7 +725,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetProtection($value) { public function setProtection($value) {
$this->logger->info("Set protection: " . $value, ["app" => $this->appName]); $this->logger->info("Set protection: " . $value, ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_protection, $value); $this->config->setAppValue($this->appName, $this->_protection, $value);
@@ -736,7 +736,7 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetProtection() { public function getProtection() {
$value = $this->config->getAppValue($this->appName, $this->_protection, "owner"); $value = $this->config->getAppValue($this->appName, $this->_protection, "owner");
if ($value === "all") { if ($value === "all") {
return "all"; return "all";
@@ -751,7 +751,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationChat($value) { public function setCustomizationChat($value) {
$this->logger->info("Set chat display: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set chat display: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customizationChat, json_encode($value)); $this->config->setAppValue($this->appName, $this->_customizationChat, json_encode($value));
@@ -762,7 +762,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetCustomizationChat() { public function getCustomizationChat() {
return $this->config->getAppValue($this->appName, $this->_customizationChat, "true") === "true"; return $this->config->getAppValue($this->appName, $this->_customizationChat, "true") === "true";
} }
@@ -773,7 +773,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationCompactHeader($value) { public function setCustomizationCompactHeader($value) {
$this->logger->info("Set compact header display: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set compact header display: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customizationCompactHeader, json_encode($value)); $this->config->setAppValue($this->appName, $this->_customizationCompactHeader, json_encode($value));
@@ -784,7 +784,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetCustomizationCompactHeader() { public function getCustomizationCompactHeader() {
return $this->config->getAppValue($this->appName, $this->_customizationCompactHeader, "true") === "true"; return $this->config->getAppValue($this->appName, $this->_customizationCompactHeader, "true") === "true";
} }
@@ -795,7 +795,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationFeedback($value) { public function setCustomizationFeedback($value) {
$this->logger->info("Set feedback display: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set feedback display: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customizationFeedback, json_encode($value)); $this->config->setAppValue($this->appName, $this->_customizationFeedback, json_encode($value));
@@ -806,7 +806,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetCustomizationFeedback() { public function getCustomizationFeedback() {
return $this->config->getAppValue($this->appName, $this->_customizationFeedback, "true") === "true"; return $this->config->getAppValue($this->appName, $this->_customizationFeedback, "true") === "true";
} }
@@ -817,7 +817,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationForcesave($value) { public function setCustomizationForcesave($value) {
$this->logger->info("Set forcesave: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set forcesave: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customizationForcesave, json_encode($value)); $this->config->setAppValue($this->appName, $this->_customizationForcesave, json_encode($value));
@@ -828,7 +828,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetCustomizationForcesave() { public function getCustomizationForcesave() {
$value = $this->config->getAppValue($this->appName, $this->_customizationForcesave, "false") === "true"; $value = $this->config->getAppValue($this->appName, $this->_customizationForcesave, "false") === "true";
return $value && ($this->checkEncryptionModule() === false); return $value && ($this->checkEncryptionModule() === false);
@@ -841,7 +841,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationHelp($value) { public function setCustomizationHelp($value) {
$this->logger->info("Set help display: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set help display: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customizationHelp, json_encode($value)); $this->config->setAppValue($this->appName, $this->_customizationHelp, json_encode($value));
@@ -852,7 +852,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetCustomizationHelp() { public function getCustomizationHelp() {
return $this->config->getAppValue($this->appName, $this->_customizationHelp, "true") === "true"; return $this->config->getAppValue($this->appName, $this->_customizationHelp, "true") === "true";
} }
@@ -863,7 +863,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationToolbarNoTabs($value) { public function setCustomizationToolbarNoTabs($value) {
$this->logger->info("Set without tabs: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set without tabs: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customizationToolbarNoTabs, json_encode($value)); $this->config->setAppValue($this->appName, $this->_customizationToolbarNoTabs, json_encode($value));
@@ -874,7 +874,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetCustomizationToolbarNoTabs() { public function getCustomizationToolbarNoTabs() {
return $this->config->getAppValue($this->appName, $this->_customizationToolbarNoTabs, "true") === "true"; return $this->config->getAppValue($this->appName, $this->_customizationToolbarNoTabs, "true") === "true";
} }
@@ -885,7 +885,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationReviewDisplay($value) { public function setCustomizationReviewDisplay($value) {
$this->logger->info("Set review mode: " . $value, ["app" => $this->appName]); $this->logger->info("Set review mode: " . $value, ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customizationReviewDisplay, $value); $this->config->setAppValue($this->appName, $this->_customizationReviewDisplay, $value);
@@ -896,7 +896,7 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetCustomizationReviewDisplay() { public function getCustomizationReviewDisplay() {
$value = $this->config->getAppValue($this->appName, $this->_customizationReviewDisplay, "original"); $value = $this->config->getAppValue($this->appName, $this->_customizationReviewDisplay, "original");
if ($value === "markup") { if ($value === "markup") {
return "markup"; return "markup";
@@ -914,7 +914,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationTheme($value) { public function setCustomizationTheme($value) {
$this->logger->info("Set theme: " . $value, ["app" => $this->appName]); $this->logger->info("Set theme: " . $value, ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customizationTheme, $value); $this->config->setAppValue($this->appName, $this->_customizationTheme, $value);
@@ -925,7 +925,7 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetCustomizationTheme() { public function getCustomizationTheme() {
$value = $this->config->getAppValue($this->appName, $this->_customizationTheme, "theme-classic-light"); $value = $this->config->getAppValue($this->appName, $this->_customizationTheme, "theme-classic-light");
if ($value === "theme-light") { if ($value === "theme-light") {
return "theme-light"; return "theme-light";
@@ -943,10 +943,10 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationMacros($value) { public function setCustomizationMacros($value) {
$this->logger->info("Set macros enabled: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set macros enabled: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customization_macros, json_encode($value)); $this->config->setAppValue($this->appName, $this->customization_macros, json_encode($value));
} }
/** /**
@@ -954,8 +954,8 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetCustomizationMacros() { public function getCustomizationMacros() {
return $this->config->getAppValue($this->appName, $this->_customization_macros, "true") === "true"; return $this->config->getAppValue($this->appName, $this->customization_macros, "true") === "true";
} }
/** /**
@@ -965,10 +965,10 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetCustomizationPlugins($value) { public function setCustomizationPlugins($value) {
$this->logger->info("Set plugins enabled: " . json_encode($value), ["app" => $this->appName]); $this->logger->info("Set plugins enabled: " . json_encode($value), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_customizationPlugins, json_encode($value)); $this->config->setAppValue($this->appName, $this->customizationPlugins, json_encode($value));
} }
/** /**
@@ -976,8 +976,8 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetCustomizationPlugins() { public function getCustomizationPlugins() {
return $this->config->getAppValue($this->appName, $this->_customizationPlugins, "true") === "true"; return $this->config->getAppValue($this->appName, $this->customizationPlugins, "true") === "true";
} }
/** /**
@@ -987,7 +987,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetLimitGroups($groups) { public function setLimitGroups($groups) {
if (!\is_array($groups)) { if (!\is_array($groups)) {
$groups = []; $groups = [];
} }
@@ -1002,7 +1002,7 @@ class AppConfig {
* *
* @return array * @return array
*/ */
public function GetLimitGroups() { public function getLimitGroups() {
$value = $this->config->getAppValue($this->appName, $this->_groups, ""); $value = $this->config->getAppValue($this->appName, $this->_groups, "");
if (empty($value)) { if (empty($value)) {
return []; return [];
@@ -1028,7 +1028,7 @@ class AppConfig {
return false; return false;
} }
$groups = $this->GetLimitGroups(); $groups = $this->getLimitGroups();
// no group set -> all users are allowed // no group set -> all users are allowed
if (\count($groups) === 0) { if (\count($groups) === 0) {
return true; return true;
@@ -1048,7 +1048,7 @@ class AppConfig {
$group = \OC::$server->getGroupManager()->get($groupName); $group = \OC::$server->getGroupManager()->get($groupName);
if ($group === null) { if ($group === null) {
\OC::$server->getLogger()->error("Group is unknown $groupName", ["app" => $this->appName]); \OC::$server->getLogger()->error("Group is unknown $groupName", ["app" => $this->appName]);
$this->SetLimitGroups(array_diff($groups, [$groupName])); $this->setLimitGroups(array_diff($groups, [$groupName]));
} else { } else {
if ($group->inGroup($user)) { if ($group->inGroup($user)) {
return true; return true;
@@ -1066,8 +1066,8 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetVerifyPeerOff($verifyPeerOff) { public function setVerifyPeerOff($verifyPeerOff) {
$this->logger->info("SetVerifyPeerOff " . json_encode($verifyPeerOff), ["app" => $this->appName]); $this->logger->info("setVerifyPeerOff " . json_encode($verifyPeerOff), ["app" => $this->appName]);
$this->config->setAppValue($this->appName, $this->_verification, json_encode($verifyPeerOff)); $this->config->setAppValue($this->appName, $this->_verification, json_encode($verifyPeerOff));
} }
@@ -1077,14 +1077,14 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function GetVerifyPeerOff() { public function getVerifyPeerOff() {
$turnOff = $this->config->getAppValue($this->appName, $this->_verification, ""); $turnOff = $this->config->getAppValue($this->appName, $this->_verification, "");
if (!empty($turnOff)) { if (!empty($turnOff)) {
return $turnOff === "true"; return $turnOff === "true";
} }
return $this->GetSystemValue($this->_verification); return $this->getSystemValue($this->_verification);
} }
/** /**
@@ -1092,8 +1092,8 @@ class AppConfig {
* *
* @return int * @return int
*/ */
public function GetLimitThumbSize() { public function getLimitThumbSize() {
$limitSize = (integer)$this->GetSystemValue($this->_limitThumbSize); $limitSize = (integer)$this->getSystemValue($this->limitThumbSize);
if (!empty($limitSize)) { if (!empty($limitSize)) {
return $limitSize; return $limitSize;
@@ -1109,14 +1109,14 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function JwtHeader($origin = false) { public function jwtHeader($origin = false) {
if (!$origin && $this->UseDemo()) { if (!$origin && $this->useDemo()) {
return $this->DEMO_PARAM["HEADER"]; return $this->DEMO_PARAM["HEADER"];
} }
$header = $this->config->getAppValue($this->appName, $this->_jwtHeader, ""); $header = $this->config->getAppValue($this->appName, $this->_jwtHeader, "");
if (empty($header)) { if (empty($header)) {
$header = $this->GetSystemValue($this->_jwtHeader); $header = $this->getSystemValue($this->_jwtHeader);
} }
if (!$origin && empty($header)) { if (!$origin && empty($header)) {
$header = "Authorization"; $header = "Authorization";
@@ -1131,7 +1131,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetJwtHeader($value) { public function setJwtHeader($value) {
$value = trim($value); $value = trim($value);
if (empty($value)) { if (empty($value)) {
$this->logger->info("Clear header key", ["app" => $this->appName]); $this->logger->info("Clear header key", ["app" => $this->appName]);
@@ -1147,8 +1147,8 @@ class AppConfig {
* *
* @return int * @return int
*/ */
public function GetJwtLeeway() { public function getJwtLeeway() {
$jwtLeeway = (integer)$this->GetSystemValue($this->_jwtLeeway); $jwtLeeway = (integer)$this->getSystemValue($this->_jwtLeeway);
return $jwtLeeway; return $jwtLeeway;
} }
@@ -1160,7 +1160,7 @@ class AppConfig {
* *
* @return void * @return void
*/ */
public function SetSettingsError($value) { public function setSettingsError($value) {
$this->config->setAppValue($this->appName, $this->_settingsError, $value); $this->config->setAppValue($this->appName, $this->_settingsError, $value);
} }
@@ -1169,7 +1169,7 @@ class AppConfig {
* *
* @return bool * @return bool
*/ */
public function SettingsAreSuccessful() { public function settingsAreSuccessful() {
return empty($this->config->getAppValue($this->appName, $this->_settingsError, "")); return empty($this->config->getAppValue($this->appName, $this->_settingsError, ""));
} }
@@ -1202,17 +1202,17 @@ class AppConfig {
* *
* @NoAdminRequired * @NoAdminRequired
*/ */
public function FormatsSetting() { public function formatsSetting() {
$result = $this->formats; $result = $this->formats;
$defFormats = $this->GetDefaultFormats(); $defFormats = $this->getDefaultFormats();
foreach ($defFormats as $format => $setting) { foreach ($defFormats as $format => $setting) {
if (\array_key_exists($format, $result)) { if (\array_key_exists($format, $result)) {
$result[$format]["def"] = ($setting === true || $setting === "true"); $result[$format]["def"] = ($setting === true || $setting === "true");
} }
} }
$editFormats = $this->GetEditableFormats(); $editFormats = $this->getEditableFormats();
foreach ($editFormats as $format => $setting) { foreach ($editFormats as $format => $setting) {
if (\array_key_exists($format, $result)) { if (\array_key_exists($format, $result)) {
$result[$format]["edit"] = ($setting === true || $setting === "true"); $result[$format]["edit"] = ($setting === true || $setting === "true");
@@ -1227,7 +1227,7 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function ShareAttributesVersion() { public function shareAttributesVersion() {
if (\version_compare(\implode(".", \OCP\Util::getVersion()), "10.3.0", ">=")) { if (\version_compare(\implode(".", \OCP\Util::getVersion()), "10.3.0", ">=")) {
return "v2"; return "v2";
} elseif (\version_compare(\implode(".", \OCP\Util::getVersion()), "10.2.0", ">=")) { } elseif (\version_compare(\implode(".", \OCP\Util::getVersion()), "10.2.0", ">=")) {
@@ -1241,8 +1241,8 @@ class AppConfig {
* *
* @return int * @return int
*/ */
public function GetEditorsCheckInterval() { public function getEditorsCheckInterval() {
$interval = $this->GetSystemValue($this->_editors_check_interval); $interval = $this->getSystemValue($this->_editors_check_interval);
if (empty($interval) && $interval !== 0) { if (empty($interval) && $interval !== 0) {
$interval = 60 * 60 * 24; $interval = 60 * 60 * 24;
@@ -1310,7 +1310,7 @@ class AppConfig {
* *
* @return string * @return string
*/ */
public function GetLinkToDocs() { public function getLinkToDocs() {
return $this->linkToDocs; return $this->linkToDocs;
} }
} }

View File

@@ -113,7 +113,7 @@ class DocumentServer extends Command {
protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
$check = $input->getOption("check"); $check = $input->getOption("check");
$documentserver = $this->config->GetDocumentServerUrl(true); $documentserver = $this->config->getDocumentServerUrl(true);
if (empty($documentserver)) { if (empty($documentserver)) {
$output->writeln("<info>Document server is not configured</info>"); $output->writeln("<info>Document server is not configured</info>");
return 1; return 1;
@@ -123,7 +123,7 @@ class DocumentServer extends Command {
$documentService = new DocumentService($this->trans, $this->config); $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); $this->config->setSettingsError($error);
if (!empty($error)) { if (!empty($error)) {
$output->writeln("<error>Error connection: $error</error>"); $output->writeln("<error>Error connection: $error</error>");

View File

@@ -113,7 +113,7 @@ class EditorsCheck extends TimedJob {
$this->trans = $trans; $this->trans = $trans;
$this->crypt = $crypt; $this->crypt = $crypt;
$this->groupManager = $groupManager; $this->groupManager = $groupManager;
$this->setInterval($this->config->GetEditorsCheckInterval()); $this->setInterval($this->config->getEditorsCheckInterval());
} }
/** /**
@@ -124,17 +124,17 @@ class EditorsCheck extends TimedJob {
* @return void * @return void
*/ */
protected function run($argument) { protected function run($argument) {
if (empty($this->config->GetDocumentServerUrl())) { if (empty($this->config->getDocumentServerUrl())) {
$this->logger->debug("Settings are empty", ["app" => $this->appName]); $this->logger->debug("Settings are empty", ["app" => $this->appName]);
return; return;
} }
if (!$this->config->SettingsAreSuccessful()) { if (!$this->config->settingsAreSuccessful()) {
$this->logger->debug("Settings are not correct", ["app" => $this->appName]); $this->logger->debug("Settings are not correct", ["app" => $this->appName]);
return; return;
} }
$fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.emptyfile"); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.emptyfile");
if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) {
$fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $fileUrl);
} }
$host = parse_url($fileUrl)["host"]; $host = parse_url($fileUrl)["host"];
if ($host === "localhost" || $host === "127.0.0.1") { if ($host === "localhost" || $host === "127.0.0.1") {
@@ -148,7 +148,7 @@ class EditorsCheck extends TimedJob {
list($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt); list($error, $version) = $documentService->checkDocServiceUrl($this->urlGenerator, $this->crypt);
if (!empty($error)) { if (!empty($error)) {
$this->logger->info("ONLYOFFICE server is not available", ["app" => $this->appName]); $this->logger->info("ONLYOFFICE server is not available", ["app" => $this->appName]);
$this->config->SetSettingsError($error); $this->config->setSettingsError($error);
$this->notifyAdmins(); $this->notifyAdmins();
} else { } else {
$this->logger->debug("ONLYOFFICE server availability check is finished successfully", ["app" => $this->appName]); $this->logger->debug("ONLYOFFICE server availability check is finished successfully", ["app" => $this->appName]);

View File

@@ -49,8 +49,8 @@ class Crypt {
* *
* @return string * @return string
*/ */
public function GetHash($object) { public function getHash($object) {
return \Firebase\JWT\JWT::encode($object, $this->config->GetSKey(), "HS256"); return \Firebase\JWT\JWT::encode($object, $this->config->getSKey(), "HS256");
} }
/** /**
@@ -60,14 +60,14 @@ class Crypt {
* *
* @return array * @return array
*/ */
public function ReadHash($token) { public function readHash($token) {
$result = null; $result = null;
$error = null; $error = null;
if ($token === null) { if ($token === null) {
return [$result, "token is empty"]; return [$result, "token is empty"];
} }
try { 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) { } catch (\UnexpectedValueException $e) {
$error = $e->getMessage(); $error = $e->getMessage();
} }

View File

@@ -67,7 +67,7 @@ class DocumentService {
* *
* @return string * @return string
*/ */
public static function GenerateRevisionId($expected_key) { public static function generateRevisionId($expected_key) {
if (\strlen($expected_key) > 20) { if (\strlen($expected_key) > 20) {
$expected_key = crc32($expected_key); $expected_key = crc32($expected_key);
} }
@@ -86,12 +86,12 @@ class DocumentService {
* *
* @return string * @return string
*/ */
public function GetConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id) { public function getConvertedUri($document_uri, $from_extension, $to_extension, $document_revision_id) {
$responceFromConvertService = $this->SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, false); $responceFromConvertService = $this->sendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, false);
$errorElement = $responceFromConvertService->Error; $errorElement = $responceFromConvertService->Error;
if ($errorElement->count() > 0) { if ($errorElement->count() > 0) {
$this->ProcessConvServResponceError($errorElement . ""); $this->processConvServResponceError($errorElement . "");
} }
$isEndConvert = $responceFromConvertService->EndConvert; $isEndConvert = $responceFromConvertService->EndConvert;
@@ -104,7 +104,7 @@ class DocumentService {
} }
/** /**
* Request for conversion to a service * request for conversion to a service
* *
* @param string $document_uri - Uri for the document to convert * @param string $document_uri - Uri for the document to convert
* @param string $from_extension - Document extension * @param string $from_extension - Document extension
@@ -114,8 +114,8 @@ class DocumentService {
* *
* @return array * @return array
*/ */
public function SendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async) { public function sendRequestToConvertService($document_uri, $from_extension, $to_extension, $document_revision_id, $is_async) {
$documentServerUrl = $this->config->GetDocumentServerInternalUrl(); $documentServerUrl = $this->config->getDocumentServerInternalUrl();
if (empty($documentServerUrl)) { if (empty($documentServerUrl)) {
throw new \Exception($this->trans->t("ONLYOFFICE app is not configured. Please contact admin")); throw new \Exception($this->trans->t("ONLYOFFICE app is not configured. Please contact admin"));
@@ -127,7 +127,7 @@ class DocumentService {
$document_revision_id = $document_uri; $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)) { if (empty($from_extension)) {
$from_extension = pathinfo($document_uri)["extension"]; $from_extension = pathinfo($document_uri)["extension"];
@@ -145,8 +145,8 @@ class DocumentService {
"region" => str_replace("_", "-", \OC::$server->getL10NFactory("")->get("")->getLanguageCode()) "region" => str_replace("_", "-", \OC::$server->getL10NFactory("")->get("")->getLanguageCode())
]; ];
if ($this->config->UseDemo()) { if ($this->config->useDemo()) {
$data["tenant"] = $this->config->GetSystemValue("instanceid", true); $data["tenant"] = $this->config->getSystemValue("instanceid", true);
} }
$opts = [ $opts = [
@@ -157,19 +157,19 @@ class DocumentService {
"body" => json_encode($data) "body" => json_encode($data)
]; ];
if (!empty($this->config->GetDocumentServerSecret())) { if (!empty($this->config->getDocumentServerSecret())) {
$params = [ $params = [
"payload" => $data "payload" => $data
]; ];
$token = \Firebase\JWT\JWT::encode($params, $this->config->GetDocumentServerSecret(), "HS256"); $token = \Firebase\JWT\JWT::encode($params, $this->config->getDocumentServerSecret(), "HS256");
$opts["headers"][$this->config->JwtHeader()] = "Bearer " . $token; $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; $data["token"] = $token;
$opts["body"] = json_encode($data); $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); libxml_use_internal_errors(true);
if (!\function_exists("simplexml_load_file")) { if (!\function_exists("simplexml_load_file")) {
@@ -194,7 +194,7 @@ class DocumentService {
* *
* @return null * @return null
*/ */
public function ProcessConvServResponceError($errorCode) { public function processConvServResponceError($errorCode) {
$errorMessageTemplate = $this->trans->t("Error occurred in the document service"); $errorMessageTemplate = $this->trans->t("Error occurred in the document service");
$errorMessage = ""; $errorMessage = "";
@@ -237,12 +237,12 @@ class DocumentService {
} }
/** /**
* Request health status * request health status
* *
* @return bool * @return bool
*/ */
public function HealthcheckRequest() { public function healthcheckRequest() {
$documentServerUrl = $this->config->GetDocumentServerInternalUrl(); $documentServerUrl = $this->config->getDocumentServerInternalUrl();
if (empty($documentServerUrl)) { if (empty($documentServerUrl)) {
throw new \Exception($this->trans->t("ONLYOFFICE app is not configured. Please contact admin")); throw new \Exception($this->trans->t("ONLYOFFICE app is not configured. Please contact admin"));
@@ -250,7 +250,7 @@ class DocumentService {
$urlHealthcheck = $documentServerUrl . "healthcheck"; $urlHealthcheck = $documentServerUrl . "healthcheck";
$response = $this->Request($urlHealthcheck); $response = $this->request($urlHealthcheck);
return $response === "true"; return $response === "true";
} }
@@ -262,8 +262,8 @@ class DocumentService {
* *
* @return array * @return array
*/ */
public function CommandRequest($method) { public function commandRequest($method) {
$documentServerUrl = $this->config->GetDocumentServerInternalUrl(); $documentServerUrl = $this->config->getDocumentServerInternalUrl();
if (empty($documentServerUrl)) { if (empty($documentServerUrl)) {
throw new \Exception($this->trans->t("ONLYOFFICE app is not configured. Please contact admin")); throw new \Exception($this->trans->t("ONLYOFFICE app is not configured. Please contact admin"));
@@ -282,23 +282,23 @@ class DocumentService {
"body" => json_encode($data) "body" => json_encode($data)
]; ];
if (!empty($this->config->GetDocumentServerSecret())) { if (!empty($this->config->getDocumentServerSecret())) {
$params = [ $params = [
"payload" => $data "payload" => $data
]; ];
$token = \Firebase\JWT\JWT::encode($params, $this->config->GetDocumentServerSecret(), "HS256"); $token = \Firebase\JWT\JWT::encode($params, $this->config->getDocumentServerSecret(), "HS256");
$opts["headers"][$this->config->JwtHeader()] = "Bearer " . $token; $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; $data["token"] = $token;
$opts["body"] = json_encode($data); $opts["body"] = json_encode($data);
} }
$response = $this->Request($urlCommand, "post", $opts); $response = $this->request($urlCommand, "post", $opts);
$data = json_decode($response); $data = json_decode($response);
$this->ProcessCommandServResponceError($data->error); $this->processCommandServResponceError($data->error);
return $data; return $data;
} }
@@ -310,7 +310,7 @@ class DocumentService {
* *
* @return null * @return null
*/ */
public function ProcessCommandServResponceError($errorCode) { public function processCommandServResponceError($errorCode) {
$errorMessageTemplate = $this->trans->t("Error occurred in the document service"); $errorMessageTemplate = $this->trans->t("Error occurred in the document service");
$errorMessage = ""; $errorMessage = "";
@@ -335,7 +335,7 @@ class DocumentService {
} }
/** /**
* Request to Document Server with turn off verification * request to Document Server with turn off verification
* *
* @param string $url - request address * @param string $url - request address
* @param array $method - request method * @param array $method - request method
@@ -343,14 +343,14 @@ class DocumentService {
* *
* @return string * @return string
*/ */
public function Request($url, $method = "get", $opts = null) { public function request($url, $method = "get", $opts = null) {
$httpClientService = \OC::$server->getHTTPClientService(); $httpClientService = \OC::$server->getHTTPClientService();
$client = $httpClientService->newClient(); $client = $httpClientService->newClient();
if ($opts === null) { if ($opts === null) {
$opts = []; $opts = [];
} }
if (substr($url, 0, \strlen("https")) === "https" && $this->config->GetVerifyPeerOff()) { if (substr($url, 0, \strlen("https")) === "https" && $this->config->getVerifyPeerOff()) {
$opts["verify"] = false; $opts["verify"] = false;
} }
if (!\array_key_exists("timeout", $opts)) { if (!\array_key_exists("timeout", $opts)) {
@@ -380,7 +380,7 @@ class DocumentService {
try { try {
if (preg_match("/^https:\/\//i", $urlGenerator->getAbsoluteURL("/")) 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.")); throw new \Exception($this->trans->t("Mixed Active Content is not allowed. HTTPS address for ONLYOFFICE Docs is required."));
} }
@@ -390,19 +390,19 @@ class DocumentService {
} }
try { try {
$healthcheckResponse = $this->HealthcheckRequest(); $healthcheckResponse = $this->healthcheckRequest();
if (!$healthcheckResponse) { if (!$healthcheckResponse) {
throw new \Exception($this->trans->t("Bad healthcheck status")); throw new \Exception($this->trans->t("Bad healthcheck status"));
} }
} catch (\Exception $e) { } 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]; return [$e->getMessage(), $version];
} }
try { try {
$commandResponse = $this->CommandRequest("version"); $commandResponse = $this->commandRequest("version");
$logger->debug("CommandRequest on check: " . json_encode($commandResponse), ["app" => self::$appName]); $logger->debug("commandRequest on check: " . json_encode($commandResponse), ["app" => self::$appName]);
if (empty($commandResponse)) { if (empty($commandResponse)) {
throw new \Exception($this->trans->t("Error occurred in the document service")); throw new \Exception($this->trans->t("Error occurred in the document service"));
@@ -414,28 +414,28 @@ class DocumentService {
throw new \Exception($this->trans->t("Not supported version")); throw new \Exception($this->trans->t("Not supported version"));
} }
} catch (\Exception $e) { } 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]; return [$e->getMessage(), $version];
} }
$convertedFileUri = null; $convertedFileUri = null;
try { try {
$hashUrl = $crypt->GetHash(["action" => "empty"]); $hashUrl = $crypt->getHash(["action" => "empty"]);
$fileUrl = $urlGenerator->linkToRouteAbsolute(self::$appName . ".callback.emptyfile", ["doc" => $hashUrl]); $fileUrl = $urlGenerator->linkToRouteAbsolute(self::$appName . ".callback.emptyfile", ["doc" => $hashUrl]);
if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) {
$fileUrl = str_replace($urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); $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());
} catch (\Exception $e) { } 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]; return [$e->getMessage(), $version];
} }
try { try {
$this->Request($convertedFileUri); $this->request($convertedFileUri);
} catch (\Exception $e) { } catch (\Exception $e) {
$logger->logException($e, ["message" => "Request converted file on check error", "app" => self::$appName]); $logger->logException($e, ["message" => "request converted file on check error", "app" => self::$appName]);
return [$e->getMessage(), $version]; return [$e->getMessage(), $version];
} }

View File

@@ -235,7 +235,7 @@ class FileUtility {
$key = KeyManager::get($fileId); $key = KeyManager::get($fileId);
if (empty($key)) { if (empty($key)) {
$instanceId = $this->config->GetSystemValue("instanceid", true); $instanceId = $this->config->getSystemValue("instanceid", true);
$key = $instanceId . "_" . $this->GUID(); $key = $instanceId . "_" . $this->GUID();
@@ -291,7 +291,7 @@ class FileUtility {
* @return string * @return string
*/ */
public function getVersionKey($version) { public function getVersionKey($version) {
$instanceId = $this->config->GetSystemValue("instanceid", true); $instanceId = $this->config->getSystemValue("instanceid", true);
$key = $instanceId . "_" . $version->getSourceFile()->getEtag() . "_" . $version->getRevisionId(); $key = $instanceId . "_" . $version->getSourceFile()->getEtag() . "_" . $version->getRevisionId();

View File

@@ -36,16 +36,16 @@ class HookHandler {
* *
* @return void * @return void
*/ */
public static function PublicPage() { public static function publicPage() {
$appName = "onlyoffice"; $appName = "onlyoffice";
$appConfig = new AppConfig($appName); $appConfig = new AppConfig($appName);
if (!empty($appConfig->GetDocumentServerUrl()) && $appConfig->SettingsAreSuccessful()) { if (!empty($appConfig->getDocumentServerUrl()) && $appConfig->settingsAreSuccessful()) {
Util::addScript("onlyoffice", "main"); Util::addScript("onlyoffice", "main");
Util::addScript("onlyoffice", "share"); Util::addScript("onlyoffice", "share");
if ($appConfig->GetSameTab()) { if ($appConfig->getSameTab()) {
Util::addScript("onlyoffice", "listener"); Util::addScript("onlyoffice", "listener");
} }

View File

@@ -233,12 +233,12 @@ class Preview implements IProvider2 {
* @return bool * @return bool
*/ */
public function isAvailable(FileInfo $fileInfo) { public function isAvailable(FileInfo $fileInfo) {
if ($this->config->GetPreview() !== true) { if ($this->config->getPreview() !== true) {
return false; return false;
} }
if (!$fileInfo if (!$fileInfo
|| $fileInfo->getSize() === 0 || $fileInfo->getSize() === 0
|| $fileInfo->getSize() > $this->config->GetLimitThumbSize() || $fileInfo->getSize() > $this->config->getLimitThumbSize()
) { ) {
return false; return false;
} }
@@ -274,14 +274,14 @@ class Preview implements IProvider2 {
$imageUrl = null; $imageUrl = null;
$documentService = new DocumentService($this->trans, $this->config); $documentService = new DocumentService($this->trans, $this->config);
try { try {
$imageUrl = $documentService->GetConvertedUri($fileUrl, $extension, self::THUMBEXTENSION, $key); $imageUrl = $documentService->getConvertedUri($fileUrl, $extension, self::THUMBEXTENSION, $key);
} catch (\Exception $e) { } 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; return false;
} }
try { try {
$thumbnail = $documentService->Request($imageUrl); $thumbnail = $documentService->request($imageUrl);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->logException($e, ["message" => "Failed to download thumbnail", "app" => $this->appName]); $this->logger->logException($e, ["message" => "Failed to download thumbnail", "app" => $this->appName]);
return false; return false;
@@ -322,12 +322,12 @@ class Preview implements IProvider2 {
$data["version"] = $version; $data["version"] = $version;
} }
$hashUrl = $this->crypt->GetHash($data); $hashUrl = $this->crypt->getHash($data);
$fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]); $fileUrl = $this->urlGenerator->linkToRouteAbsolute($this->appName . ".callback.download", ["doc" => $hashUrl]);
if (!$this->config->UseDemo() && !empty($this->config->GetStorageUrl())) { if (!$this->config->useDemo() && !empty($this->config->getStorageUrl())) {
$fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->GetStorageUrl(), $fileUrl); $fileUrl = str_replace($this->urlGenerator->getAbsoluteURL("/"), $this->config->getStorageUrl(), $fileUrl);
} }
return $fileUrl; return $fileUrl;
@@ -378,7 +378,7 @@ class Preview implements IProvider2 {
$versionId = $version->getRevisionId(); $versionId = $version->getRevisionId();
if (strcmp($versionId, $fileVersion) === 0) { if (strcmp($versionId, $fileVersion) === 0) {
$key = $this->fileUtility->getVersionKey($version); $key = $this->fileUtility->getVersionKey($version);
$key = DocumentService::GenerateRevisionId($key); $key = DocumentService::generateRevisionId($key);
break; break;
} }
@@ -387,7 +387,7 @@ class Preview implements IProvider2 {
$owner = $file->getOwner(); $owner = $file->getOwner();
$key = $this->fileUtility->getKey($file); $key = $this->fileUtility->getKey($file);
$key = DocumentService::GenerateRevisionId($key); $key = DocumentService::generateRevisionId($key);
} }
$fileUrl = $this->getUrl($file, $owner, $versionNum); $fileUrl = $this->getUrl($file, $owner, $versionNum);

View File

@@ -48,7 +48,7 @@ class TemplateManager {
* *
* @return Folder * @return Folder
*/ */
public static function GetGlobalTemplateDir() { public static function getGlobalTemplateDir() {
$dirPath = self::$appName . "/" . self::$templateFolderName; $dirPath = self::$appName . "/" . self::$templateFolderName;
$rootFolder = \OC::$server->getRootFolder(); $rootFolder = \OC::$server->getRootFolder();
@@ -69,8 +69,8 @@ class TemplateManager {
* *
* @return array * @return array
*/ */
public static function GetGlobalTemplates($mimetype = null) { public static function getGlobalTemplates($mimetype = null) {
$templateDir = self::GetGlobalTemplateDir(); $templateDir = self::getGlobalTemplateDir();
$templatesList = $templateDir->getDirectoryListing(); $templatesList = $templateDir->getDirectoryListing();
if (!empty($mimetype) if (!empty($mimetype)
@@ -89,14 +89,14 @@ class TemplateManager {
* *
* @return File * @return File
*/ */
public static function GetTemplate($templateId) { public static function getTemplate($templateId) {
$logger = \OC::$server->getLogger(); $logger = \OC::$server->getLogger();
$templateDir = self::GetGlobalTemplateDir(); $templateDir = self::getGlobalTemplateDir();
try { try {
$templates = $templateDir->getById($templateId); $templates = $templateDir->getById($templateId);
} catch(\Exception $e) { } catch(\Exception $e) {
$logger->logException($e, ["message" => "GetTemplate: $templateId", "app" => self::$appName]); $logger->logException($e, ["message" => "getTemplate: $templateId", "app" => self::$appName]);
return null; return null;
} }
@@ -115,7 +115,7 @@ class TemplateManager {
* *
* @return string * @return string
*/ */
public static function GetTypeTemplate($mime) { public static function getTypeTemplate($mime) {
switch($mime) { switch($mime) {
case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
return "document"; return "document";
@@ -135,7 +135,7 @@ class TemplateManager {
* *
* @return bool * @return bool
*/ */
public static function IsTemplateType($name) { public static function isTemplateType($name) {
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
switch($ext) { switch($ext) {
case "docx": case "docx":
@@ -154,11 +154,11 @@ class TemplateManager {
* *
* @return string * @return string
*/ */
public static function GetEmptyTemplate($fileName) { public static function getEmptyTemplate($fileName) {
$ext = strtolower("." . pathinfo($fileName, PATHINFO_EXTENSION)); $ext = strtolower("." . pathinfo($fileName, PATHINFO_EXTENSION));
$lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode(); $lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode();
$templatePath = self::GetEmptyTemplatePath($lang, $ext); $templatePath = self::getEmptyTemplatePath($lang, $ext);
$template = file_get_contents($templatePath); $template = file_get_contents($templatePath);
return $template; return $template;
@@ -172,7 +172,7 @@ class TemplateManager {
* *
* @return string * @return string
*/ */
public static function GetEmptyTemplatePath($lang, $ext) { public static function getEmptyTemplatePath($lang, $ext) {
if (!\array_key_exists($lang, self::$localPath)) { if (!\array_key_exists($lang, self::$localPath)) {
$lang = "en"; $lang = "en";
} }