setConfiguration.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christopher Schäpers <kondou@ts.unde.re>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Lennart Rosam <hello@takuto.de>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. *
  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. // Check user and app status
  28. OCP\JSON::checkAdminUser();
  29. OCP\JSON::checkAppEnabled('user_ldap');
  30. OCP\JSON::callCheck();
  31. $prefix = (string)$_POST['ldap_serverconfig_chooser'];
  32. // Checkboxes are not submitted, when they are unchecked. Set them manually.
  33. // only legacy checkboxes (Advanced and Expert tab) need to be handled here,
  34. // the Wizard-like tabs handle it on their own
  35. $chkboxes = array('ldap_configuration_active', 'ldap_override_main_server',
  36. 'ldap_turn_off_cert_check');
  37. foreach($chkboxes as $boxid) {
  38. if(!isset($_POST[$boxid])) {
  39. $_POST[$boxid] = 0;
  40. }
  41. }
  42. $ldapWrapper = new OCA\User_LDAP\LDAP();
  43. $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix);
  44. $connection->setConfiguration($_POST);
  45. $connection->saveConfiguration();
  46. OCP\JSON::success();