securitysettingscontroller.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @author Lukas Reschke <lukas@owncloud.com>
  4. * @author Morris Jobke <hey@morrisjobke.de>
  5. *
  6. * @copyright Copyright (c) 2015, ownCloud, Inc.
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OC\Settings\Controller;
  23. use \OCP\AppFramework\Controller;
  24. use OCP\IRequest;
  25. use OCP\IConfig;
  26. /**
  27. * @package OC\Settings\Controller
  28. */
  29. class SecuritySettingsController extends Controller {
  30. /** @var \OCP\IConfig */
  31. private $config;
  32. /**
  33. * @param string $appName
  34. * @param IRequest $request
  35. * @param IConfig $config
  36. */
  37. public function __construct($appName,
  38. IRequest $request,
  39. IConfig $config) {
  40. parent::__construct($appName, $request);
  41. $this->config = $config;
  42. }
  43. /**
  44. * @return array
  45. */
  46. protected function returnSuccess() {
  47. return array(
  48. 'status' => 'success'
  49. );
  50. }
  51. /**
  52. * Add a new trusted domain
  53. * @param string $newTrustedDomain The newly to add trusted domain
  54. * @return array
  55. */
  56. public function trustedDomains($newTrustedDomain) {
  57. $trustedDomains = $this->config->getSystemValue('trusted_domains');
  58. $trustedDomains[] = $newTrustedDomain;
  59. $this->config->setSystemValue('trusted_domains', $trustedDomains);
  60. return $this->returnSuccess();
  61. }
  62. }