settings.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_filter', 'ldap_display_name', 'ldap_tls', 'ldap_nocase');
  23. if ($_POST) {
  24. foreach($params as $param){
  25. if(isset($_POST[$param])){
  26. OC_Appconfig::setValue('user_ldap', $param, $_POST[$param]);
  27. }
  28. elseif('ldap_tls' == $param) {
  29. // unchecked checkboxes are not included in the post paramters
  30. OC_Appconfig::setValue('user_ldap', $param, 0);
  31. }
  32. elseif('ldap_nocase' == $param) {
  33. OC_Appconfig::setValue('user_ldap', $param, 0);
  34. }
  35. }
  36. }
  37. // fill template
  38. $tmpl = new OC_Template( 'user_ldap', 'settings');
  39. foreach($params as $param){
  40. $value = OC_Appconfig::getValue('user_ldap', $param,'');
  41. $tmpl->assign($param, $value);
  42. }
  43. // ldap_port has a default value
  44. $tmpl->assign( 'ldap_port', OC_Appconfig::getValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT));
  45. // ldap_display_name has a default value
  46. $tmpl->assign( 'ldap_display_name', OC_Appconfig::getValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME));
  47. return $tmpl->fetchPage();