settings.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * ownCloud - user_ldap
  4. *
  5. * @author Dominik Schmidt
  6. * @copyright 2011 Dominik Schmidt dev@dominik-schmidt.de
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library 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
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. $params = array('ldap_host', 'ldap_port', 'ldap_dn', 'ldap_password', 'ldap_base', 'ldap_base_users', 'ldap_base_groups', 'ldap_userlist_filter', 'ldap_login_filter', 'ldap_group_filter', 'ldap_display_name', 'ldap_tls', 'ldap_nocase', 'ldap_quota_def', 'ldap_quota_attr', 'ldap_email_attr', 'ldap_group_member_assoc_attribute');
  23. OCP\Util::addscript('user_ldap', 'settings');
  24. if ($_POST) {
  25. foreach($params as $param){
  26. if(isset($_POST[$param])){
  27. OCP\Config::setAppValue('user_ldap', $param, $_POST[$param]);
  28. }
  29. elseif('ldap_tls' == $param) {
  30. // unchecked checkboxes are not included in the post paramters
  31. OCP\Config::setAppValue('user_ldap', $param, 0);
  32. }
  33. elseif('ldap_nocase' == $param) {
  34. OCP\Config::setAppValue('user_ldap', $param, 0);
  35. }
  36. }
  37. }
  38. // fill template
  39. $tmpl = new OCP\Template( 'user_ldap', 'settings');
  40. foreach($params as $param){
  41. $value = OCP\Config::getAppValue('user_ldap', $param,'');
  42. $tmpl->assign($param, $value);
  43. }
  44. // settings with default values
  45. $tmpl->assign( 'ldap_port', OCP\Config::getAppValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT));
  46. $tmpl->assign( 'ldap_display_name', OCP\Config::getAppValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME));
  47. $tmpl->assign( 'ldap_group_member_assoc_attribute', OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember'));
  48. return $tmpl->fetchPage();