Admin.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\User_LDAP\Settings;
  26. use OCA\User_LDAP\Configuration;
  27. use OCA\User_LDAP\Helper;
  28. use OCP\AppFramework\Http\TemplateResponse;
  29. use OCP\IL10N;
  30. use OCP\Settings\ISettings;
  31. use OCP\Template;
  32. class Admin implements ISettings {
  33. /** @var IL10N */
  34. private $l;
  35. /**
  36. * @param IL10N $l
  37. */
  38. public function __construct(IL10N $l) {
  39. $this->l = $l;
  40. }
  41. /**
  42. * @return TemplateResponse
  43. */
  44. public function getForm() {
  45. $helper = new Helper(\OC::$server->getConfig());
  46. $prefixes = $helper->getServerConfigurationPrefixes();
  47. $hosts = $helper->getServerConfigurationHosts();
  48. $wControls = new Template('user_ldap', 'part.wizardcontrols');
  49. $wControls = $wControls->fetchPage();
  50. $sControls = new Template('user_ldap', 'part.settingcontrols');
  51. $sControls = $sControls->fetchPage();
  52. $parameters['serverConfigurationPrefixes'] = $prefixes;
  53. $parameters['serverConfigurationHosts'] = $hosts;
  54. $parameters['settingControls'] = $sControls;
  55. $parameters['wizardControls'] = $wControls;
  56. // assign default values
  57. $config = new Configuration('', false);
  58. $defaults = $config->getDefaults();
  59. foreach($defaults as $key => $default) {
  60. $parameters[$key.'_default'] = $default;
  61. }
  62. return new TemplateResponse('user_ldap', 'settings', $parameters);
  63. }
  64. /**
  65. * @return string the section ID, e.g. 'sharing'
  66. */
  67. public function getSection() {
  68. return 'ldap';
  69. }
  70. /**
  71. * @return int whether the form should be rather on the top or bottom of
  72. * the admin section. The forms are arranged in ascending order of the
  73. * priority values. It is required to return a value between 0 and 100.
  74. *
  75. * E.g.: 70
  76. */
  77. public function getPriority() {
  78. return 5;
  79. }
  80. }