Config.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. namespace OC\GlobalScale;
  22. use OCP\IConfig;
  23. class Config implements \OCP\GlobalScale\IConfig {
  24. /** @var IConfig */
  25. private $config;
  26. /**
  27. * Config constructor.
  28. *
  29. * @param IConfig $config
  30. */
  31. public function __construct(IConfig $config) {
  32. $this->config = $config;
  33. }
  34. /**
  35. * check if global scale is enabled
  36. *
  37. * @since 12.0.1
  38. * @return bool
  39. */
  40. public function isGlobalScaleEnabled() {
  41. $enabled = $this->config->getSystemValue('gs.enabled', false);
  42. return $enabled !== false;
  43. }
  44. /**
  45. * check if federation should only be used internally in a global scale setup
  46. *
  47. * @since 12.0.1
  48. * @return bool
  49. */
  50. public function onlyInternalFederation() {
  51. // if global scale is disabled federation works always globally
  52. $gsEnabled = $this->isGlobalScaleEnabled();
  53. if ($gsEnabled === false) {
  54. return false;
  55. }
  56. $enabled = $this->config->getSystemValue('gs.federation', 'internal');
  57. return $enabled === 'internal';
  58. }
  59. }