@@ -368,8 +368,8 @@ discard block |
||
| 368 | 368 | // check if the file is stored in the array cache, this means that we |
| 369 | 369 | // copy a file over to the versions folder, in this case we don't want to |
| 370 | 370 | // decrypt it |
| 371 | - if ($this->arrayCache->hasKey('encryption_copy_version_' . $path)) { |
|
| 372 | - $this->arrayCache->remove('encryption_copy_version_' . $path); |
|
| 371 | + if ($this->arrayCache->hasKey('encryption_copy_version_'.$path)) { |
|
| 372 | + $this->arrayCache->remove('encryption_copy_version_'.$path); |
|
| 373 | 373 | return $this->storage->fopen($path, $mode); |
| 374 | 374 | } |
| 375 | 375 | |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | } |
| 441 | 441 | } catch (ModuleDoesNotExistsException $e) { |
| 442 | 442 | $this->logger->logException($e, [ |
| 443 | - 'message' => 'Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', |
|
| 443 | + 'message' => 'Encryption module "'.$encryptionModuleId.'" not found, file will be stored unencrypted', |
|
| 444 | 444 | 'level' => ILogger::WARN, |
| 445 | 445 | 'app' => 'core', |
| 446 | 446 | ]); |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | try { |
| 496 | 496 | $result = $this->fixUnencryptedSize($path, $size, $unencryptedSize); |
| 497 | 497 | } catch (\Exception $e) { |
| 498 | - $this->logger->error('Couldn\'t re-calculate unencrypted size for '. $path); |
|
| 498 | + $this->logger->error('Couldn\'t re-calculate unencrypted size for '.$path); |
|
| 499 | 499 | $this->logger->logException($e); |
| 500 | 500 | } |
| 501 | 501 | unset($this->fixUnencryptedSizeOf[$this->getFullPath($path)]); |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | |
| 525 | 525 | // if we couldn't open the file we return the old unencrypted size |
| 526 | 526 | if (!is_resource($stream)) { |
| 527 | - $this->logger->error('Could not open ' . $path . '. Recalculation of unencrypted size aborted.'); |
|
| 527 | + $this->logger->error('Could not open '.$path.'. Recalculation of unencrypted size aborted.'); |
|
| 528 | 528 | return $unencryptedSize; |
| 529 | 529 | } |
| 530 | 530 | |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | // next highest is end of chunks, one subtracted is last one |
| 550 | 550 | // we have to read the last chunk, we can't just calculate it (because of padding etc) |
| 551 | 551 | |
| 552 | - $lastChunkNr = ceil($size/ $blockSize)-1; |
|
| 552 | + $lastChunkNr = ceil($size / $blockSize) - 1; |
|
| 553 | 553 | // calculate last chunk position |
| 554 | 554 | $lastChunkPos = ($lastChunkNr * $blockSize); |
| 555 | 555 | // try to fseek to the last chunk, if it fails we have to read the whole file |
@@ -557,16 +557,16 @@ discard block |
||
| 557 | 557 | $newUnencryptedSize += $lastChunkNr * $unencryptedBlockSize; |
| 558 | 558 | } |
| 559 | 559 | |
| 560 | - $lastChunkContentEncrypted=''; |
|
| 560 | + $lastChunkContentEncrypted = ''; |
|
| 561 | 561 | $count = $blockSize; |
| 562 | 562 | |
| 563 | 563 | while ($count > 0) { |
| 564 | - $data=fread($stream, $blockSize); |
|
| 565 | - $count=strlen($data); |
|
| 564 | + $data = fread($stream, $blockSize); |
|
| 565 | + $count = strlen($data); |
|
| 566 | 566 | $lastChunkContentEncrypted .= $data; |
| 567 | - if(strlen($lastChunkContentEncrypted) > $blockSize) { |
|
| 567 | + if (strlen($lastChunkContentEncrypted) > $blockSize) { |
|
| 568 | 568 | $newUnencryptedSize += $unencryptedBlockSize; |
| 569 | - $lastChunkContentEncrypted=substr($lastChunkContentEncrypted, $blockSize); |
|
| 569 | + $lastChunkContentEncrypted = substr($lastChunkContentEncrypted, $blockSize); |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | |
@@ -574,8 +574,8 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | // we have to decrypt the last chunk to get it actual size |
| 576 | 576 | $encryptionModule->begin($this->getFullPath($path), $this->uid, 'r', $header, []); |
| 577 | - $decryptedLastChunk = $encryptionModule->decrypt($lastChunkContentEncrypted, $lastChunkNr . 'end'); |
|
| 578 | - $decryptedLastChunk .= $encryptionModule->end($this->getFullPath($path), $lastChunkNr . 'end'); |
|
| 577 | + $decryptedLastChunk = $encryptionModule->decrypt($lastChunkContentEncrypted, $lastChunkNr.'end'); |
|
| 578 | + $decryptedLastChunk .= $encryptionModule->end($this->getFullPath($path), $lastChunkNr.'end'); |
|
| 579 | 579 | |
| 580 | 580 | // calc the real file size with the size of the last chunk |
| 581 | 581 | $newUnencryptedSize += strlen($decryptedLastChunk); |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | $cacheInformation = [ |
| 660 | 660 | 'encrypted' => $isEncrypted, |
| 661 | 661 | ]; |
| 662 | - if($isEncrypted) { |
|
| 662 | + if ($isEncrypted) { |
|
| 663 | 663 | $encryptedVersion = $sourceStorage->getCache()->get($sourceInternalPath)['encryptedVersion']; |
| 664 | 664 | |
| 665 | 665 | // In case of a move operation from an unencrypted to an encrypted |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | // correct value would be "1". Thus we manually set the value to "1" |
| 668 | 668 | // for those cases. |
| 669 | 669 | // See also https://github.com/owncloud/core/issues/23078 |
| 670 | - if($encryptedVersion === 0 || !$keepEncryptionVersion) { |
|
| 670 | + if ($encryptedVersion === 0 || !$keepEncryptionVersion) { |
|
| 671 | 671 | $encryptedVersion = 1; |
| 672 | 672 | } |
| 673 | 673 | |
@@ -703,9 +703,9 @@ discard block |
||
| 703 | 703 | // remember that we try to create a version so that we can detect it during |
| 704 | 704 | // fopen($sourceInternalPath) and by-pass the encryption in order to |
| 705 | 705 | // create a 1:1 copy of the file |
| 706 | - $this->arrayCache->set('encryption_copy_version_' . $sourceInternalPath, true); |
|
| 706 | + $this->arrayCache->set('encryption_copy_version_'.$sourceInternalPath, true); |
|
| 707 | 707 | $result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
| 708 | - $this->arrayCache->remove('encryption_copy_version_' . $sourceInternalPath); |
|
| 708 | + $this->arrayCache->remove('encryption_copy_version_'.$sourceInternalPath); |
|
| 709 | 709 | if ($result) { |
| 710 | 710 | $info = $this->getCache('', $sourceStorage)->get($sourceInternalPath); |
| 711 | 711 | // make sure that we update the unencrypted size for the version |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | $mount = $this->mountManager->findByStorageId($sourceStorage->getId()); |
| 726 | 726 | if (count($mount) === 1) { |
| 727 | 727 | $mountPoint = $mount[0]->getMountPoint(); |
| 728 | - $source = $mountPoint . '/' . $sourceInternalPath; |
|
| 728 | + $source = $mountPoint.'/'.$sourceInternalPath; |
|
| 729 | 729 | $target = $this->getFullPath($targetInternalPath); |
| 730 | 730 | $this->copyKeys($source, $target); |
| 731 | 731 | } else { |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | if (is_resource($dh)) { |
| 739 | 739 | while ($result and ($file = readdir($dh)) !== false) { |
| 740 | 740 | if (!Filesystem::isIgnoredDir($file)) { |
| 741 | - $result &= $this->copyFromStorage($sourceStorage, $sourceInternalPath . '/' . $file, $targetInternalPath . '/' . $file, false, $isRename); |
|
| 741 | + $result &= $this->copyFromStorage($sourceStorage, $sourceInternalPath.'/'.$file, $targetInternalPath.'/'.$file, false, $isRename); |
|
| 742 | 742 | } |
| 743 | 743 | } |
| 744 | 744 | } |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | fclose($target); |
| 755 | 755 | throw $e; |
| 756 | 756 | } |
| 757 | - if($result) { |
|
| 757 | + if ($result) { |
|
| 758 | 758 | if ($preserveMtime) { |
| 759 | 759 | $this->touch($targetInternalPath, $sourceStorage->filemtime($sourceInternalPath)); |
| 760 | 760 | } |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | $this->getCache()->remove($targetInternalPath); |
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | - return (bool)$result; |
|
| 769 | + return (bool) $result; |
|
| 770 | 770 | |
| 771 | 771 | } |
| 772 | 772 | |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | * @return string full path including mount point |
| 838 | 838 | */ |
| 839 | 839 | protected function getFullPath($path) { |
| 840 | - return Filesystem::normalizePath($this->mountPoint . '/' . $path); |
|
| 840 | + return Filesystem::normalizePath($this->mountPoint.'/'.$path); |
|
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | /** |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | $header = substr($header, 0, $endAt + strlen(Util::HEADER_END)); |
| 894 | 894 | |
| 895 | 895 | // +1 to not start with an ':' which would result in empty element at the beginning |
| 896 | - $exploded = explode(':', substr($header, strlen(Util::HEADER_START)+1)); |
|
| 896 | + $exploded = explode(':', substr($header, strlen(Util::HEADER_START) + 1)); |
|
| 897 | 897 | |
| 898 | 898 | $element = array_shift($exploded); |
| 899 | 899 | while ($element !== Util::HEADER_END) { |
@@ -956,7 +956,7 @@ discard block |
||
| 956 | 956 | try { |
| 957 | 957 | $encryptionModule = $this->encryptionManager->getEncryptionModule($encryptionModuleId); |
| 958 | 958 | } catch (ModuleDoesNotExistsException $e) { |
| 959 | - $this->logger->critical('Encryption module defined in "' . $path . '" not loaded!'); |
|
| 959 | + $this->logger->critical('Encryption module defined in "'.$path.'" not loaded!'); |
|
| 960 | 960 | throw $e; |
| 961 | 961 | } |
| 962 | 962 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $this->realDataDir = $this->datadir; |
| 67 | 67 | } else { |
| 68 | 68 | $realPath = realpath($this->datadir) ?: $this->datadir; |
| 69 | - $this->realDataDir = rtrim($realPath, '/') . '/'; |
|
| 69 | + $this->realDataDir = rtrim($realPath, '/').'/'; |
|
| 70 | 70 | } |
| 71 | 71 | if (substr($this->datadir, -1) !== '/') { |
| 72 | 72 | $this->datadir .= '/'; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function getId() { |
| 81 | - return 'local::' . $this->datadir; |
|
| 81 | + return 'local::'.$this->datadir; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | public function mkdir($path) { |
@@ -236,17 +236,17 @@ discard block |
||
| 236 | 236 | $dstParent = dirname($path2); |
| 237 | 237 | |
| 238 | 238 | if (!$this->isUpdatable($srcParent)) { |
| 239 | - \OCP\Util::writeLog('core', 'unable to rename, source directory is not writable : ' . $srcParent, ILogger::ERROR); |
|
| 239 | + \OCP\Util::writeLog('core', 'unable to rename, source directory is not writable : '.$srcParent, ILogger::ERROR); |
|
| 240 | 240 | return false; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | if (!$this->isUpdatable($dstParent)) { |
| 244 | - \OCP\Util::writeLog('core', 'unable to rename, destination directory is not writable : ' . $dstParent, ILogger::ERROR); |
|
| 244 | + \OCP\Util::writeLog('core', 'unable to rename, destination directory is not writable : '.$dstParent, ILogger::ERROR); |
|
| 245 | 245 | return false; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | if (!$this->file_exists($path1)) { |
| 249 | - \OCP\Util::writeLog('core', 'unable to rename, file does not exists : ' . $path1, ILogger::ERROR); |
|
| 249 | + \OCP\Util::writeLog('core', 'unable to rename, file does not exists : '.$path1, ILogger::ERROR); |
|
| 250 | 250 | return false; |
| 251 | 251 | } |
| 252 | 252 | |
@@ -327,13 +327,13 @@ discard block |
||
| 327 | 327 | foreach (scandir($physicalDir) as $item) { |
| 328 | 328 | if (\OC\Files\Filesystem::isIgnoredDir($item)) |
| 329 | 329 | continue; |
| 330 | - $physicalItem = $physicalDir . '/' . $item; |
|
| 330 | + $physicalItem = $physicalDir.'/'.$item; |
|
| 331 | 331 | |
| 332 | 332 | if (strstr(strtolower($item), strtolower($query)) !== false) { |
| 333 | - $files[] = $dir . '/' . $item; |
|
| 333 | + $files[] = $dir.'/'.$item; |
|
| 334 | 334 | } |
| 335 | 335 | if (is_dir($physicalItem)) { |
| 336 | - $files = array_merge($files, $this->searchInDir($query, $dir . '/' . $item)); |
|
| 336 | + $files = array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | return $files; |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | * @throws ForbiddenException |
| 363 | 363 | */ |
| 364 | 364 | public function getSourcePath($path) { |
| 365 | - $fullPath = $this->datadir . $path; |
|
| 365 | + $fullPath = $this->datadir.$path; |
|
| 366 | 366 | $currentPath = $path; |
| 367 | 367 | if ($this->allowSymlinks || $currentPath === '') { |
| 368 | 368 | return $fullPath; |
@@ -374,10 +374,10 @@ discard block |
||
| 374 | 374 | if ($currentPath === '' || $currentPath === '.') { |
| 375 | 375 | return $fullPath; |
| 376 | 376 | } |
| 377 | - $realPath = realpath($this->datadir . $currentPath); |
|
| 377 | + $realPath = realpath($this->datadir.$currentPath); |
|
| 378 | 378 | } |
| 379 | 379 | if ($realPath) { |
| 380 | - $realPath = $realPath . '/'; |
|
| 380 | + $realPath = $realPath.'/'; |
|
| 381 | 381 | } |
| 382 | 382 | if (substr($realPath, 0, $this->dataDirLength) === $this->realDataDir) { |
| 383 | 383 | return $fullPath; |
@@ -404,9 +404,9 @@ discard block |
||
| 404 | 404 | if ($this->is_file($path)) { |
| 405 | 405 | $stat = $this->stat($path); |
| 406 | 406 | return md5( |
| 407 | - $stat['mtime'] . |
|
| 408 | - $stat['ino'] . |
|
| 409 | - $stat['dev'] . |
|
| 407 | + $stat['mtime']. |
|
| 408 | + $stat['ino']. |
|
| 409 | + $stat['dev']. |
|
| 410 | 410 | $stat['size'] |
| 411 | 411 | ); |
| 412 | 412 | } else { |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | if (is_string($params['secure'])) { |
| 104 | 104 | $this->secure = ($params['secure'] === 'true'); |
| 105 | 105 | } else { |
| 106 | - $this->secure = (bool)$params['secure']; |
|
| 106 | + $this->secure = (bool) $params['secure']; |
|
| 107 | 107 | } |
| 108 | 108 | } else { |
| 109 | 109 | $this->secure = false; |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | $this->root = $params['root'] ?? '/'; |
| 123 | - $this->root = '/' . ltrim($this->root, '/'); |
|
| 124 | - $this->root = rtrim($this->root, '/') . '/'; |
|
| 123 | + $this->root = '/'.ltrim($this->root, '/'); |
|
| 124 | + $this->root = rtrim($this->root, '/').'/'; |
|
| 125 | 125 | } else { |
| 126 | 126 | throw new \Exception('Invalid webdav storage configuration'); |
| 127 | 127 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | /** {@inheritdoc} */ |
| 165 | 165 | public function getId() { |
| 166 | - return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root; |
|
| 166 | + return 'webdav::'.$this->user.'@'.$this->host.'/'.$this->root; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** {@inheritdoc} */ |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | if ($this->secure) { |
| 173 | 173 | $baseUri .= 's'; |
| 174 | 174 | } |
| 175 | - $baseUri .= '://' . $this->host . $this->root; |
|
| 175 | + $baseUri .= '://'.$this->host.$this->root; |
|
| 176 | 176 | return $baseUri; |
| 177 | 177 | } |
| 178 | 178 | |
@@ -193,8 +193,8 @@ discard block |
||
| 193 | 193 | $path = $this->cleanPath($path); |
| 194 | 194 | // FIXME: some WebDAV impl return 403 when trying to DELETE |
| 195 | 195 | // a non-empty folder |
| 196 | - $result = $this->simpleResponse('DELETE', $path . '/', null, 204); |
|
| 197 | - $this->statCache->clear($path . '/'); |
|
| 196 | + $result = $this->simpleResponse('DELETE', $path.'/', null, 204); |
|
| 197 | + $this->statCache->clear($path.'/'); |
|
| 198 | 198 | $this->statCache->remove($path); |
| 199 | 199 | return $result; |
| 200 | 200 | } |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | $this->statCache->set($path, $response); |
| 270 | 270 | } catch (ClientHttpException $e) { |
| 271 | 271 | if ($e->getHttpStatus() === 404) { |
| 272 | - $this->statCache->clear($path . '/'); |
|
| 272 | + $this->statCache->clear($path.'/'); |
|
| 273 | 273 | $this->statCache->set($path, false); |
| 274 | 274 | return false; |
| 275 | 275 | } |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $this->init(); |
| 327 | 327 | $path = $this->cleanPath($path); |
| 328 | 328 | $result = $this->simpleResponse('DELETE', $path, null, 204); |
| 329 | - $this->statCache->clear($path . '/'); |
|
| 329 | + $this->statCache->clear($path.'/'); |
|
| 330 | 330 | $this->statCache->remove($path); |
| 331 | 331 | return $result; |
| 332 | 332 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | try { |
| 342 | 342 | $response = $this->httpClientService |
| 343 | 343 | ->newClient() |
| 344 | - ->get($this->createBaseUri() . $this->encodePath($path), [ |
|
| 344 | + ->get($this->createBaseUri().$this->encodePath($path), [ |
|
| 345 | 345 | 'auth' => [$this->user, $this->password], |
| 346 | 346 | 'stream' => true |
| 347 | 347 | ]); |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | if ($response->getStatusCode() === Http::STATUS_LOCKED) { |
| 359 | 359 | throw new \OCP\Lock\LockedException($path); |
| 360 | 360 | } else { |
| 361 | - Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), ILogger::ERROR); |
|
| 361 | + Util::writeLog("webdav client", 'Guzzle get returned status code '.$response->getStatusCode(), ILogger::ERROR); |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | $tmpFile = $tempManager->getTemporaryFile($ext); |
| 399 | 399 | } |
| 400 | 400 | $handle = fopen($tmpFile, $mode); |
| 401 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
| 401 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
| 402 | 402 | $this->writeBack($tmpFile, $path); |
| 403 | 403 | }); |
| 404 | 404 | } |
@@ -423,7 +423,7 @@ discard block |
||
| 423 | 423 | return FileInfo::SPACE_UNKNOWN; |
| 424 | 424 | } |
| 425 | 425 | if (isset($response['{DAV:}quota-available-bytes'])) { |
| 426 | - return (int)$response['{DAV:}quota-available-bytes']; |
|
| 426 | + return (int) $response['{DAV:}quota-available-bytes']; |
|
| 427 | 427 | } else { |
| 428 | 428 | return FileInfo::SPACE_UNKNOWN; |
| 429 | 429 | } |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | |
| 500 | 500 | $this->httpClientService |
| 501 | 501 | ->newClient() |
| 502 | - ->put($this->createBaseUri() . $this->encodePath($target), [ |
|
| 502 | + ->put($this->createBaseUri().$this->encodePath($target), [ |
|
| 503 | 503 | 'body' => $source, |
| 504 | 504 | 'auth' => [$this->user, $this->password] |
| 505 | 505 | ]); |
@@ -516,18 +516,18 @@ discard block |
||
| 516 | 516 | // overwrite directory ? |
| 517 | 517 | if ($this->is_dir($path2)) { |
| 518 | 518 | // needs trailing slash in destination |
| 519 | - $path2 = rtrim($path2, '/') . '/'; |
|
| 519 | + $path2 = rtrim($path2, '/').'/'; |
|
| 520 | 520 | } |
| 521 | 521 | $this->client->request( |
| 522 | 522 | 'MOVE', |
| 523 | 523 | $this->encodePath($path1), |
| 524 | 524 | null, |
| 525 | 525 | [ |
| 526 | - 'Destination' => $this->createBaseUri() . $this->encodePath($path2), |
|
| 526 | + 'Destination' => $this->createBaseUri().$this->encodePath($path2), |
|
| 527 | 527 | ] |
| 528 | 528 | ); |
| 529 | - $this->statCache->clear($path1 . '/'); |
|
| 530 | - $this->statCache->clear($path2 . '/'); |
|
| 529 | + $this->statCache->clear($path1.'/'); |
|
| 530 | + $this->statCache->clear($path2.'/'); |
|
| 531 | 531 | $this->statCache->set($path1, false); |
| 532 | 532 | $this->statCache->set($path2, true); |
| 533 | 533 | $this->removeCachedFile($path1); |
@@ -548,17 +548,17 @@ discard block |
||
| 548 | 548 | // overwrite directory ? |
| 549 | 549 | if ($this->is_dir($path2)) { |
| 550 | 550 | // needs trailing slash in destination |
| 551 | - $path2 = rtrim($path2, '/') . '/'; |
|
| 551 | + $path2 = rtrim($path2, '/').'/'; |
|
| 552 | 552 | } |
| 553 | 553 | $this->client->request( |
| 554 | 554 | 'COPY', |
| 555 | 555 | $this->encodePath($path1), |
| 556 | 556 | null, |
| 557 | 557 | [ |
| 558 | - 'Destination' => $this->createBaseUri() . $this->encodePath($path2), |
|
| 558 | + 'Destination' => $this->createBaseUri().$this->encodePath($path2), |
|
| 559 | 559 | ] |
| 560 | 560 | ); |
| 561 | - $this->statCache->clear($path2 . '/'); |
|
| 561 | + $this->statCache->clear($path2.'/'); |
|
| 562 | 562 | $this->statCache->set($path2, true); |
| 563 | 563 | $this->removeCachedFile($path2); |
| 564 | 564 | return true; |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | } |
| 578 | 578 | return [ |
| 579 | 579 | 'mtime' => strtotime($response['{DAV:}getlastmodified']), |
| 580 | - 'size' => (int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, |
|
| 580 | + 'size' => (int) isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, |
|
| 581 | 581 | ]; |
| 582 | 582 | } catch (\Exception $e) { |
| 583 | 583 | $this->convertException($e, $path); |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | return $response['statusCode'] == $expected; |
| 660 | 660 | } catch (ClientHttpException $e) { |
| 661 | 661 | if ($e->getHttpStatus() === 404 && $method === 'DELETE') { |
| 662 | - $this->statCache->clear($path . '/'); |
|
| 662 | + $this->statCache->clear($path.'/'); |
|
| 663 | 663 | $this->statCache->set($path, false); |
| 664 | 664 | return false; |
| 665 | 665 | } |
@@ -680,22 +680,22 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | /** {@inheritdoc} */ |
| 682 | 682 | public function isUpdatable($path) { |
| 683 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE); |
|
| 683 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_UPDATE); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | /** {@inheritdoc} */ |
| 687 | 687 | public function isCreatable($path) { |
| 688 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE); |
|
| 688 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_CREATE); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** {@inheritdoc} */ |
| 692 | 692 | public function isSharable($path) { |
| 693 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE); |
|
| 693 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_SHARE); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | 696 | /** {@inheritdoc} */ |
| 697 | 697 | public function isDeletable($path) { |
| 698 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE); |
|
| 698 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_DELETE); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | /** {@inheritdoc} */ |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | if (!empty($etag) && $cachedData['etag'] !== $etag) { |
| 785 | 785 | return true; |
| 786 | 786 | } else if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) { |
| 787 | - $sharePermissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions']; |
|
| 787 | + $sharePermissions = (int) $response['{http://open-collaboration-services.org/ns}share-permissions']; |
|
| 788 | 788 | return $sharePermissions !== $cachedData['permissions']; |
| 789 | 789 | } else if (isset($response['{http://owncloud.org/ns}permissions'])) { |
| 790 | 790 | $permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']); |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | if ($e->getHttpStatus() === 405) { |
| 801 | 801 | if ($path === '') { |
| 802 | 802 | // if root is gone it means the storage is not available |
| 803 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
| 803 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
| 804 | 804 | } |
| 805 | 805 | return false; |
| 806 | 806 | } |
@@ -834,19 +834,19 @@ discard block |
||
| 834 | 834 | } |
| 835 | 835 | if ($e->getHttpStatus() === Http::STATUS_UNAUTHORIZED) { |
| 836 | 836 | // either password was changed or was invalid all along |
| 837 | - throw new StorageInvalidException(get_class($e) . ': ' . $e->getMessage()); |
|
| 837 | + throw new StorageInvalidException(get_class($e).': '.$e->getMessage()); |
|
| 838 | 838 | } else if ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) { |
| 839 | 839 | // ignore exception for MethodNotAllowed, false will be returned |
| 840 | 840 | return; |
| 841 | 841 | } |
| 842 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
| 842 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
| 843 | 843 | } else if ($e instanceof ClientException) { |
| 844 | 844 | // connection timeout or refused, server could be temporarily down |
| 845 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
| 845 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
| 846 | 846 | } else if ($e instanceof \InvalidArgumentException) { |
| 847 | 847 | // parse error because the server returned HTML instead of XML, |
| 848 | 848 | // possibly temporarily down |
| 849 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
| 849 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
| 850 | 850 | } else if (($e instanceof StorageNotAvailableException) || ($e instanceof StorageInvalidException)) { |
| 851 | 851 | // rethrow |
| 852 | 852 | throw $e; |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $this->mkdir($path2); |
| 220 | 220 | while ($file = readdir($dir)) { |
| 221 | 221 | if (!Filesystem::isIgnoredDir($file)) { |
| 222 | - if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) { |
|
| 222 | + if (!$this->copy($path1.'/'.$file, $path2.'/'.$file)) { |
|
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | } |
@@ -273,12 +273,12 @@ discard block |
||
| 273 | 273 | if (is_resource($dh)) { |
| 274 | 274 | while (($file = readdir($dh)) !== false) { |
| 275 | 275 | if (!\OC\Files\Filesystem::isIgnoredDir($file)) { |
| 276 | - if ($this->is_dir($path . '/' . $file)) { |
|
| 277 | - mkdir($target . '/' . $file); |
|
| 278 | - $this->addLocalFolder($path . '/' . $file, $target . '/' . $file); |
|
| 276 | + if ($this->is_dir($path.'/'.$file)) { |
|
| 277 | + mkdir($target.'/'.$file); |
|
| 278 | + $this->addLocalFolder($path.'/'.$file, $target.'/'.$file); |
|
| 279 | 279 | } else { |
| 280 | - $tmp = $this->toTmpFile($path . '/' . $file); |
|
| 281 | - rename($tmp, $target . '/' . $file); |
|
| 280 | + $tmp = $this->toTmpFile($path.'/'.$file); |
|
| 281 | + rename($tmp, $target.'/'.$file); |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | } |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | while (($item = readdir($dh)) !== false) { |
| 298 | 298 | if (\OC\Files\Filesystem::isIgnoredDir($item)) continue; |
| 299 | 299 | if (strstr(strtolower($item), strtolower($query)) !== false) { |
| 300 | - $files[] = $dir . '/' . $item; |
|
| 300 | + $files[] = $dir.'/'.$item; |
|
| 301 | 301 | } |
| 302 | - if ($this->is_dir($dir . '/' . $item)) { |
|
| 303 | - $files = array_merge($files, $this->searchInDir($query, $dir . '/' . $item)); |
|
| 302 | + if ($this->is_dir($dir.'/'.$item)) { |
|
| 303 | + $files = array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); |
|
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | if (!isset($this->watcher)) { |
| 352 | 352 | $this->watcher = new Watcher($storage); |
| 353 | 353 | $globalPolicy = \OC::$server->getConfig()->getSystemValue('filesystem_check_changes', Watcher::CHECK_NEVER); |
| 354 | - $this->watcher->setPolicy((int)$this->getMountOption('filesystem_check_changes', $globalPolicy)); |
|
| 354 | + $this->watcher->setPolicy((int) $this->getMountOption('filesystem_check_changes', $globalPolicy)); |
|
| 355 | 355 | } |
| 356 | 356 | return $this->watcher; |
| 357 | 357 | } |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | public function cleanPath($path) { |
| 427 | 427 | if (strlen($path) == 0 or $path[0] != '/') { |
| 428 | - $path = '/' . $path; |
|
| 428 | + $path = '/'.$path; |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | $output = array(); |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | \OC::$server->getLogger()->info("External storage not available: stat() failed"); |
| 454 | 454 | return false; |
| 455 | 455 | } catch (\Exception $e) { |
| 456 | - \OC::$server->getLogger()->info("External storage not available: " . $e->getMessage()); |
|
| 456 | + \OC::$server->getLogger()->info("External storage not available: ".$e->getMessage()); |
|
| 457 | 457 | \OC::$server->getLogger()->logException($e, ['level' => ILogger::DEBUG]); |
| 458 | 458 | return false; |
| 459 | 459 | } |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | if (is_resource($dh)) { |
| 605 | 605 | while ($result and ($file = readdir($dh)) !== false) { |
| 606 | 606 | if (!Filesystem::isIgnoredDir($file)) { |
| 607 | - $result &= $this->copyFromStorage($sourceStorage, $sourceInternalPath . '/' . $file, $targetInternalPath . '/' . $file); |
|
| 607 | + $result &= $this->copyFromStorage($sourceStorage, $sourceInternalPath.'/'.$file, $targetInternalPath.'/'.$file); |
|
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | } |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | $this->getCache()->remove($targetInternalPath); |
| 631 | 631 | } |
| 632 | 632 | } |
| 633 | - return (bool)$result; |
|
| 633 | + return (bool) $result; |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /** |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | ); |
| 711 | 711 | } |
| 712 | 712 | try { |
| 713 | - $provider->acquireLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type); |
|
| 713 | + $provider->acquireLock('files/'.md5($this->getId().'::'.trim($path, '/')), $type); |
|
| 714 | 714 | } catch (LockedException $e) { |
| 715 | 715 | if ($logger) { |
| 716 | 716 | $logger->logException($e); |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | ); |
| 743 | 743 | } |
| 744 | 744 | try { |
| 745 | - $provider->releaseLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type); |
|
| 745 | + $provider->releaseLock('files/'.md5($this->getId().'::'.trim($path, '/')), $type); |
|
| 746 | 746 | } catch (LockedException $e) { |
| 747 | 747 | if ($logger) { |
| 748 | 748 | $logger->logException($e); |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | ); |
| 775 | 775 | } |
| 776 | 776 | try { |
| 777 | - $provider->changeLock('files/' . md5($this->getId() . '::' . trim($path, '/')), $type); |
|
| 777 | + $provider->changeLock('files/'.md5($this->getId().'::'.trim($path, '/')), $type); |
|
| 778 | 778 | } catch (LockedException $e) { |
| 779 | 779 | if ($logger) { |
| 780 | 780 | $logger->logException($e); |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | if ($lock) { |
| 330 | 330 | if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { |
| 331 | - $this->storage->acquireLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); |
|
| 331 | + $this->storage->acquireLock('scanner::'.$path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); |
|
| 332 | 332 | $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); |
| 333 | 333 | } |
| 334 | 334 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | if ($lock) { |
| 341 | 341 | if ($this->storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { |
| 342 | 342 | $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider); |
| 343 | - $this->storage->releaseLock('scanner::' . $path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); |
|
| 343 | + $this->storage->releaseLock('scanner::'.$path, ILockingProvider::LOCK_EXCLUSIVE, $this->lockingProvider); |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | 346 | return $data; |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | $exceptionOccurred = false; |
| 430 | 430 | $childQueue = []; |
| 431 | 431 | foreach ($newChildren as $file) { |
| 432 | - $child = $path ? $path . '/' . $file : $file; |
|
| 432 | + $child = $path ? $path.'/'.$file : $file; |
|
| 433 | 433 | try { |
| 434 | 434 | $existingData = isset($existingChildren[$file]) ? $existingChildren[$file] : null; |
| 435 | 435 | $data = $this->scanFile($child, $reuse, $folderId, $existingData, $lock); |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | \OC::$server->getDatabaseConnection()->beginTransaction(); |
| 455 | 455 | } |
| 456 | 456 | \OC::$server->getLogger()->logException($ex, [ |
| 457 | - 'message' => 'Exception while scanning file "' . $child . '"', |
|
| 457 | + 'message' => 'Exception while scanning file "'.$child.'"', |
|
| 458 | 458 | 'level' => ILogger::DEBUG, |
| 459 | 459 | 'app' => 'core', |
| 460 | 460 | ]); |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | } |
| 469 | 469 | $removedChildren = \array_diff(array_keys($existingChildren), $newChildren); |
| 470 | 470 | foreach ($removedChildren as $childName) { |
| 471 | - $child = $path ? $path . '/' . $childName : $childName; |
|
| 471 | + $child = $path ? $path.'/'.$childName : $childName; |
|
| 472 | 472 | $this->removeFromCache($child); |
| 473 | 473 | } |
| 474 | 474 | if ($this->useTransactions) { |
@@ -508,13 +508,13 @@ discard block |
||
| 508 | 508 | */ |
| 509 | 509 | public function backgroundScan() { |
| 510 | 510 | if (!$this->cache->inCache('')) { |
| 511 | - $this->runBackgroundScanJob(function () { |
|
| 511 | + $this->runBackgroundScanJob(function() { |
|
| 512 | 512 | $this->scan('', self::SCAN_RECURSIVE, self::REUSE_ETAG); |
| 513 | 513 | }, ''); |
| 514 | 514 | } else { |
| 515 | 515 | $lastPath = null; |
| 516 | 516 | while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) { |
| 517 | - $this->runBackgroundScanJob(function () use ($path) { |
|
| 517 | + $this->runBackgroundScanJob(function() use ($path) { |
|
| 518 | 518 | $this->scan($path, self::SCAN_RECURSIVE_INCOMPLETE, self::REUSE_ETAG | self::REUSE_SIZE); |
| 519 | 519 | }, $path); |
| 520 | 520 | // FIXME: this won't proceed with the next item, needs revamping of getIncomplete() |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public function getCustomLogger(string $path):ILogger { |
| 64 | 64 | $systemConfig = null; |
| 65 | 65 | $iconfig = $this->c->getConfig(); |
| 66 | - if($iconfig instanceof AllConfig) { |
|
| 66 | + if ($iconfig instanceof AllConfig) { |
|
| 67 | 67 | // Log is bound to SystemConfig, but fetches it from \OC::$server if not supplied |
| 68 | 68 | $systemConfig = $iconfig->getSystemConfig(); |
| 69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | protected function buildLogFile(string $logFile = ''):File { |
| 75 | 75 | $config = $this->c->getConfig(); |
| 76 | 76 | $defaultLogFile = $config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/nextcloud.log'; |
| 77 | - if($logFile === '') { |
|
| 77 | + if ($logFile === '') { |
|
| 78 | 78 | $logFile = $config->getSystemValue('logfile', $defaultLogFile); |
| 79 | 79 | } |
| 80 | 80 | $fallback = $defaultLogFile !== $logFile ? $defaultLogFile : ''; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | 'collectionOf' => $collectionOf, |
| 85 | 85 | 'supportedFileExtensions' => $supportedFileExtensions |
| 86 | 86 | ); |
| 87 | - if(count(self::$backendTypes) === 1) { |
|
| 87 | + if (count(self::$backendTypes) === 1) { |
|
| 88 | 88 | Util::addScript('core', 'merged-share-backend'); |
| 89 | 89 | \OC_Util::addStyle('core', 'share'); |
| 90 | 90 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | $select = self::createSelectStatement(self::FORMAT_NONE, $fileDependent); |
| 157 | 157 | |
| 158 | - $where .= ' `' . $column . '` = ? AND `item_type` = ? '; |
|
| 158 | + $where .= ' `'.$column.'` = ? AND `item_type` = ? '; |
|
| 159 | 159 | $arguments = array($itemSource, $itemType); |
| 160 | 160 | // for link shares $user === null |
| 161 | 161 | if ($user !== null) { |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $arguments[] = $owner; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - $query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` '. $fileDependentWhere . $where); |
|
| 176 | + $query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$fileDependentWhere.$where); |
|
| 177 | 177 | |
| 178 | 178 | $result = \OC_DB::executeAudited($query, $arguments); |
| 179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) { |
| 182 | 182 | continue; |
| 183 | 183 | } |
| 184 | - if ($fileDependent && (int)$row['file_parent'] === -1) { |
|
| 184 | + if ($fileDependent && (int) $row['file_parent'] === -1) { |
|
| 185 | 185 | // if it is a mount point we need to get the path from the mount manager |
| 186 | 186 | $mountManager = \OC\Files\Filesystem::getMountManager(); |
| 187 | 187 | $mountPoint = $mountManager->findByStorageId($row['storage_id']); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $row['path'] = $path; |
| 193 | 193 | } else { |
| 194 | 194 | \OC::$server->getLogger()->warning( |
| 195 | - 'Could not resolve mount point for ' . $row['storage_id'], |
|
| 195 | + 'Could not resolve mount point for '.$row['storage_id'], |
|
| 196 | 196 | ['app' => 'OCP\Share'] |
| 197 | 197 | ); |
| 198 | 198 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | //if didn't found a result than let's look for a group share. |
| 204 | - if(empty($shares) && $user !== null) { |
|
| 204 | + if (empty($shares) && $user !== null) { |
|
| 205 | 205 | $userObject = \OC::$server->getUserManager()->get($user); |
| 206 | 206 | $groups = []; |
| 207 | 207 | if ($userObject) { |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | if (!empty($groups)) { |
| 212 | - $where = $fileDependentWhere . ' WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)'; |
|
| 212 | + $where = $fileDependentWhere.' WHERE `'.$column.'` = ? AND `item_type` = ? AND `share_with` in (?)'; |
|
| 213 | 213 | $arguments = array($itemSource, $itemType, $groups); |
| 214 | 214 | $types = array(null, null, IQueryBuilder::PARAM_STR_ARRAY); |
| 215 | 215 | |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | // class isn't static anymore... |
| 224 | 224 | $conn = \OC::$server->getDatabaseConnection(); |
| 225 | 225 | $result = $conn->executeQuery( |
| 226 | - 'SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where, |
|
| 226 | + 'SELECT '.$select.' FROM `*PREFIX*share` '.$where, |
|
| 227 | 227 | $arguments, |
| 228 | 228 | $types |
| 229 | 229 | ); |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1); |
| 266 | 266 | $result = $query->execute(array($token)); |
| 267 | 267 | if ($result === false) { |
| 268 | - \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, ILogger::ERROR); |
|
| 268 | + \OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage().', token='.$token, ILogger::ERROR); |
|
| 269 | 269 | } |
| 270 | 270 | $row = $result->fetchRow(); |
| 271 | 271 | if ($row === false) { |
@@ -371,12 +371,12 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | //verify that we don't share a folder which already contains a share mount point |
| 373 | 373 | if ($itemType === 'folder') { |
| 374 | - $path = '/' . $uidOwner . '/files' . \OC\Files\Filesystem::getPath($itemSource) . '/'; |
|
| 374 | + $path = '/'.$uidOwner.'/files'.\OC\Files\Filesystem::getPath($itemSource).'/'; |
|
| 375 | 375 | $mountManager = \OC\Files\Filesystem::getMountManager(); |
| 376 | 376 | $mounts = $mountManager->findIn($path); |
| 377 | 377 | foreach ($mounts as $mount) { |
| 378 | 378 | if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) { |
| 379 | - $message = 'Sharing "' . $itemSourceName . '" failed, because it contains files shared with you!'; |
|
| 379 | + $message = 'Sharing "'.$itemSourceName.'" failed, because it contains files shared with you!'; |
|
| 380 | 380 | \OCP\Util::writeLog('OCP\Share', $message, ILogger::DEBUG); |
| 381 | 381 | throw new \Exception($message); |
| 382 | 382 | } |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | // single file shares should never have delete permissions |
| 388 | 388 | if ($itemType === 'file') { |
| 389 | - $permissions = (int)$permissions & ~\OCP\Constants::PERMISSION_DELETE; |
|
| 389 | + $permissions = (int) $permissions & ~\OCP\Constants::PERMISSION_DELETE; |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | //Validate expirationDate |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | } else { |
| 541 | 541 | // reuse the already set password, but only if we change permissions |
| 542 | 542 | // otherwise the user disabled the password protection |
| 543 | - if ($checkExists && (int)$permissions !== (int)$oldPermissions) { |
|
| 543 | + if ($checkExists && (int) $permissions !== (int) $oldPermissions) { |
|
| 544 | 544 | $shareWith = $checkExists['share_with']; |
| 545 | 545 | } |
| 546 | 546 | } |
@@ -612,10 +612,10 @@ discard block |
||
| 612 | 612 | throw new \Exception($message_t); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - $token = \OC::$server->getSecureRandom()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER . |
|
| 615 | + $token = \OC::$server->getSecureRandom()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_UPPER. |
|
| 616 | 616 | \OCP\Security\ISecureRandom::CHAR_DIGITS); |
| 617 | 617 | |
| 618 | - $shareWith = $user . '@' . $remote; |
|
| 618 | + $shareWith = $user.'@'.$remote; |
|
| 619 | 619 | $shareId = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, $token, $itemSourceName); |
| 620 | 620 | |
| 621 | 621 | $send = false; |
@@ -666,12 +666,12 @@ discard block |
||
| 666 | 666 | $currentUser = $owner ? $owner : \OC_User::getUser(); |
| 667 | 667 | foreach ($items as $item) { |
| 668 | 668 | // delete the item with the expected share_type and owner |
| 669 | - if ((int)$item['share_type'] === (int)$shareType && $item['uid_owner'] === $currentUser) { |
|
| 669 | + if ((int) $item['share_type'] === (int) $shareType && $item['uid_owner'] === $currentUser) { |
|
| 670 | 670 | $toDelete = $item; |
| 671 | 671 | // if there is more then one result we don't have to delete the children |
| 672 | 672 | // but update their parent. For group shares the new parent should always be |
| 673 | 673 | // the original group share and not the db entry with the unique name |
| 674 | - } else if ((int)$item['share_type'] === self::$shareTypeGroupUserUnique) { |
|
| 674 | + } else if ((int) $item['share_type'] === self::$shareTypeGroupUserUnique) { |
|
| 675 | 675 | $newParent = $item['parent']; |
| 676 | 676 | } else { |
| 677 | 677 | $newParent = $item['id']; |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | |
| 704 | 704 | $result = $query->execute(array($status, $itemType, $itemSource, $shareType, $recipient)); |
| 705 | 705 | |
| 706 | - if($result === false) { |
|
| 706 | + if ($result === false) { |
|
| 707 | 707 | \OCP\Util::writeLog('OCP\Share', 'Couldn\'t set send mail status', ILogger::ERROR); |
| 708 | 708 | } |
| 709 | 709 | } |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | if ($defaultExpireDateEnforced && $shareTime === null) { |
| 730 | 730 | $items = self::getItemShared($itemType, $itemSource); |
| 731 | 731 | $firstItem = reset($items); |
| 732 | - $shareTime = (int)$firstItem['stime']; |
|
| 732 | + $shareTime = (int) $firstItem['stime']; |
|
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | if ($defaultExpireDateEnforced) { |
@@ -737,9 +737,9 @@ discard block |
||
| 737 | 737 | $maxDate = new \DateTime(); |
| 738 | 738 | $maxDate->setTimestamp($shareTime); |
| 739 | 739 | $maxDays = \OC::$server->getConfig()->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
| 740 | - $maxDate->add(new \DateInterval('P' . $maxDays . 'D')); |
|
| 740 | + $maxDate->add(new \DateInterval('P'.$maxDays.'D')); |
|
| 741 | 741 | if ($date > $maxDate) { |
| 742 | - $warning = 'Cannot set expiration date. Shares cannot expire later than ' . $maxDays . ' after they have been shared'; |
|
| 742 | + $warning = 'Cannot set expiration date. Shares cannot expire later than '.$maxDays.' after they have been shared'; |
|
| 743 | 743 | $warning_t = $l->t('Cannot set expiration date. Shares cannot expire later than %s after they have been shared', array($maxDays)); |
| 744 | 744 | \OCP\Util::writeLog('OCP\Share', $warning, ILogger::WARN); |
| 745 | 745 | throw new \Exception($warning_t); |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | */ |
| 802 | 802 | protected static function unshareItem(array $item, $newParent = null) { |
| 803 | 803 | |
| 804 | - $shareType = (int)$item['share_type']; |
|
| 804 | + $shareType = (int) $item['share_type']; |
|
| 805 | 805 | $shareWith = null; |
| 806 | 806 | if ($shareType !== \OCP\Share::SHARE_TYPE_LINK) { |
| 807 | 807 | $shareWith = $item['share_with']; |
@@ -817,7 +817,7 @@ discard block |
||
| 817 | 817 | 'itemParent' => $item['parent'], |
| 818 | 818 | 'uidOwner' => $item['uid_owner'], |
| 819 | 819 | ); |
| 820 | - if($item['item_type'] === 'file' || $item['item_type'] === 'folder') { |
|
| 820 | + if ($item['item_type'] === 'file' || $item['item_type'] === 'folder') { |
|
| 821 | 821 | $hookParams['fileSource'] = $item['file_source']; |
| 822 | 822 | $hookParams['fileTarget'] = $item['file_target']; |
| 823 | 823 | } |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | $deletedShares[] = $hookParams; |
| 828 | 828 | $hookParams['deletedShares'] = $deletedShares; |
| 829 | 829 | \OC_Hook::emit(\OCP\Share::class, 'post_unshare', $hookParams); |
| 830 | - if ((int)$item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) { |
|
| 830 | + if ((int) $item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) { |
|
| 831 | 831 | list(, $remote) = Helper::splitUserRemote($item['share_with']); |
| 832 | 832 | self::sendRemoteUnshare($remote, $item['id'], $item['token']); |
| 833 | 833 | } |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | // Get filesystem root to add it to the file target and remove from the |
| 989 | 989 | // file source, match file_source with the file cache |
| 990 | 990 | if ($itemType == 'file' || $itemType == 'folder') { |
| 991 | - if(!is_null($uidOwner)) { |
|
| 991 | + if (!is_null($uidOwner)) { |
|
| 992 | 992 | $root = \OC\Files\Filesystem::getRoot(); |
| 993 | 993 | } else { |
| 994 | 994 | $root = ''; |
@@ -1133,7 +1133,7 @@ discard block |
||
| 1133 | 1133 | $result = $query->execute($queryArgs); |
| 1134 | 1134 | if ($result === false) { |
| 1135 | 1135 | \OCP\Util::writeLog('OCP\Share', |
| 1136 | - \OC_DB::getErrorMessage() . ', select=' . $select . ' where=', |
|
| 1136 | + \OC_DB::getErrorMessage().', select='.$select.' where=', |
|
| 1137 | 1137 | ILogger::ERROR); |
| 1138 | 1138 | } |
| 1139 | 1139 | $items = array(); |
@@ -1175,14 +1175,14 @@ discard block |
||
| 1175 | 1175 | } |
| 1176 | 1176 | // Switch ids if sharing permission is granted on only |
| 1177 | 1177 | // one share to ensure correct parent is used if resharing |
| 1178 | - if (~(int)$items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE |
|
| 1179 | - && (int)$row['permissions'] & \OCP\Constants::PERMISSION_SHARE) { |
|
| 1178 | + if (~(int) $items[$id]['permissions'] & \OCP\Constants::PERMISSION_SHARE |
|
| 1179 | + && (int) $row['permissions'] & \OCP\Constants::PERMISSION_SHARE) { |
|
| 1180 | 1180 | $items[$row['id']] = $items[$id]; |
| 1181 | 1181 | $switchedItems[$id] = $row['id']; |
| 1182 | 1182 | unset($items[$id]); |
| 1183 | 1183 | $id = $row['id']; |
| 1184 | 1184 | } |
| 1185 | - $items[$id]['permissions'] |= (int)$row['permissions']; |
|
| 1185 | + $items[$id]['permissions'] |= (int) $row['permissions']; |
|
| 1186 | 1186 | |
| 1187 | 1187 | } |
| 1188 | 1188 | continue; |
@@ -1196,8 +1196,8 @@ discard block |
||
| 1196 | 1196 | $query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?'); |
| 1197 | 1197 | $parentResult = $query->execute(array($row['parent'])); |
| 1198 | 1198 | if ($result === false) { |
| 1199 | - \OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' . |
|
| 1200 | - \OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where, |
|
| 1199 | + \OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: '. |
|
| 1200 | + \OC_DB::getErrorMessage().', select='.$select.' where='.$where, |
|
| 1201 | 1201 | ILogger::ERROR); |
| 1202 | 1202 | } else { |
| 1203 | 1203 | $parentRow = $parentResult->fetchRow(); |
@@ -1207,7 +1207,7 @@ discard block |
||
| 1207 | 1207 | $subPath = substr($row['path'], $pos); |
| 1208 | 1208 | $splitPath = explode('/', $subPath); |
| 1209 | 1209 | foreach (array_slice($splitPath, 2) as $pathPart) { |
| 1210 | - $tmpPath = $tmpPath . '/' . $pathPart; |
|
| 1210 | + $tmpPath = $tmpPath.'/'.$pathPart; |
|
| 1211 | 1211 | } |
| 1212 | 1212 | $row['path'] = $tmpPath; |
| 1213 | 1213 | } |
@@ -1226,7 +1226,7 @@ discard block |
||
| 1226 | 1226 | } |
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | - if($checkExpireDate) { |
|
| 1229 | + if ($checkExpireDate) { |
|
| 1230 | 1230 | if (self::expireItem($row)) { |
| 1231 | 1231 | continue; |
| 1232 | 1232 | } |
@@ -1237,11 +1237,11 @@ discard block |
||
| 1237 | 1237 | } |
| 1238 | 1238 | // Add display names to result |
| 1239 | 1239 | $row['share_with_displayname'] = $row['share_with']; |
| 1240 | - if ( isset($row['share_with']) && $row['share_with'] != '' && |
|
| 1240 | + if (isset($row['share_with']) && $row['share_with'] != '' && |
|
| 1241 | 1241 | $row['share_type'] === self::SHARE_TYPE_USER) { |
| 1242 | 1242 | $shareWithUser = \OC::$server->getUserManager()->get($row['share_with']); |
| 1243 | 1243 | $row['share_with_displayname'] = $shareWithUser === null ? $row['share_with'] : $shareWithUser->getDisplayName(); |
| 1244 | - } else if(isset($row['share_with']) && $row['share_with'] != '' && |
|
| 1244 | + } else if (isset($row['share_with']) && $row['share_with'] != '' && |
|
| 1245 | 1245 | $row['share_type'] === self::SHARE_TYPE_REMOTE) { |
| 1246 | 1246 | $addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']); |
| 1247 | 1247 | foreach ($addressBookEntries as $entry) { |
@@ -1252,7 +1252,7 @@ discard block |
||
| 1252 | 1252 | } |
| 1253 | 1253 | } |
| 1254 | 1254 | } |
| 1255 | - if ( isset($row['uid_owner']) && $row['uid_owner'] != '') { |
|
| 1255 | + if (isset($row['uid_owner']) && $row['uid_owner'] != '') { |
|
| 1256 | 1256 | $ownerUser = \OC::$server->getUserManager()->get($row['uid_owner']); |
| 1257 | 1257 | $row['displayname_owner'] = $ownerUser === null ? $row['uid_owner'] : $ownerUser->getDisplayName(); |
| 1258 | 1258 | } |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | // for file/folder shares we need to compare file_source, otherwise we compare item_source |
| 1402 | 1402 | // only group shares if they already point to the same target, otherwise the file where shared |
| 1403 | 1403 | // before grouping of shares was added. In this case we don't group them toi avoid confusions |
| 1404 | - if (( $fileSharing && $item['file_source'] === $r['file_source'] && $item['file_target'] === $r['file_target']) || |
|
| 1404 | + if (($fileSharing && $item['file_source'] === $r['file_source'] && $item['file_target'] === $r['file_target']) || |
|
| 1405 | 1405 | (!$fileSharing && $item['item_source'] === $r['item_source'] && $item['item_target'] === $r['item_target'])) { |
| 1406 | 1406 | // add the first item to the list of grouped shares |
| 1407 | 1407 | if (!isset($result[$key]['grouped'])) { |
@@ -1447,7 +1447,7 @@ discard block |
||
| 1447 | 1447 | $groupItemTarget = $itemTarget = $fileSource = $parent = 0; |
| 1448 | 1448 | |
| 1449 | 1449 | $result = self::checkReshare($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $itemSourceName, $expirationDate); |
| 1450 | - if(!empty($result)) { |
|
| 1450 | + if (!empty($result)) { |
|
| 1451 | 1451 | $parent = $result['parent']; |
| 1452 | 1452 | $itemSource = $result['itemSource']; |
| 1453 | 1453 | $fileSource = $result['fileSource']; |
@@ -1541,11 +1541,11 @@ discard block |
||
| 1541 | 1541 | $itemTarget = $sourceExists['item_target']; |
| 1542 | 1542 | |
| 1543 | 1543 | // for group shares we don't need a additional entry if the target is the same |
| 1544 | - if($isGroupShare && $groupItemTarget === $itemTarget) { |
|
| 1544 | + if ($isGroupShare && $groupItemTarget === $itemTarget) { |
|
| 1545 | 1545 | continue; |
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | - } elseif(!$sourceExists && !$isGroupShare) { |
|
| 1548 | + } elseif (!$sourceExists && !$isGroupShare) { |
|
| 1549 | 1549 | |
| 1550 | 1550 | $itemTarget = Helper::generateTarget($itemType, $itemSource, $userShareType, $user, |
| 1551 | 1551 | $uidOwner, $suggestedItemTarget, $parent); |
@@ -1676,8 +1676,8 @@ discard block |
||
| 1676 | 1676 | |
| 1677 | 1677 | if ($checkReshare && $checkReshare['uid_owner'] !== \OC_User::getUser()) { |
| 1678 | 1678 | // Check if share permissions is granted |
| 1679 | - if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) { |
|
| 1680 | - if (~(int)$checkReshare['permissions'] & $permissions) { |
|
| 1679 | + if (self::isResharingAllowed() && (int) $checkReshare['permissions'] & \OCP\Constants::PERMISSION_SHARE) { |
|
| 1680 | + if (~(int) $checkReshare['permissions'] & $permissions) { |
|
| 1681 | 1681 | $message = 'Sharing %s failed, because the permissions exceed permissions granted to %s'; |
| 1682 | 1682 | $message_t = $l->t('Sharing %s failed, because the permissions exceed permissions granted to %s', array($itemSourceName, $uidOwner)); |
| 1683 | 1683 | |
@@ -1689,7 +1689,7 @@ discard block |
||
| 1689 | 1689 | |
| 1690 | 1690 | $result['expirationDate'] = $expirationDate; |
| 1691 | 1691 | // $checkReshare['expiration'] could be null and then is always less than any value |
| 1692 | - if(isset($checkReshare['expiration']) && $checkReshare['expiration'] < $expirationDate) { |
|
| 1692 | + if (isset($checkReshare['expiration']) && $checkReshare['expiration'] < $expirationDate) { |
|
| 1693 | 1693 | $result['expirationDate'] = $checkReshare['expiration']; |
| 1694 | 1694 | } |
| 1695 | 1695 | |
@@ -1781,7 +1781,7 @@ discard block |
||
| 1781 | 1781 | |
| 1782 | 1782 | $id = false; |
| 1783 | 1783 | if ($result) { |
| 1784 | - $id = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share'); |
|
| 1784 | + $id = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share'); |
|
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | 1787 | return $id; |
@@ -1809,8 +1809,8 @@ discard block |
||
| 1809 | 1809 | return true; |
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | - if ( \OC::$server->getSession()->exists('public_link_authenticated') |
|
| 1813 | - && \OC::$server->getSession()->get('public_link_authenticated') === (string)$linkItem['id'] ) { |
|
| 1812 | + if (\OC::$server->getSession()->exists('public_link_authenticated') |
|
| 1813 | + && \OC::$server->getSession()->get('public_link_authenticated') === (string) $linkItem['id']) { |
|
| 1814 | 1814 | return true; |
| 1815 | 1815 | } |
| 1816 | 1816 | |
@@ -1912,7 +1912,7 @@ discard block |
||
| 1912 | 1912 | * @param array $parameters additional format parameters |
| 1913 | 1913 | * @return array format result |
| 1914 | 1914 | */ |
| 1915 | - private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE , $parameters = null) { |
|
| 1915 | + private static function formatResult($items, $column, $backend, $format = self::FORMAT_NONE, $parameters = null) { |
|
| 1916 | 1916 | if ($format === self::FORMAT_NONE) { |
| 1917 | 1917 | return $items; |
| 1918 | 1918 | } else if ($format === self::FORMAT_STATUSES) { |
@@ -1969,13 +1969,13 @@ discard block |
||
| 1969 | 1969 | $try = 0; |
| 1970 | 1970 | $discoveryService = \OC::$server->query(\OCP\OCS\IDiscoveryService::class); |
| 1971 | 1971 | while ($result['success'] === false && $try < 2) { |
| 1972 | - $federationEndpoints = $discoveryService->discover($protocol . $remoteDomain, 'FEDERATED_SHARING'); |
|
| 1972 | + $federationEndpoints = $discoveryService->discover($protocol.$remoteDomain, 'FEDERATED_SHARING'); |
|
| 1973 | 1973 | $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares'; |
| 1974 | 1974 | $client = \OC::$server->getHTTPClientService()->newClient(); |
| 1975 | 1975 | |
| 1976 | 1976 | try { |
| 1977 | 1977 | $response = $client->post( |
| 1978 | - $protocol . $remoteDomain . $endpoint . $urlSuffix . '?format=' . self::RESPONSE_FORMAT, |
|
| 1978 | + $protocol.$remoteDomain.$endpoint.$urlSuffix.'?format='.self::RESPONSE_FORMAT, |
|
| 1979 | 1979 | [ |
| 1980 | 1980 | 'body' => $fields, |
| 1981 | 1981 | 'connect_timeout' => 10, |
@@ -2075,7 +2075,7 @@ discard block |
||
| 2075 | 2075 | * @return int |
| 2076 | 2076 | */ |
| 2077 | 2077 | public static function getExpireInterval() { |
| 2078 | - return (int)\OC::$server->getConfig()->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 2078 | + return (int) \OC::$server->getConfig()->getAppValue('core', 'shareapi_expire_after_n_days', '7'); |
|
| 2079 | 2079 | } |
| 2080 | 2080 | |
| 2081 | 2081 | /** |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param array $urlParams |
| 83 | 83 | * @param ServerContainer|null $server |
| 84 | 84 | */ |
| 85 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
| 85 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null) { |
|
| 86 | 86 | parent::__construct(); |
| 87 | 87 | $this['AppName'] = $appName; |
| 88 | 88 | $this['urlParams'] = $urlParams; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | /** |
| 103 | 103 | * Core services |
| 104 | 104 | */ |
| 105 | - $this->registerService(IOutput::class, function($c){ |
|
| 105 | + $this->registerService(IOutput::class, function($c) { |
|
| 106 | 106 | return new Output($this->getServer()->getWebRoot()); |
| 107 | 107 | }); |
| 108 | 108 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | return $this->getServer()->getUserFolder(); |
| 111 | 111 | }); |
| 112 | 112 | |
| 113 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
| 113 | + $this->registerService(IAppData::class, function(SimpleContainer $c) { |
|
| 114 | 114 | return $this->getServer()->getAppDataDir($c->query('AppName')); |
| 115 | 115 | }); |
| 116 | 116 | |
@@ -131,37 +131,37 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
| 133 | 133 | |
| 134 | - $this->registerService(IServerContainer::class, function ($c) { |
|
| 134 | + $this->registerService(IServerContainer::class, function($c) { |
|
| 135 | 135 | return $this->getServer(); |
| 136 | 136 | }); |
| 137 | 137 | $this->registerAlias('ServerContainer', IServerContainer::class); |
| 138 | 138 | |
| 139 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
| 139 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function($c) { |
|
| 140 | 140 | return $c->query(Manager::class); |
| 141 | 141 | }); |
| 142 | 142 | |
| 143 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
| 143 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function($c) { |
|
| 144 | 144 | return $c; |
| 145 | 145 | }); |
| 146 | 146 | |
| 147 | 147 | // commonly used attributes |
| 148 | - $this->registerService('UserId', function ($c) { |
|
| 148 | + $this->registerService('UserId', function($c) { |
|
| 149 | 149 | return $c->query(IUserSession::class)->getSession()->get('user_id'); |
| 150 | 150 | }); |
| 151 | 151 | |
| 152 | - $this->registerService('WebRoot', function ($c) { |
|
| 152 | + $this->registerService('WebRoot', function($c) { |
|
| 153 | 153 | return $c->query('ServerContainer')->getWebRoot(); |
| 154 | 154 | }); |
| 155 | 155 | |
| 156 | - $this->registerService('OC_Defaults', function ($c) { |
|
| 156 | + $this->registerService('OC_Defaults', function($c) { |
|
| 157 | 157 | return $c->getServer()->getThemingDefaults(); |
| 158 | 158 | }); |
| 159 | 159 | |
| 160 | - $this->registerService(IManager::class, function ($c) { |
|
| 160 | + $this->registerService(IManager::class, function($c) { |
|
| 161 | 161 | return $this->getServer()->getEncryptionManager(); |
| 162 | 162 | }); |
| 163 | 163 | |
| 164 | - $this->registerService(IConfig::class, function ($c) { |
|
| 164 | + $this->registerService(IConfig::class, function($c) { |
|
| 165 | 165 | return $c->query(OC\GlobalScale\Config::class); |
| 166 | 166 | }); |
| 167 | 167 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | return $c->query(Validator::class); |
| 170 | 170 | }); |
| 171 | 171 | |
| 172 | - $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
| 172 | + $this->registerService(\OC\Security\IdentityProof\Manager::class, function($c) { |
|
| 173 | 173 | return new \OC\Security\IdentityProof\Manager( |
| 174 | 174 | $this->getServer()->query(\OC\Files\AppData\Factory::class), |
| 175 | 175 | $this->getServer()->getCrypto(), |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | ); |
| 178 | 178 | }); |
| 179 | 179 | |
| 180 | - $this->registerService('Protocol', function($c){ |
|
| 180 | + $this->registerService('Protocol', function($c) { |
|
| 181 | 181 | /** @var \OC\Server $server */ |
| 182 | 182 | $server = $c->query('ServerContainer'); |
| 183 | 183 | $protocol = $server->getRequest()->getHttpProtocol(); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | ); |
| 226 | 226 | }); |
| 227 | 227 | |
| 228 | - $this->registerService(OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware::class, function ($c) use ($app) { |
|
| 228 | + $this->registerService(OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware::class, function($c) use ($app) { |
|
| 229 | 229 | /** @var \OC\Server $server */ |
| 230 | 230 | $server = $app->getServer(); |
| 231 | 231 | |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | ); |
| 278 | 278 | }); |
| 279 | 279 | |
| 280 | - $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
| 280 | + $this->registerService('TwoFactorMiddleware', function(SimpleContainer $c) use ($app) { |
|
| 281 | 281 | $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
| 282 | 282 | $userSession = $app->getServer()->getUserSession(); |
| 283 | 283 | $session = $app->getServer()->getSession(); |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
| 288 | 288 | }); |
| 289 | 289 | |
| 290 | - $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
| 290 | + $this->registerService('OCSMiddleware', function(SimpleContainer $c) { |
|
| 291 | 291 | return new OCSMiddleware( |
| 292 | 292 | $c['Request'] |
| 293 | 293 | ); |
| 294 | 294 | }); |
| 295 | 295 | |
| 296 | - $this->registerService(OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware::class, function (SimpleContainer $c) { |
|
| 296 | + $this->registerService(OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware::class, function(SimpleContainer $c) { |
|
| 297 | 297 | return new OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware( |
| 298 | 298 | $c['Request'], |
| 299 | 299 | $c['ControllerMethodReflector'] |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | $dispatcher->registerMiddleware($c['BruteForceMiddleware']); |
| 313 | 313 | $dispatcher->registerMiddleware($c['RateLimitingMiddleware']); |
| 314 | 314 | |
| 315 | - foreach($middleWares as $middleWare) { |
|
| 315 | + foreach ($middleWares as $middleWare) { |
|
| 316 | 316 | $dispatcher->registerMiddleware($c[$middleWare]); |
| 317 | 317 | } |
| 318 | 318 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | * @return mixed |
| 375 | 375 | */ |
| 376 | 376 | public function log($message, $level) { |
| 377 | - switch($level){ |
|
| 377 | + switch ($level) { |
|
| 378 | 378 | case 'debug': |
| 379 | 379 | $level = ILogger::DEBUG; |
| 380 | 380 | break; |
@@ -440,12 +440,12 @@ discard block |
||
| 440 | 440 | return parent::query($name); |
| 441 | 441 | } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
| 442 | 442 | return parent::query($name); |
| 443 | - } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
| 443 | + } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']).'\\') === 0) { |
|
| 444 | 444 | return parent::query($name); |
| 445 | 445 | } |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - throw new QueryException('Could not resolve ' . $name . '!' . |
|
| 448 | + throw new QueryException('Could not resolve '.$name.'!'. |
|
| 449 | 449 | ' Class can not be instantiated', 1); |
| 450 | 450 | } |
| 451 | 451 | } |
@@ -33,21 +33,21 @@ discard block |
||
| 33 | 33 | use Icewind\Streams\CallbackWrapper; |
| 34 | 34 | use OCP\ILogger; |
| 35 | 35 | |
| 36 | -class ZIP extends Archive{ |
|
| 36 | +class ZIP extends Archive { |
|
| 37 | 37 | /** |
| 38 | 38 | * @var \ZipArchive zip |
| 39 | 39 | */ |
| 40 | - private $zip=null; |
|
| 40 | + private $zip = null; |
|
| 41 | 41 | private $path; |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @param string $source |
| 45 | 45 | */ |
| 46 | 46 | public function __construct($source) { |
| 47 | - $this->path=$source; |
|
| 48 | - $this->zip=new \ZipArchive(); |
|
| 49 | - if($this->zip->open($source, \ZipArchive::CREATE)) { |
|
| 50 | - }else{ |
|
| 47 | + $this->path = $source; |
|
| 48 | + $this->zip = new \ZipArchive(); |
|
| 49 | + if ($this->zip->open($source, \ZipArchive::CREATE)) { |
|
| 50 | + } else { |
|
| 51 | 51 | \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | * @param string $source either a local file or string data |
| 66 | 66 | * @return bool |
| 67 | 67 | */ |
| 68 | - public function addFile($path, $source='') { |
|
| 69 | - if($source and $source[0]=='/' and file_exists($source)) { |
|
| 70 | - $result=$this->zip->addFile($source, $path); |
|
| 71 | - }else{ |
|
| 72 | - $result=$this->zip->addFromString($path, $source); |
|
| 68 | + public function addFile($path, $source = '') { |
|
| 69 | + if ($source and $source[0] == '/' and file_exists($source)) { |
|
| 70 | + $result = $this->zip->addFile($source, $path); |
|
| 71 | + } else { |
|
| 72 | + $result = $this->zip->addFromString($path, $source); |
|
| 73 | 73 | } |
| 74 | - if($result) { |
|
| 75 | - $this->zip->close();//close and reopen to save the zip |
|
| 74 | + if ($result) { |
|
| 75 | + $this->zip->close(); //close and reopen to save the zip |
|
| 76 | 76 | $this->zip->open($this->path); |
| 77 | 77 | } |
| 78 | 78 | return $result; |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | * @return boolean|null |
| 85 | 85 | */ |
| 86 | 86 | public function rename($source, $dest) { |
| 87 | - $source=$this->stripPath($source); |
|
| 88 | - $dest=$this->stripPath($dest); |
|
| 87 | + $source = $this->stripPath($source); |
|
| 88 | + $dest = $this->stripPath($dest); |
|
| 89 | 89 | $this->zip->renameName($source, $dest); |
| 90 | 90 | } |
| 91 | 91 | /** |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @return int |
| 95 | 95 | */ |
| 96 | 96 | public function filesize($path) { |
| 97 | - $stat=$this->zip->statName($path); |
|
| 97 | + $stat = $this->zip->statName($path); |
|
| 98 | 98 | return $stat['size']; |
| 99 | 99 | } |
| 100 | 100 | /** |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | * @return array |
| 112 | 112 | */ |
| 113 | 113 | public function getFolder($path) { |
| 114 | - $files=$this->getFiles(); |
|
| 115 | - $folderContent=array(); |
|
| 116 | - $pathLength=strlen($path); |
|
| 117 | - foreach($files as $file) { |
|
| 118 | - if(substr($file, 0, $pathLength)==$path and $file!=$path) { |
|
| 119 | - if(strrpos(substr($file, 0, -1), '/')<=$pathLength) { |
|
| 120 | - $folderContent[]=substr($file, $pathLength); |
|
| 114 | + $files = $this->getFiles(); |
|
| 115 | + $folderContent = array(); |
|
| 116 | + $pathLength = strlen($path); |
|
| 117 | + foreach ($files as $file) { |
|
| 118 | + if (substr($file, 0, $pathLength) == $path and $file != $path) { |
|
| 119 | + if (strrpos(substr($file, 0, -1), '/') <= $pathLength) { |
|
| 120 | + $folderContent[] = substr($file, $pathLength); |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | * @return array |
| 129 | 129 | */ |
| 130 | 130 | public function getFiles() { |
| 131 | - $fileCount=$this->zip->numFiles; |
|
| 132 | - $files=array(); |
|
| 133 | - for($i=0;$i<$fileCount;$i++) { |
|
| 134 | - $files[]=$this->zip->getNameIndex($i); |
|
| 131 | + $fileCount = $this->zip->numFiles; |
|
| 132 | + $files = array(); |
|
| 133 | + for ($i = 0; $i < $fileCount; $i++) { |
|
| 134 | + $files[] = $this->zip->getNameIndex($i); |
|
| 135 | 135 | } |
| 136 | 136 | return $files; |
| 137 | 137 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @return bool |
| 168 | 168 | */ |
| 169 | 169 | public function fileExists($path) { |
| 170 | - return ($this->zip->locateName($path)!==false) or ($this->zip->locateName($path.'/')!==false); |
|
| 170 | + return ($this->zip->locateName($path) !== false) or ($this->zip->locateName($path.'/') !== false); |
|
| 171 | 171 | } |
| 172 | 172 | /** |
| 173 | 173 | * remove a file or folder from the archive |
@@ -175,9 +175,9 @@ discard block |
||
| 175 | 175 | * @return bool |
| 176 | 176 | */ |
| 177 | 177 | public function remove($path) { |
| 178 | - if($this->fileExists($path.'/')) { |
|
| 178 | + if ($this->fileExists($path.'/')) { |
|
| 179 | 179 | return $this->zip->deleteName($path.'/'); |
| 180 | - }else{ |
|
| 180 | + } else { |
|
| 181 | 181 | return $this->zip->deleteName($path); |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -188,23 +188,23 @@ discard block |
||
| 188 | 188 | * @return resource |
| 189 | 189 | */ |
| 190 | 190 | public function getStream($path, $mode) { |
| 191 | - if($mode=='r' or $mode=='rb') { |
|
| 191 | + if ($mode == 'r' or $mode == 'rb') { |
|
| 192 | 192 | return $this->zip->getStream($path); |
| 193 | 193 | } else { |
| 194 | 194 | //since we can't directly get a writable stream, |
| 195 | 195 | //make a temp copy of the file and put it back |
| 196 | 196 | //in the archive when the stream is closed |
| 197 | - if(strrpos($path, '.')!==false) { |
|
| 198 | - $ext=substr($path, strrpos($path, '.')); |
|
| 199 | - }else{ |
|
| 200 | - $ext=''; |
|
| 197 | + if (strrpos($path, '.') !== false) { |
|
| 198 | + $ext = substr($path, strrpos($path, '.')); |
|
| 199 | + } else { |
|
| 200 | + $ext = ''; |
|
| 201 | 201 | } |
| 202 | 202 | $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); |
| 203 | - if($this->fileExists($path)) { |
|
| 203 | + if ($this->fileExists($path)) { |
|
| 204 | 204 | $this->extractFile($path, $tmpFile); |
| 205 | 205 | } |
| 206 | 206 | $handle = fopen($tmpFile, $mode); |
| 207 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
| 207 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
| 208 | 208 | $this->writeBack($tmpFile, $path); |
| 209 | 209 | }); |
| 210 | 210 | } |
@@ -223,9 +223,9 @@ discard block |
||
| 223 | 223 | * @return string |
| 224 | 224 | */ |
| 225 | 225 | private function stripPath($path) { |
| 226 | - if(!$path || $path[0]=='/') { |
|
| 226 | + if (!$path || $path[0] == '/') { |
|
| 227 | 227 | return substr($path, 1); |
| 228 | - }else{ |
|
| 228 | + } else { |
|
| 229 | 229 | return $path; |
| 230 | 230 | } |
| 231 | 231 | } |