setConfiguration.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. // Check user and app status
  27. \OC_JSON::checkAdminUser();
  28. \OC_JSON::checkAppEnabled('user_ldap');
  29. \OC_JSON::callCheck();
  30. $prefix = (string)$_POST['ldap_serverconfig_chooser'];
  31. // Checkboxes are not submitted, when they are unchecked. Set them manually.
  32. // only legacy checkboxes (Advanced and Expert tab) need to be handled here,
  33. // the Wizard-like tabs handle it on their own
  34. $chkboxes = ['ldap_configuration_active', 'ldap_override_main_server',
  35. 'ldap_turn_off_cert_check'];
  36. foreach ($chkboxes as $boxid) {
  37. if (!isset($_POST[$boxid])) {
  38. $_POST[$boxid] = 0;
  39. }
  40. }
  41. $ldapWrapper = new OCA\User_LDAP\LDAP();
  42. $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix);
  43. $connection->setConfiguration($_POST);
  44. $connection->saveConfiguration();
  45. \OC_JSON::success();