1
0
mirror of https://github.com/ONLYOFFICE/onlyoffice-owncloud.git synced 2025-07-30 10:43:07 +03:00

oc native function invocation

This commit is contained in:
rivexe
2023-12-18 14:52:00 +03:00
parent 696b4aca2b
commit 79555b55cc
13 changed files with 62 additions and 62 deletions

View File

@ -202,7 +202,7 @@ class CallbackController extends Controller {
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
}
$header = substr($header, strlen("Bearer "));
$header = substr($header, \strlen("Bearer "));
try {
$decodedHeader = \Firebase\JWT\JWT::decode($header, new \Firebase\JWT\Key($this->config->GetDocumentServerSecret(), "HS256"));
@ -275,7 +275,7 @@ class CallbackController extends Controller {
$versions = array_reverse($this->versionManager->getVersionsForFile($owner, $file->getFileInfo()));
$versionId = null;
if ($version > count($versions)) {
if ($version > \count($versions)) {
$versionId = $file->getFileInfo()->getMtime();
} else {
$fileVersion = array_values($versions)[$version - 1];
@ -339,7 +339,7 @@ class CallbackController extends Controller {
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
}
$header = substr($header, strlen("Bearer "));
$header = substr($header, \strlen("Bearer "));
try {
$decodedHeader = \Firebase\JWT\JWT::decode($header, new \Firebase\JWT\Key($this->config->GetDocumentServerSecret(), "HS256"));
@ -417,7 +417,7 @@ class CallbackController extends Controller {
return new JSONResponse(["message" => $this->trans->t("Access denied")], Http::STATUS_FORBIDDEN);
}
$header = substr($header, strlen("Bearer "));
$header = substr($header, \strlen("Bearer "));
try {
$decodedHeader = \Firebase\JWT\JWT::decode($header, new \Firebase\JWT\Key($this->config->GetDocumentServerSecret(), "HS256"));
@ -625,7 +625,7 @@ class CallbackController extends Controller {
$file = $files[0];
if (count($files) > 1 && !empty($filePath)) {
if (\count($files) > 1 && !empty($filePath)) {
$filePath = "/" . $userId . "/files" . $filePath;
foreach ($files as $curFile) {
if ($curFile->getPath() === $filePath) {
@ -654,7 +654,7 @@ class CallbackController extends Controller {
$versions = array_reverse($this->versionManager->getVersionsForFile($owner, $file->getFileInfo()));
if ($version <= count($versions)) {
if ($version <= \count($versions)) {
$fileVersion = array_values($versions)[$version - 1];
$file = $this->versionManager->getVersionFile($owner, $file->getFileInfo(), $fileVersion->getRevisionId());
}
@ -709,7 +709,7 @@ class CallbackController extends Controller {
if ($owner !== null) {
$versions = array_reverse($this->versionManager->getVersionsForFile($owner, $file->getFileInfo()));
if ($version <= count($versions)) {
if ($version <= \count($versions)) {
$fileVersion = array_values($versions)[$version - 1];
$file = $this->versionManager->getVersionFile($owner, $file->getFileInfo(), $fileVersion->getRevisionId());
}
@ -757,8 +757,8 @@ class CallbackController extends Controller {
$instanceId = $this->config->GetSystemValue("instanceid", true);
$instanceId = $instanceId . "_";
if (substr($userId, 0, strlen($instanceId)) === $instanceId) {
return substr($userId, strlen($instanceId));
if (substr($userId, 0, \strlen($instanceId)) === $instanceId) {
return substr($userId, \strlen($instanceId));
}
return $userId;

View File

@ -266,7 +266,7 @@ class EditorApiController extends OCSController {
$fileName = $file->getName();
$ext = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
$format = !empty($ext) && array_key_exists($ext, $this->config->FormatsSetting()) ? $this->config->FormatsSetting()[$ext] : null;
$format = !empty($ext) && \array_key_exists($ext, $this->config->FormatsSetting()) ? $this->config->FormatsSetting()[$ext] : null;
if (!isset($format)) {
$this->logger->info("Format is not supported for editing: $fileName", ["app" => $this->appName]);
return new JSONResponse(["error" => $this->trans->t("Format is not supported")]);
@ -281,7 +281,7 @@ class EditorApiController extends OCSController {
if ($owner !== null) {
$versions = array_reverse($this->versionManager->getVersionsForFile($owner, $file->getFileInfo()));
if ($version <= count($versions)) {
if ($version <= \count($versions)) {
$fileVersion = array_values($versions)[$version - 1];
$key = $this->fileUtility->getVersionKey($fileVersion);
@ -361,7 +361,7 @@ class EditorApiController extends OCSController {
&& (\OC::$server->getConfig()->getAppValue("files", "enable_lock_file_action", "no") === "yes")
&& $fileStorage->instanceOfStorage(IPersistentLockingStorage::class)) {
$locks = $fileStorage->getLocks($file->getFileInfo()->getInternalPath(), false);
if (count($locks) > 0) {
if (\count($locks) > 0) {
$activeLock = $locks[0];
if ($accountId !== $activeLock->getOwnerAccountId()) {
@ -582,7 +582,7 @@ class EditorApiController extends OCSController {
$file = $files[0];
if (count($files) > 1 && !empty($filePath)) {
if (\count($files) > 1 && !empty($filePath)) {
$filePath = "/" . $userId . "/files" . $filePath;
foreach ($files as $curFile) {
if ($curFile->getPath() === $filePath) {
@ -763,7 +763,7 @@ class EditorApiController extends OCSController {
private function isFavorite($fileId) {
$currentTags = $this->tagManager->load("files")->getTagsForObjects([$fileId]);
if ($currentTags) {
return in_array(Tags::TAG_FAVORITE, $currentTags[$fileId]);
return \in_array(Tags::TAG_FAVORITE, $currentTags[$fileId]);
}
return false;

View File

@ -377,7 +377,7 @@ class EditorController extends Controller {
foreach ($currentUserGroups as $currentUserGroup) {
$group = $this->groupManager->get($currentUserGroup);
foreach ($group->getUsers() as $user) {
if (!in_array($user, $users)) {
if (!\in_array($user, $users)) {
array_push($users, $user);
}
}
@ -391,7 +391,7 @@ class EditorController extends Controller {
if (!$all) {
$accessList = $this->getAccessList($file);
foreach ($accessList as $accessUser) {
if (!in_array($accessUser, $users)) {
if (!\in_array($accessUser, $users)) {
array_push($users, $accessUser);
}
}
@ -439,7 +439,7 @@ class EditorController extends Controller {
$recipients = $this->userManager->getByEmail($email);
foreach ($recipients as $recipient) {
$recipientId = $recipient->getUID();
if (!in_array($recipientId, $recipientIds)) {
if (!\in_array($recipientId, $recipientIds)) {
array_push($recipientIds, $recipientId);
}
}
@ -465,9 +465,9 @@ class EditorController extends Controller {
//Length from ownCloud:
//https://github.com/owncloud/core/blob/master/lib/private/Notification/Notification.php#L181
$maxLen = 64;
if (strlen($comment) > $maxLen) {
if (\strlen($comment) > $maxLen) {
$ending = "...";
$comment = substr($comment, 0, ($maxLen - strlen($ending))) . $ending;
$comment = substr($comment, 0, ($maxLen - \strlen($ending))) . $ending;
}
$notificationManager = \OC::$server->getNotificationManager();
@ -494,7 +494,7 @@ class EditorController extends Controller {
foreach ($recipientIds as $recipientId) {
$recipient = $this->userManager->get($recipientId);
$isAvailable = in_array($recipient, $accessList);
$isAvailable = \in_array($recipient, $accessList);
if (!$isAvailable
&& $file->getFileInfo()->getMountPoint() instanceof \OCA\Files_External\Config\ExternalMountPoint) {
@ -692,7 +692,7 @@ class EditorController extends Controller {
return ["error" => $this->trans->t("Failed to download converted file")];
}
$fileNameWithoutExt = substr($fileName, 0, strlen($fileName) - strlen($ext) - 1);
$fileNameWithoutExt = substr($fileName, 0, \strlen($fileName) - \strlen($ext) - 1);
$newFileName = $folder->getNonExistingName($fileNameWithoutExt . "." . $internalExtension);
try {
@ -944,7 +944,7 @@ class EditorController extends Controller {
$key = null;
$fileUrl = null;
$versionId = null;
if ($version > count($versions)) {
if ($version > \count($versions)) {
$key = $this->fileUtility->getKey($file, true);
$versionId = $file->getFileInfo()->getMtime();
@ -969,7 +969,7 @@ class EditorController extends Controller {
];
if ($version > 1
&& count($versions) >= $version - 1
&& \count($versions) >= $version - 1
&& FileVersions::hasChanges($ownerId, $fileId, $versionId)) {
$changesUrl = $this->getUrl($file, $user, null, $version, true);
$result["changesUrl"] = $changesUrl;
@ -1040,7 +1040,7 @@ class EditorController extends Controller {
$versions = array_reverse($this->versionManager->getVersionsForFile($owner, $file->getFileInfo()));
}
if (count($versions) >= $version) {
if (\count($versions) >= $version) {
$fileVersion = array_values($versions)[$version - 1];
$this->versionManager->rollback($fileVersion);
}
@ -1173,7 +1173,7 @@ class EditorController extends Controller {
return $this->renderError($this->trans->t("Failed to download converted file"));
}
$fileNameWithoutExt = substr($fileName, 0, strlen($fileName) - strlen($ext) - 1);
$fileNameWithoutExt = substr($fileName, 0, \strlen($fileName) - \strlen($ext) - 1);
$newFileName = $fileNameWithoutExt . "." . $toExtension;
$formats = $this->config->FormatsSetting();
@ -1306,7 +1306,7 @@ class EditorController extends Controller {
$file = $files[0];
if (count($files) > 1 && !empty($filePath)) {
if (\count($files) > 1 && !empty($filePath)) {
$filePath = "/" . $userId . "/files" . $filePath;
foreach ($files as $curFile) {
if ($curFile->getPath() === $filePath) {
@ -1404,13 +1404,13 @@ class EditorController extends Controller {
}
foreach ($accessList as $accessUser) {
if (!in_array($accessUser, $result)) {
if (!\in_array($accessUser, $result)) {
array_push($result, $accessUser);
}
}
}
if (!in_array($file->getOwner(), $result)) {
if (!\in_array($file->getOwner(), $result)) {
array_push($result, $file->getOwner());
}

View File

@ -92,7 +92,7 @@ class TemplateController extends Controller {
public function AddTemplate() {
$file = $this->request->getUploadedFile("file");
if (!is_null($file)) {
if (!\is_null($file)) {
if (is_uploaded_file($file["tmp_name"]) && $file["error"] === 0) {
if (!TemplateManager::IsTemplateType($file["name"])) {
return [

View File

@ -327,7 +327,7 @@ class AppConfig {
return $this->config->getSystemValue($key);
}
if (!empty($this->config->getSystemValue($this->appName))
&& array_key_exists($key, $this->config->getSystemValue($this->appName))) {
&& \array_key_exists($key, $this->config->getSystemValue($this->appName))) {
return $this->config->getSystemValue($this->appName)[$key];
}
return null;
@ -404,7 +404,7 @@ class AppConfig {
*/
public function SetDocumentServerUrl($documentServer) {
$documentServer = trim($documentServer);
if (strlen($documentServer) > 0) {
if (\strlen($documentServer) > 0) {
$documentServer = rtrim($documentServer, "/") . "/";
if (!preg_match("/(^https?:\/\/)|^\//i", $documentServer)) {
$documentServer = "http://" . $documentServer;
@ -434,7 +434,7 @@ class AppConfig {
}
if ($url !== "/") {
$url = rtrim($url, "/");
if (strlen($url) > 0) {
if (\strlen($url) > 0) {
$url = $url . "/";
}
}
@ -448,7 +448,7 @@ class AppConfig {
*/
public function SetDocumentServerInternalUrl($documentServerInternal) {
$documentServerInternal = rtrim(trim($documentServerInternal), "/");
if (strlen($documentServerInternal) > 0) {
if (\strlen($documentServerInternal) > 0) {
$documentServerInternal = $documentServerInternal . "/";
if (!preg_match("/^https?:\/\//i", $documentServerInternal)) {
$documentServerInternal = "http://" . $documentServerInternal;
@ -496,7 +496,7 @@ class AppConfig {
if (!preg_match("/^https?:\/\//i", $from)) {
$parsedUrl = parse_url($url);
$from = $parsedUrl["scheme"] . "://" . $parsedUrl["host"] . (array_key_exists("port", $parsedUrl) ? (":" . $parsedUrl["port"]) : "") . $from;
$from = $parsedUrl["scheme"] . "://" . $parsedUrl["host"] . (\array_key_exists("port", $parsedUrl) ? (":" . $parsedUrl["port"]) : "") . $from;
}
if ($from !== $documentServerUrl) {
@ -515,7 +515,7 @@ class AppConfig {
*/
public function SetStorageUrl($storageUrl) {
$storageUrl = rtrim(trim($storageUrl), "/");
if (strlen($storageUrl) > 0) {
if (\strlen($storageUrl) > 0) {
$storageUrl = $storageUrl . "/";
if (!preg_match("/^https?:\/\//i", $storageUrl)) {
$storageUrl = "http://" . $storageUrl;
@ -944,7 +944,7 @@ class AppConfig {
* @param array $groups - the list of groups
*/
public function SetLimitGroups($groups) {
if (!is_array($groups)) {
if (!\is_array($groups)) {
$groups = array();
}
$value = json_encode($groups);
@ -964,7 +964,7 @@ class AppConfig {
return array();
}
$groups = json_decode($value, true);
if (!is_array($groups)) {
if (!\is_array($groups)) {
$groups = array();
}
return $groups;
@ -980,17 +980,17 @@ class AppConfig {
public function isUserAllowedToUse($userId = null) {
// no user -> no
$userSession = \OC::$server->getUserSession();
if (is_null($userId) && ($userSession === null || !$userSession->isLoggedIn())) {
if (\is_null($userId) && ($userSession === null || !$userSession->isLoggedIn())) {
return false;
}
$groups = $this->GetLimitGroups();
// no group set -> all users are allowed
if (count($groups) === 0) {
if (\count($groups) === 0) {
return true;
}
if (is_null($userId)) {
if (\is_null($userId)) {
$user = $userSession->getUser();
} else {
$user = \OC::$server->getUserManager()->get($userId);
@ -1157,14 +1157,14 @@ class AppConfig {
$defFormats = $this->GetDefaultFormats();
foreach ($defFormats as $format => $setting) {
if (array_key_exists($format, $result)) {
if (\array_key_exists($format, $result)) {
$result[$format]["def"] = ($setting === true || $setting === "true");
}
}
$editFormats = $this->GetEditableFormats();
foreach ($editFormats as $format => $setting) {
if (array_key_exists($format, $result)) {
if (\array_key_exists($format, $result)) {
$result[$format]["edit"] = ($setting === true || $setting === "true");
}
}

View File

@ -67,11 +67,11 @@ class DocumentService {
* @return string
*/
public static function GenerateRevisionId($expected_key) {
if (strlen($expected_key) > 20) {
if (\strlen($expected_key) > 20) {
$expected_key = crc32($expected_key);
}
$key = preg_replace("[^0-9-.a-zA-Z_=]", "_", $expected_key);
$key = substr($key, 0, min(array(strlen($key), 20)));
$key = substr($key, 0, min(array(\strlen($key), 20)));
return $key;
}
@ -171,7 +171,7 @@ class DocumentService {
$response_xml_data = $this->Request($urlToConverter, "post", $opts);
libxml_use_internal_errors(true);
if (!function_exists("simplexml_load_file")) {
if (!\function_exists("simplexml_load_file")) {
throw new \Exception($this->trans->t("Server can't read xml"));
}
$response_data = simplexml_load_string($response_xml_data);
@ -349,10 +349,10 @@ class DocumentService {
if (null === $opts) {
$opts = array();
}
if (substr($url, 0, strlen("https")) === "https" && $this->config->GetVerifyPeerOff()) {
if (substr($url, 0, \strlen("https")) === "https" && $this->config->GetVerifyPeerOff()) {
$opts["verify"] = false;
}
if (!array_key_exists("timeout", $opts)) {
if (!\array_key_exists("timeout", $opts)) {
$opts["timeout"] = 60;
}
@ -407,7 +407,7 @@ class DocumentService {
}
$version = $commandResponse->version;
$versionF = floatval($version);
$versionF = \floatval($version);
if ($versionF > 0.0 && $versionF <= 6.0) {
throw new \Exception($this->trans->t("Not supported version"));
}

View File

@ -273,7 +273,7 @@ class FileUtility {
* @return string
*/
private function GUID() {
if (function_exists("com_create_guid") === true) {
if (\function_exists("com_create_guid") === true) {
return trim(com_create_guid(), "{}");
}

View File

@ -75,7 +75,7 @@ class FileVersions {
return false;
}
$filePath = substr($pathVersion, 0, $pos);
$versionId = substr($pathVersion, 2 + $pos - strlen($pathVersion));
$versionId = substr($pathVersion, 2 + $pos - \strlen($pathVersion));
return [$filePath, $versionId];
}

View File

@ -47,7 +47,7 @@ class KeyManager {
$result = $select->execute([$fileId]);
$keys = $result ? $select->fetch() : [];
$key = is_array($keys) && isset($keys["key"]) ? $keys["key"] : "";
$key = \is_array($keys) && isset($keys["key"]) ? $keys["key"] : "";
return $key;
}
@ -142,7 +142,7 @@ class KeyManager {
$result = $select->execute([$fileId]);
$rows = $result ? $select->fetch() : [];
$fs = is_array($rows) && isset($rows["fs"]) ? $rows["fs"] : "";
$fs = \is_array($rows) && isset($rows["fs"]) ? $rows["fs"] : "";
return $fs === "1";
}

View File

@ -236,7 +236,7 @@ class Preview implements IProvider2 {
|| $fileInfo->getSize() > $this->config->GetLimitThumbSize()) {
return false;
}
if (!in_array($fileInfo->getMimetype(), self::$capabilities, true)) {
if (!\in_array($fileInfo->getMimetype(), self::$capabilities, true)) {
return false;
}
return true;

View File

@ -117,7 +117,7 @@ class RemoteInstance {
$logger = \OC::$server->getLogger();
$remote = rtrim($remote, "/") . "/";
if (in_array($remote, self::$healthRemote)) {
if (\in_array($remote, self::$healthRemote)) {
$logger->debug("Remote instance " . $remote . " from local cache status " . $dbremote["status"], ["app" => self::App_Name]);
return true;
}

View File

@ -73,7 +73,7 @@ class TemplateManager {
$templatesList = $templateDir->getDirectoryListing();
if (!empty($mimetype)
&& is_array($templatesList) && count($templatesList) > 0) {
&& \is_array($templatesList) && \count($templatesList) > 0) {
$templatesList = $templateDir->searchByMime($mimetype);
}
@ -171,11 +171,11 @@ class TemplateManager {
* @return string
*/
public static function GetEmptyTemplatePath($lang, $ext) {
if (!array_key_exists($lang, self::$localPath)) {
if (!\array_key_exists($lang, self::$localPath)) {
$lang = "en";
}
return dirname(__DIR__) . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . self::$localPath[$lang] . DIRECTORY_SEPARATOR . "new" . $ext;
return \dirname(__DIR__) . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . self::$localPath[$lang] . DIRECTORY_SEPARATOR . "new" . $ext;
}
/**

View File

@ -119,7 +119,7 @@ script("onlyoffice", "template");
<p>
<input type="checkbox" class="checkbox" id="onlyofficeGroups"
<?php if (count($_["limitGroups"]) > 0) { ?>checked="checked"<?php } ?> />
<?php if (\count($_["limitGroups"]) > 0) { ?>checked="checked"<?php } ?> />
<label for="onlyofficeGroups"><?php p($l->t("Restrict access to editors to following groups")) ?></label>
<br />
<input type="hidden" id="onlyofficeLimitGroups" value="<?php p(implode("|", $_["limitGroups"])) ?>"
@ -148,12 +148,12 @@ script("onlyoffice", "template");
<p class="onlyoffice-header"><?php p($l->t("The default application for opening the format")) ?></p>
<div class="onlyoffice-exts">
<?php foreach ($_["formats"] as $format => $setting) { ?>
<?php if (array_key_exists("mime", $setting)) { ?>
<?php if (\array_key_exists("mime", $setting)) { ?>
<div>
<input type="checkbox" class="checkbox"
id="onlyofficeDefFormat<?php p($format) ?>"
name="<?php p($format) ?>"
<?php if (array_key_exists("def", $setting) && $setting["def"]) { ?>checked="checked"<?php } ?> />
<?php if (\array_key_exists("def", $setting) && $setting["def"]) { ?>checked="checked"<?php } ?> />
<label for="onlyofficeDefFormat<?php p($format) ?>"><?php p($format) ?></label>
</div>
<?php } ?>
@ -166,12 +166,12 @@ script("onlyoffice", "template");
</p>
<div class="onlyoffice-exts">
<?php foreach ($_["formats"] as $format => $setting) { ?>
<?php if (array_key_exists("editable", $setting)) { ?>
<?php if (\array_key_exists("editable", $setting)) { ?>
<div>
<input type="checkbox" class="checkbox"
id="onlyofficeEditFormat<?php p($format) ?>"
name="<?php p($format) ?>"
<?php if (array_key_exists("edit", $setting) && $setting["edit"]) { ?>checked="checked"<?php } ?> />
<?php if (\array_key_exists("edit", $setting) && $setting["edit"]) { ?>checked="checked"<?php } ?> />
<label for="onlyofficeEditFormat<?php p($format) ?>"><?php p($format) ?></label>
</div>
<?php } ?>