settings.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * @author Frank Karlitschek <frank@owncloud.org>
  4. * @author Joas Schilling <nickvergessen@owncloud.com>
  5. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  6. * @author Lukas Reschke <lukas@owncloud.com>
  7. * @author Michael Gapczynski <GapczynskiM@gmail.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Vincent Petry <pvince81@owncloud.com>
  10. *
  11. * @copyright Copyright (c) 2015, ownCloud, Inc.
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. OC_Util::checkAdminUser();
  28. OCP\Util::addScript('files_external', 'settings');
  29. OCP\Util::addStyle('files_external', 'settings');
  30. \OC_Util::addVendorScript('select2/select2');
  31. \OC_Util::addVendorStyle('select2/select2');
  32. $backends = OC_Mount_Config::getBackends();
  33. $personal_backends = array();
  34. $enabled_backends = explode(',', OCP\Config::getAppValue('files_external', 'user_mounting_backends', ''));
  35. foreach ($backends as $class => $backend)
  36. {
  37. if ($class != '\OC\Files\Storage\Local')
  38. {
  39. $personal_backends[$class] = array(
  40. 'backend' => $backend['backend'],
  41. 'enabled' => in_array($class, $enabled_backends),
  42. );
  43. }
  44. }
  45. $mounts = OC_Mount_Config::getSystemMountPoints();
  46. $hasId = true;
  47. foreach ($mounts as $mount) {
  48. if (!isset($mount['id'])) {
  49. // some mount points are missing ids
  50. $hasId = false;
  51. break;
  52. }
  53. }
  54. if (!$hasId) {
  55. $service = new \OCA\Files_external\Service\GlobalStoragesService();
  56. // this will trigger the new storage code which will automatically
  57. // generate storage config ids
  58. $service->getAllStorages();
  59. // re-read updated config
  60. $mounts = OC_Mount_Config::getSystemMountPoints();
  61. // TODO: use the new storage config format in the template
  62. }
  63. $tmpl = new OCP\Template('files_external', 'settings');
  64. $tmpl->assign('encryptionEnabled', \OC::$server->getEncryptionManager()->isEnabled());
  65. $tmpl->assign('isAdminPage', true);
  66. $tmpl->assign('mounts', $mounts);
  67. $tmpl->assign('backends', $backends);
  68. $tmpl->assign('personal_backends', $personal_backends);
  69. $tmpl->assign('dependencies', OC_Mount_Config::checkDependencies());
  70. $tmpl->assign('allowUserMounting', OCP\Config::getAppValue('files_external', 'allow_user_mounting', 'yes'));
  71. return $tmpl->fetchPage();