1
0

Config.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\GlobalScale;
  7. use OCP\IConfig;
  8. class Config implements \OCP\GlobalScale\IConfig {
  9. /** @var IConfig */
  10. private $config;
  11. /**
  12. * Config constructor.
  13. *
  14. * @param IConfig $config
  15. */
  16. public function __construct(IConfig $config) {
  17. $this->config = $config;
  18. }
  19. /**
  20. * check if global scale is enabled
  21. *
  22. * @since 12.0.1
  23. * @return bool
  24. */
  25. public function isGlobalScaleEnabled() {
  26. return $this->config->getSystemValueBool('gs.enabled', false);
  27. }
  28. /**
  29. * check if federation should only be used internally in a global scale setup
  30. *
  31. * @since 12.0.1
  32. * @return bool
  33. */
  34. public function onlyInternalFederation() {
  35. // if global scale is disabled federation works always globally
  36. $gsEnabled = $this->isGlobalScaleEnabled();
  37. if ($gsEnabled === false) {
  38. return false;
  39. }
  40. $enabled = $this->config->getSystemValueString('gs.federation', 'internal');
  41. return $enabled === 'internal';
  42. }
  43. }