@@ -97,7 +97,7 @@ |
||
| 97 | 97 | <?php include '/etc/grommunio-web/disclaimer.html'; ?> |
| 98 | 98 | </div> |
| 99 | 99 | <?php } |
| 100 | - elseif (file_exists('disclaimer.html')) { ?> |
|
| 100 | +elseif (file_exists('disclaimer.html')) { ?> |
|
| 101 | 101 | <div class="disclaimer"> |
| 102 | 102 | <?php include 'disclaimer.html'; ?> |
| 103 | 103 | </div> |
@@ -10,15 +10,13 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * Constructor. |
| 12 | 12 | */ |
| 13 | - public function __construct() |
|
| 14 | - { |
|
| 13 | + public function __construct() { |
|
| 15 | 14 | } |
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | 17 | * Called to initialize the plugin and register for hooks. |
| 19 | 18 | */ |
| 20 | - public function init() |
|
| 21 | - { |
|
| 19 | + public function init() { |
|
| 22 | 20 | $this->registerHook('server.core.settings.init.before'); |
| 23 | 21 | } |
| 24 | 22 | |
@@ -28,8 +26,7 @@ discard block |
||
| 28 | 26 | * @param string $eventID Identifier of the hook |
| 29 | 27 | * @param array $data Reference to the data of the triggered hook |
| 30 | 28 | */ |
| 31 | - public function execute($eventID, &$data) |
|
| 32 | - { |
|
| 29 | + public function execute($eventID, &$data) { |
|
| 33 | 30 | switch ($eventID) { |
| 34 | 31 | case 'server.core.settings.init.before': |
| 35 | 32 | $this->onBeforeSettingsInit($data); |
@@ -43,8 +40,7 @@ discard block |
||
| 43 | 40 | * |
| 44 | 41 | * @param array $data Reference to the data of the triggered hook |
| 45 | 42 | */ |
| 46 | - public function onBeforeSettingsInit(&$data) |
|
| 47 | - { |
|
| 43 | + public function onBeforeSettingsInit(&$data) { |
|
| 48 | 44 | $data['settingsObj']->addSysAdminDefaults([ |
| 49 | 45 | 'zarafa' => [ |
| 50 | 46 | 'v1' => [ |
@@ -100,8 +100,7 @@ discard block |
||
| 100 | 100 | /** |
| 101 | 101 | * Seafile backend constructor |
| 102 | 102 | */ |
| 103 | - public function __construct() |
|
| 104 | - { |
|
| 103 | + public function __construct() { |
|
| 105 | 104 | // initialization |
| 106 | 105 | $this->debug = PLUGIN_FILESBROWSER_LOGLEVEL === 'DEBUG'; |
| 107 | 106 | |
@@ -132,19 +131,20 @@ discard block |
||
| 132 | 131 | * @throws BackendException if connection is not successful |
| 133 | 132 | * @return boolean true if action succeeded |
| 134 | 133 | */ |
| 135 | - public function open() |
|
| 136 | - { |
|
| 134 | + public function open() { |
|
| 137 | 135 | $url = $this->config->getApiUrl(); |
| 138 | 136 | |
| 139 | 137 | try { |
| 140 | 138 | $this->sso->open(); |
| 141 | - } catch (Throwable $throwable) { |
|
| 139 | + } |
|
| 140 | + catch (Throwable $throwable) { |
|
| 142 | 141 | $this->backendException($throwable); |
| 143 | 142 | } |
| 144 | 143 | |
| 145 | 144 | try { |
| 146 | 145 | $this->seafapi = new SeafileApi($url, $this->config->user, $this->config->pass); |
| 147 | - } catch (Throwable $throwable) { |
|
| 146 | + } |
|
| 147 | + catch (Throwable $throwable) { |
|
| 148 | 148 | $this->backendException($throwable); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -160,15 +160,15 @@ discard block |
||
| 160 | 160 | * |
| 161 | 161 | * @return array |
| 162 | 162 | */ |
| 163 | - public function ls($dir, $hidefirst = true) |
|
| 164 | - { |
|
| 163 | + public function ls($dir, $hidefirst = true) { |
|
| 165 | 164 | $timer = new Timer(); |
| 166 | 165 | $this->log("[LS] '$dir'"); |
| 167 | 166 | |
| 168 | 167 | if ('' === trim($dir, '/')) { |
| 169 | 168 | try { |
| 170 | 169 | $listing = $this->seafapi->listLibraries(); |
| 171 | - } catch (Throwable $throwable) { |
|
| 170 | + } |
|
| 171 | + catch (Throwable $throwable) { |
|
| 172 | 172 | $this->backendException($throwable); |
| 173 | 173 | } |
| 174 | 174 | goto result; |
@@ -183,7 +183,8 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | try { |
| 185 | 185 | $listing = $this->seafapi->listItemsInDirectory($lsDir->lib, $lsDir->path ?? ''); |
| 186 | - } catch (Throwable $throwable) { |
|
| 186 | + } |
|
| 187 | + catch (Throwable $throwable) { |
|
| 187 | 188 | $this->backendException($throwable); |
| 188 | 189 | } |
| 189 | 190 | |
@@ -221,8 +222,7 @@ discard block |
||
| 221 | 222 | * @throws BackendException |
| 222 | 223 | * @return bool |
| 223 | 224 | */ |
| 224 | - public function mkcol($dir) |
|
| 225 | - { |
|
| 225 | + public function mkcol($dir) { |
|
| 226 | 226 | $timer = new Timer(); |
| 227 | 227 | $this->log("[MKCOL] '$dir'"); |
| 228 | 228 | |
@@ -231,17 +231,20 @@ discard block |
||
| 231 | 231 | try { |
| 232 | 232 | $result = $this->seafapi->createLibrary($dir); |
| 233 | 233 | unset($result); |
| 234 | - } catch (Throwable $throwable) { |
|
| 234 | + } |
|
| 235 | + catch (Throwable $throwable) { |
|
| 235 | 236 | $this->backendException($throwable); |
| 236 | 237 | } |
| 237 | 238 | $success = true; |
| 238 | - } else { |
|
| 239 | + } |
|
| 240 | + else { |
|
| 239 | 241 | // create directory within library |
| 240 | 242 | $lib = $this->seafapi->getLibraryFromPath($dir)->id; |
| 241 | 243 | [, $path] = explode('/', trim($dir, '/'), 2); |
| 242 | 244 | try { |
| 243 | 245 | $result = $this->seafapi->createNewDirectory($lib, $path); |
| 244 | - } catch (Throwable $throwable) { |
|
| 246 | + } |
|
| 247 | + catch (Throwable $throwable) { |
|
| 245 | 248 | $this->backendException($throwable); |
| 246 | 249 | } |
| 247 | 250 | $success = 'success' === $result; |
@@ -258,8 +261,7 @@ discard block |
||
| 258 | 261 | * @throws BackendException |
| 259 | 262 | * @return bool |
| 260 | 263 | */ |
| 261 | - public function delete($path) |
|
| 262 | - { |
|
| 264 | + public function delete($path) { |
|
| 263 | 265 | $timer = new Timer(); |
| 264 | 266 | $this->log("[DELETE] '$path'"); |
| 265 | 267 | |
@@ -268,15 +270,18 @@ discard block |
||
| 268 | 270 | try { |
| 269 | 271 | $this->seafapi->deleteLibraryByName($path); |
| 270 | 272 | $result = 'success'; |
| 271 | - } catch (Throwable $throwable) { |
|
| 273 | + } |
|
| 274 | + catch (Throwable $throwable) { |
|
| 272 | 275 | $this->backendException($throwable); |
| 273 | 276 | } |
| 274 | - } else { |
|
| 277 | + } |
|
| 278 | + else { |
|
| 275 | 279 | // delete file or directory within library |
| 276 | 280 | $deletePath = $this->splitGrommunioPath($path); |
| 277 | 281 | try { |
| 278 | 282 | $result = $this->seafapi->deleteFile($deletePath->lib, $deletePath->path); |
| 279 | - } catch (Throwable $throwable) { |
|
| 283 | + } |
|
| 284 | + catch (Throwable $throwable) { |
|
| 280 | 285 | $this->backendException($throwable); |
| 281 | 286 | } |
| 282 | 287 | } |
@@ -294,8 +299,7 @@ discard block |
||
| 294 | 299 | * @throws BackendException |
| 295 | 300 | * @return bool |
| 296 | 301 | */ |
| 297 | - public function move($src_path, $dst_path, $overwrite = false) |
|
| 298 | - { |
|
| 302 | + public function move($src_path, $dst_path, $overwrite = false) { |
|
| 299 | 303 | $timer = new Timer(); |
| 300 | 304 | $this->log("[MOVE] '$src_path' -> '$dst_path'"); |
| 301 | 305 | |
@@ -323,7 +327,8 @@ discard block |
||
| 323 | 327 | try { |
| 324 | 328 | $this->seafapi->renameLibrary($src->libName, $dst->libName); |
| 325 | 329 | $result = true; |
| 326 | - } catch (Throwable $throwable) { |
|
| 330 | + } |
|
| 331 | + catch (Throwable $throwable) { |
|
| 327 | 332 | $this->backendException($throwable); |
| 328 | 333 | } |
| 329 | 334 | goto done; |
@@ -345,7 +350,8 @@ discard block |
||
| 345 | 350 | if ($isIntraLibTransaction && $pathsHaveSameDirNames) { |
| 346 | 351 | try { |
| 347 | 352 | $result = $this->seafapi->renameFile($src->lib, $src->path, basename($dst->path)); |
| 348 | - } catch (Throwable $throwable) { |
|
| 353 | + } |
|
| 354 | + catch (Throwable $throwable) { |
|
| 349 | 355 | $this->backendException($throwable); |
| 350 | 356 | } |
| 351 | 357 | goto done; |
@@ -355,7 +361,8 @@ discard block |
||
| 355 | 361 | if (isset($src->path, $dst->lib)) { |
| 356 | 362 | try { |
| 357 | 363 | $result = $this->seafapi->moveFile($src->lib, $src->path, $dst->lib, $dirNames[1]); |
| 358 | - } catch (Throwable $throwable) { |
|
| 364 | + } |
|
| 365 | + catch (Throwable $throwable) { |
|
| 359 | 366 | $this->backendException($throwable); |
| 360 | 367 | } |
| 361 | 368 | } |
@@ -381,8 +388,7 @@ discard block |
||
| 381 | 388 | * |
| 382 | 389 | * @return boolean true if action succeeded |
| 383 | 390 | */ |
| 384 | - public function get($path, &$buffer) |
|
| 385 | - { |
|
| 391 | + public function get($path, &$buffer) { |
|
| 386 | 392 | $timer = new Timer(); |
| 387 | 393 | $this->log("[GET] '$path'"); |
| 388 | 394 | |
@@ -390,7 +396,8 @@ discard block |
||
| 390 | 396 | |
| 391 | 397 | try { |
| 392 | 398 | $result = $this->seafapi->downloadFileAsBuffer($src->lib, $src->path); |
| 393 | - } catch (Throwable $throwable) { |
|
| 399 | + } |
|
| 400 | + catch (Throwable $throwable) { |
|
| 394 | 401 | $this->backendException($throwable); |
| 395 | 402 | } |
| 396 | 403 | |
@@ -414,8 +421,7 @@ discard block |
||
| 414 | 421 | * |
| 415 | 422 | * @return boolean true if action succeeded |
| 416 | 423 | */ |
| 417 | - public function get_file($srcpath, $localpath) |
|
| 418 | - { |
|
| 424 | + public function get_file($srcpath, $localpath) { |
|
| 419 | 425 | $timer = new Timer(); |
| 420 | 426 | $this->log("[GET_FILE] '$srcpath' -> '$localpath'"); |
| 421 | 427 | |
@@ -423,7 +429,8 @@ discard block |
||
| 423 | 429 | |
| 424 | 430 | try { |
| 425 | 431 | $result = $this->seafapi->downloadFileToFile($src->lib, $src->path, $localpath); |
| 426 | - } catch (Throwable $throwable) { |
|
| 432 | + } |
|
| 433 | + catch (Throwable $throwable) { |
|
| 427 | 434 | $this->backendException($throwable); |
| 428 | 435 | } |
| 429 | 436 | |
@@ -441,8 +448,7 @@ discard block |
||
| 441 | 448 | * |
| 442 | 449 | * @return boolean true if action succeeded |
| 443 | 450 | */ |
| 444 | - public function put($path, $data) |
|
| 445 | - { |
|
| 451 | + public function put($path, $data) { |
|
| 446 | 452 | $timer = new Timer(); |
| 447 | 453 | $this->log(sprintf("[PUT] start: path: %s (%d)", $path, strlen($data))); |
| 448 | 454 | |
@@ -451,7 +457,8 @@ discard block |
||
| 451 | 457 | try { |
| 452 | 458 | /** @noinspection PhpUnusedLocalVariableInspection */ |
| 453 | 459 | $result = $this->seafapi->uploadBuffer($target->lib, $target->path, $data); |
| 454 | - } catch (Throwable $throwable) { |
|
| 460 | + } |
|
| 461 | + catch (Throwable $throwable) { |
|
| 455 | 462 | $this->backendException($throwable); |
| 456 | 463 | } |
| 457 | 464 | |
@@ -469,8 +476,7 @@ discard block |
||
| 469 | 476 | * |
| 470 | 477 | * @return boolean true if action succeeded |
| 471 | 478 | */ |
| 472 | - public function put_file($path, $filename) |
|
| 473 | - { |
|
| 479 | + public function put_file($path, $filename) { |
|
| 474 | 480 | $timer = new Timer(); |
| 475 | 481 | $this->log(sprintf("[PUT_FILE] %s -> %s", $filename, $path)); |
| 476 | 482 | |
@@ -485,7 +491,8 @@ discard block |
||
| 485 | 491 | if ($target->path === null && $target->libName !== null) { |
| 486 | 492 | try { |
| 487 | 493 | $defaultLibrary = $this->seafapi->getDefaultLibrary(); |
| 488 | - } catch (Throwable $throwable) { |
|
| 494 | + } |
|
| 495 | + catch (Throwable $throwable) { |
|
| 489 | 496 | $this->backendException($throwable); |
| 490 | 497 | } |
| 491 | 498 | if (isset($defaultLibrary->repo_id, $defaultLibrary->exists) && true === $defaultLibrary->exists) { |
@@ -498,7 +505,8 @@ discard block |
||
| 498 | 505 | try { |
| 499 | 506 | /** @noinspection PhpUnusedLocalVariableInspection */ |
| 500 | 507 | $result = $this->seafapi->uploadFile($target->lib, $target->path, $filename); |
| 501 | - } catch (Throwable $throwable) { |
|
| 508 | + } |
|
| 509 | + catch (Throwable $throwable) { |
|
| 502 | 510 | $this->backendException($throwable); |
| 503 | 511 | } |
| 504 | 512 | |
@@ -516,8 +524,7 @@ discard block |
||
| 516 | 524 | * @param $backend_config |
| 517 | 525 | * @return void |
| 518 | 526 | */ |
| 519 | - public function init_backend($backend_config) |
|
| 520 | - { |
|
| 527 | + public function init_backend($backend_config) { |
|
| 521 | 528 | $config = $backend_config; |
| 522 | 529 | |
| 523 | 530 | if ($backend_config["use_zarafa_credentials"]) { |
@@ -530,7 +537,8 @@ discard block |
||
| 530 | 537 | $config['user'] = $encryptionStore->get('username'); |
| 531 | 538 | $config['password'] = $encryptionStore->get('password'); |
| 532 | 539 | } |
| 533 | - } else { |
|
| 540 | + } |
|
| 541 | + else { |
|
| 534 | 542 | $config['user'] = ConfigUtil::loadSmtpAddress(); |
| 535 | 543 | $password = $_SESSION['password']; |
| 536 | 544 | if (function_exists('openssl_decrypt')) { |
@@ -551,11 +559,11 @@ discard block |
||
| 551 | 559 | * @return false|string |
| 552 | 560 | * @noinspection PhpMultipleClassDeclarationsInspection Grommunio has a \JsonException shim |
| 553 | 561 | */ |
| 554 | - public function getFormConfig() |
|
| 555 | - { |
|
| 562 | + public function getFormConfig() { |
|
| 556 | 563 | try { |
| 557 | 564 | $json = json_encode($this->metaConfig, JSON_THROW_ON_ERROR); |
| 558 | - } catch (JsonException $e) { |
|
| 565 | + } |
|
| 566 | + catch (JsonException $e) { |
|
| 559 | 567 | $this->log(sprintf('[%s]: %s', get_class($e), $e->getMessage())); |
| 560 | 568 | $json = false; |
| 561 | 569 | } |
@@ -563,8 +571,7 @@ discard block |
||
| 563 | 571 | return $json; |
| 564 | 572 | } |
| 565 | 573 | |
| 566 | - public function getFormConfigWithData() |
|
| 567 | - { |
|
| 574 | + public function getFormConfigWithData() { |
|
| 568 | 575 | return $this->getFormConfig(); |
| 569 | 576 | } |
| 570 | 577 | |
@@ -576,8 +583,7 @@ discard block |
||
| 576 | 583 | * |
| 577 | 584 | * @return void |
| 578 | 585 | */ |
| 579 | - public function set_debug($debug) |
|
| 580 | - { |
|
| 586 | + public function set_debug($debug) { |
|
| 581 | 587 | $this->debug = (bool)$debug; |
| 582 | 588 | } |
| 583 | 589 | |
@@ -595,8 +601,7 @@ discard block |
||
| 595 | 601 | * @return bool |
| 596 | 602 | * @noinspection PhpReturnDocTypeMismatchInspection Upstream Interface Issue |
| 597 | 603 | */ |
| 598 | - public function copy_coll($src_path, $dst_path, $overwrite = false) |
|
| 599 | - { |
|
| 604 | + public function copy_coll($src_path, $dst_path, $overwrite = false) { |
|
| 600 | 605 | $this->backendError(self::SFA_ERR_UNIMPLEMENTED, 'Not implemented'); |
| 601 | 606 | } |
| 602 | 607 | |
@@ -610,8 +615,7 @@ discard block |
||
| 610 | 615 | * @return bool |
| 611 | 616 | * @noinspection PhpReturnDocTypeMismatchInspection Upstream Interface Issue |
| 612 | 617 | */ |
| 613 | - public function copy_file($src_path, $dst_path, $overwrite = false) |
|
| 614 | - { |
|
| 618 | + public function copy_file($src_path, $dst_path, $overwrite = false) { |
|
| 615 | 619 | $this->backendError(self::SFA_ERR_UNIMPLEMENTED, 'Not implemented'); |
| 616 | 620 | } |
| 617 | 621 | |
@@ -623,8 +627,7 @@ discard block |
||
| 623 | 627 | * @return bool |
| 624 | 628 | * @noinspection PhpReturnDocTypeMismatchInspection Upstream Interface Issue |
| 625 | 629 | */ |
| 626 | - public function exists($path) |
|
| 627 | - { |
|
| 630 | + public function exists($path) { |
|
| 628 | 631 | $this->backendError(self::SFA_ERR_UNIMPLEMENTED, 'Not implemented'); |
| 629 | 632 | } |
| 630 | 633 | |
@@ -635,8 +638,7 @@ discard block |
||
| 635 | 638 | * @throws BackendException if request is not successful |
| 636 | 639 | * @return array directory info |
| 637 | 640 | */ |
| 638 | - public function gpi($path) |
|
| 639 | - { |
|
| 641 | + public function gpi($path) { |
|
| 640 | 642 | $this->log("[GPI] '$path'"); |
| 641 | 643 | $list = $this->ls(dirname($path), false); // get contents of the parent dir |
| 642 | 644 | |
@@ -656,8 +658,7 @@ discard block |
||
| 656 | 658 | * @return bool |
| 657 | 659 | * @noinspection PhpReturnDocTypeMismatchInspection Upstream Interface Issue |
| 658 | 660 | */ |
| 659 | - public function is_dir($path) |
|
| 660 | - { |
|
| 661 | + public function is_dir($path) { |
|
| 661 | 662 | $this->backendError(self::SFA_ERR_UNIMPLEMENTED, 'Not implemented'); |
| 662 | 663 | } |
| 663 | 664 | |
@@ -669,8 +670,7 @@ discard block |
||
| 669 | 670 | * @return bool |
| 670 | 671 | * @noinspection PhpReturnDocTypeMismatchInspection Upstream Interface Issue |
| 671 | 672 | */ |
| 672 | - public function is_file($path) |
|
| 673 | - { |
|
| 673 | + public function is_file($path) { |
|
| 674 | 674 | $this->backendError(self::SFA_ERR_UNIMPLEMENTED, 'Not implemented'); |
| 675 | 675 | } |
| 676 | 676 | |
@@ -684,11 +684,11 @@ discard block |
||
| 684 | 684 | * @throws BackendException |
| 685 | 685 | * @return String |
| 686 | 686 | */ |
| 687 | - public function getServerVersion() |
|
| 688 | - { |
|
| 687 | + public function getServerVersion() { |
|
| 689 | 688 | try { |
| 690 | 689 | return $this->seafapi->getServerVersion(); |
| 691 | - } catch (Throwable $throwable) { |
|
| 690 | + } |
|
| 691 | + catch (Throwable $throwable) { |
|
| 692 | 692 | $this->backendException($throwable); |
| 693 | 693 | } |
| 694 | 694 | } |
@@ -703,8 +703,7 @@ discard block |
||
| 703 | 703 | * @noinspection PhpMissingParamTypeInspection |
| 704 | 704 | * @noinspection PhpUnusedParameterInspection |
| 705 | 705 | */ |
| 706 | - public function getQuotaBytesUsed($dir) |
|
| 707 | - { |
|
| 706 | + public function getQuotaBytesUsed($dir) { |
|
| 708 | 707 | $return = $this->seafapi->checkAccountInfo(); |
| 709 | 708 | |
| 710 | 709 | return ($return->usage ?? 0) * self::QUOTA_MULTIPLIER_SEAFILE_TO_GROMMUNIO; |
@@ -716,8 +715,7 @@ discard block |
||
| 716 | 715 | * @noinspection PhpUnusedParameterInspection |
| 717 | 716 | * @noinspection PhpMissingParamTypeInspection |
| 718 | 717 | */ |
| 719 | - public function getQuotaBytesAvailable($dir) |
|
| 720 | - { |
|
| 718 | + public function getQuotaBytesAvailable($dir) { |
|
| 721 | 719 | $return = $this->seafapi->checkAccountInfo(); |
| 722 | 720 | $avail = $return->total - $return->usage; |
| 723 | 721 | if (-2 === (int)$return->total) { |
@@ -734,8 +732,7 @@ discard block |
||
| 734 | 732 | /** |
| 735 | 733 | * Initialise form fields |
| 736 | 734 | */ |
| 737 | - private function init_form() |
|
| 738 | - { |
|
| 735 | + private function init_form() { |
|
| 739 | 736 | $this->metaConfig = [ |
| 740 | 737 | "success" => true, |
| 741 | 738 | "metaData" => [ |
@@ -861,8 +858,7 @@ discard block |
||
| 861 | 858 | * @throws BackendException |
| 862 | 859 | * @return no-return |
| 863 | 860 | */ |
| 864 | - private function backendError(int $errorCode, string $title = null) |
|
| 865 | - { |
|
| 861 | + private function backendError(int $errorCode, string $title = null) { |
|
| 866 | 862 | $message = $this->parseErrorCodeToMessage($errorCode); |
| 867 | 863 | $title = $this->backendTransName; |
| 868 | 864 | $this->backendErrorThrow($title, $message, $errorCode); |
@@ -877,8 +873,7 @@ discard block |
||
| 877 | 873 | * @throws BackendException |
| 878 | 874 | * @return no-return |
| 879 | 875 | */ |
| 880 | - private function backendErrorThrow(string $title, string $message, int $code = 0) |
|
| 881 | - { |
|
| 876 | + private function backendErrorThrow(string $title, string $message, int $code = 0) { |
|
| 882 | 877 | /** {@see \Files\Backend\Exception} */ |
| 883 | 878 | $exception = new BackendException($message, $code); |
| 884 | 879 | $exception->setTitle($title); |
@@ -892,8 +887,7 @@ discard block |
||
| 892 | 887 | * @throws BackendException |
| 893 | 888 | * @return no-return |
| 894 | 889 | */ |
| 895 | - private function backendException(Throwable $t) |
|
| 896 | - { |
|
| 890 | + private function backendException(Throwable $t) { |
|
| 897 | 891 | // if it is already a backend exception, throw it. |
| 898 | 892 | if ($t instanceof BackendException) { |
| 899 | 893 | throw $t; |
@@ -926,8 +920,7 @@ discard block |
||
| 926 | 920 | * @throws BackendException |
| 927 | 921 | * @return void |
| 928 | 922 | */ |
| 929 | - private function backendExceptionSeafapi(Exception $exception) |
|
| 930 | - { |
|
| 923 | + private function backendExceptionSeafapi(Exception $exception) { |
|
| 931 | 924 | $code = $exception->getCode(); |
| 932 | 925 | $message = $exception->getMessage(); |
| 933 | 926 | |
@@ -956,8 +949,7 @@ discard block |
||
| 956 | 949 | * |
| 957 | 950 | * @return void |
| 958 | 951 | */ |
| 959 | - private function log(string $err_string) |
|
| 960 | - { |
|
| 952 | + private function log(string $err_string) { |
|
| 961 | 953 | if ($this->debug) { |
| 962 | 954 | Logger::debug(self::LOG_CONTEXT, $err_string); |
| 963 | 955 | $this->debugLog($err_string, 2); |
@@ -973,8 +965,7 @@ discard block |
||
| 973 | 965 | * |
| 974 | 966 | * @return string user friendly error message |
| 975 | 967 | */ |
| 976 | - private function parseErrorCodeToMessage(int $error_code) |
|
| 977 | - { |
|
| 968 | + private function parseErrorCodeToMessage(int $error_code) { |
|
| 978 | 969 | $error = $error_code; |
| 979 | 970 | |
| 980 | 971 | switch ($error) { |
@@ -66,8 +66,7 @@ |
||
| 66 | 66 | |
| 67 | 67 | private array $config = []; |
| 68 | 68 | |
| 69 | - public function __construct(array $config = []) |
|
| 70 | - { |
|
| 69 | + public function __construct(array $config = []) { |
|
| 71 | 70 | $this->importConfigArray($config); |
| 72 | 71 | } |
| 73 | 72 | |
@@ -11,8 +11,7 @@ |
||
| 11 | 11 | { |
| 12 | 12 | private float $start; |
| 13 | 13 | |
| 14 | - public function __construct() |
|
| 15 | - { |
|
| 14 | + public function __construct() { |
|
| 16 | 15 | $this->start = microtime(true); |
| 17 | 16 | } |
| 18 | 17 | |
@@ -13,8 +13,7 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | * @return void |
| 15 | 15 | */ |
| 16 | - public function init() |
|
| 17 | - { |
|
| 16 | + public function init() { |
|
| 18 | 17 | $this->registerHook('server.core.settings.init.before'); |
| 19 | 18 | } |
| 20 | 19 | |
@@ -24,8 +23,7 @@ discard block |
||
| 24 | 23 | * @param String $eventID Identifier of the hook |
| 25 | 24 | * @param Array $data Reference to the data of the triggered hook |
| 26 | 25 | */ |
| 27 | - public function execute($eventID, &$data) |
|
| 28 | - { |
|
| 26 | + public function execute($eventID, &$data) { |
|
| 29 | 27 | switch ($eventID) { |
| 30 | 28 | case 'server.core.settings.init.before': |
| 31 | 29 | $this->onBeforeSettingsInit($data); |
@@ -41,8 +39,7 @@ discard block |
||
| 41 | 39 | * @param Array $data Reference to the data of the triggered hook |
| 42 | 40 | * @return void |
| 43 | 41 | */ |
| 44 | - public function onBeforeSettingsInit(&$data) |
|
| 45 | - { |
|
| 42 | + public function onBeforeSettingsInit(&$data) { |
|
| 46 | 43 | $data['settingsObj']->addSysAdminDefaults(array( |
| 47 | 44 | 'zarafa' => array( |
| 48 | 45 | 'v1' => array( |
@@ -122,8 +122,7 @@ discard block |
||
| 122 | 122 | * @param string $pass |
| 123 | 123 | * @param string|null $otp |
| 124 | 124 | */ |
| 125 | - public function __construct(string $baseurl, string $user, string $pass, string $otp = null) |
|
| 126 | - { |
|
| 125 | + public function __construct(string $baseurl, string $user, string $pass, string $otp = null) { |
|
| 127 | 126 | if (!(function_exists('curl_version'))) { |
| 128 | 127 | throw new ConnectionException('PHP-CURL not installed', self::ERROR_CODE_NO_CURL); |
| 129 | 128 | } |
@@ -603,8 +602,7 @@ discard block |
||
| 603 | 602 | * @throws InvalidArgumentException |
| 604 | 603 | * @return array |
| 605 | 604 | */ |
| 606 | - public function shareLibraryPathToGroup(string $lib, string $path, $group, string $permission = null) |
|
| 607 | - { |
|
| 605 | + public function shareLibraryPathToGroup(string $lib, string $path, $group, string $permission = null) { |
|
| 608 | 606 | $lib = $this->verifyLib($lib); |
| 609 | 607 | $path = $this->normalizePath($path); |
| 610 | 608 | $pathEncoded = rawurlencode($path); |
@@ -637,8 +635,7 @@ discard block |
||
| 637 | 635 | * @throws InvalidArgumentException |
| 638 | 636 | * @return array |
| 639 | 637 | */ |
| 640 | - public function shareLibraryPathToUser(string $lib, string $path, string $user, string $permission = null) |
|
| 641 | - { |
|
| 638 | + public function shareLibraryPathToUser(string $lib, string $path, string $user, string $permission = null) { |
|
| 642 | 639 | $lib = $this->verifyLib($lib); |
| 643 | 640 | $path = $this->normalizePath($path); |
| 644 | 641 | $pathEncoded = rawurlencode($path); |
@@ -751,8 +748,7 @@ discard block |
||
| 751 | 748 | * @throws InvalidArgumentException|Exception |
| 752 | 749 | * @return string|object the common "success" or the object with error_msg property |
| 753 | 750 | */ |
| 754 | - public function createNewDirectory(string $lib, string $path) |
|
| 755 | - { |
|
| 751 | + public function createNewDirectory(string $lib, string $path) { |
|
| 756 | 752 | $lib = $this->verifyLib($lib); |
| 757 | 753 | $path = $this->normalizePath($path); |
| 758 | 754 | $pathEncoded = rawurlencode($path); |
@@ -777,8 +773,7 @@ discard block |
||
| 777 | 773 | * @throws InvalidArgumentException|Exception |
| 778 | 774 | * @return string|object the common "success" or the known object with error_msg property |
| 779 | 775 | */ |
| 780 | - public function deleteFile(string $lib, string $path) |
|
| 781 | - { |
|
| 776 | + public function deleteFile(string $lib, string $path) { |
|
| 782 | 777 | $lib = $this->verifyLib($lib); |
| 783 | 778 | $path = $this->normalizePath($path); |
| 784 | 779 | $pathEncoded = rawurlencode($path); |
@@ -827,8 +822,7 @@ discard block |
||
| 827 | 822 | * @throws InvalidArgumentException|Exception |
| 828 | 823 | * @return string|false on failure |
| 829 | 824 | */ |
| 830 | - public function downloadFileAsBuffer(string $lib, string $path) |
|
| 831 | - { |
|
| 825 | + public function downloadFileAsBuffer(string $lib, string $path) { |
|
| 832 | 826 | $url = $this->downloadFile($lib, $path); |
| 833 | 827 | |
| 834 | 828 | return $this->get($url); |
@@ -852,7 +846,8 @@ discard block |
||
| 852 | 846 | |
| 853 | 847 | try { |
| 854 | 848 | $result = $this->downloadFileToStream($lib, $path, $handle); |
| 855 | - } finally { |
|
| 849 | + } |
|
| 850 | + finally { |
|
| 856 | 851 | $close = fclose($handle); |
| 857 | 852 | } |
| 858 | 853 | |
@@ -953,8 +948,7 @@ discard block |
||
| 953 | 948 | * @return string|object the common "success" or the known object with error_msg property |
| 954 | 949 | * @throws Exception |
| 955 | 950 | */ |
| 956 | - public function renameFile(string $lib, string $path, string $newName) |
|
| 957 | - { |
|
| 951 | + public function renameFile(string $lib, string $path, string $newName) { |
|
| 958 | 952 | $lib = $this->verifyLib($lib); |
| 959 | 953 | $path = $this->normalizePath($path); |
| 960 | 954 | $pathEncoded = rawurlencode($path); |
@@ -1417,8 +1411,7 @@ discard block |
||
| 1417 | 1411 | * @param array $curlOptions |
| 1418 | 1412 | * @return bool|string |
| 1419 | 1413 | */ |
| 1420 | - private function get(string $url, array $curlOptions = []) |
|
| 1421 | - { |
|
| 1414 | + private function get(string $url, array $curlOptions = []) { |
|
| 1422 | 1415 | $curlOptions += $this->curlSharedOptions; |
| 1423 | 1416 | |
| 1424 | 1417 | return $this->curlExec($url, $curlOptions); |
@@ -1432,8 +1425,7 @@ discard block |
||
| 1432 | 1425 | * @param array $curlOptions |
| 1433 | 1426 | * @return bool|string |
| 1434 | 1427 | */ |
| 1435 | - private function post(string $url, array $fields = [], array $curlOptions = []) |
|
| 1436 | - { |
|
| 1428 | + private function post(string $url, array $fields = [], array $curlOptions = []) { |
|
| 1437 | 1429 | $curlOptions += $this->curlSharedOptions; |
| 1438 | 1430 | $curlOptions[CURLOPT_POST] = true; |
| 1439 | 1431 | $curlOptions[CURLOPT_POSTFIELDS] = $fields; |
@@ -1449,8 +1441,7 @@ discard block |
||
| 1449 | 1441 | * @param array $curlOptions |
| 1450 | 1442 | * @return bool|string |
| 1451 | 1443 | */ |
| 1452 | - public function put(string $url, array $fields = [], array $curlOptions = []) |
|
| 1453 | - { |
|
| 1444 | + public function put(string $url, array $fields = [], array $curlOptions = []) { |
|
| 1454 | 1445 | $curlOptions += $this->curlSharedOptions; |
| 1455 | 1446 | $curlOptions[CURLOPT_CUSTOMREQUEST] = 'PUT'; |
| 1456 | 1447 | $curlOptions[CURLOPT_POSTFIELDS] = $fields; |
@@ -1465,8 +1456,7 @@ discard block |
||
| 1465 | 1456 | * @param array $curlOptions |
| 1466 | 1457 | * @return bool|string |
| 1467 | 1458 | */ |
| 1468 | - public function delete(string $url, array $curlOptions = []) |
|
| 1469 | - { |
|
| 1459 | + public function delete(string $url, array $curlOptions = []) { |
|
| 1470 | 1460 | |
| 1471 | 1461 | $curlOptions += $this->curlSharedOptions; |
| 1472 | 1462 | $curlOptions[CURLOPT_CUSTOMREQUEST] = 'DELETE'; |
@@ -1484,8 +1474,7 @@ discard block |
||
| 1484 | 1474 | * @throws InvalidResponseException |
| 1485 | 1475 | * @return string|object|array |
| 1486 | 1476 | */ |
| 1487 | - private function jsonDecode(string $jsonText, int $flags = self::JSON_DECODE_ACCEPT_DEFAULT) |
|
| 1488 | - { |
|
| 1477 | + private function jsonDecode(string $jsonText, int $flags = self::JSON_DECODE_ACCEPT_DEFAULT) { |
|
| 1489 | 1478 | $accept = $flags & self::JSON_DECODE_ACCEPT_MASK; |
| 1490 | 1479 | if (0 === $accept) { |
| 1491 | 1480 | return $jsonText; |
@@ -1564,8 +1553,7 @@ discard block |
||
| 1564 | 1553 | * @param array $options |
| 1565 | 1554 | * @return bool|string |
| 1566 | 1555 | */ |
| 1567 | - private function curlExec(string $url, array $options) |
|
| 1568 | - { |
|
| 1556 | + private function curlExec(string $url, array $options) { |
|
| 1569 | 1557 | $handle = curl_init($url); |
| 1570 | 1558 | if (!($handle instanceof CurlHandle)) { |
| 1571 | 1559 | throw new ConnectionException('Unable to initialise cURL session.', self::ERROR_CODE_NO_CURL); |
@@ -20,7 +20,8 @@ |
||
| 20 | 20 | $classFileName = $basePath . str_replace('\\', '/', $classNamespaceSuffix) . '.php'; |
| 21 | 21 | if (is_file($classFileName)) { |
| 22 | 22 | require($classFileName); |
| 23 | - } else { |
|
| 23 | + } |
|
| 24 | + else { |
|
| 24 | 25 | throw new \RuntimeException(sprintf('class: %s: no such file: %s', $className, $classFileName)); |
| 25 | 26 | } |
| 26 | 27 | } |
@@ -59,8 +59,7 @@ |
||
| 59 | 59 | return sprintf('%s %s', $code, self::HTTP_STATUS[$code] ?? "UNKNOWN_PHRASE"); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null) |
|
| 63 | - { |
|
| 62 | + public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null) { |
|
| 64 | 63 | // trigger E_USER_NOTICE if code is not known |
| 65 | 64 | $isHttpCode = 100 <= $code && $code < 600; |
| 66 | 65 | $isKnownHttpCode = $isHttpCode && isset(self::HTTP_STATUS[$code]); |