settings.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_agent_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. if('ldap_agent_password' == $param) {
  28. OCP\Config::setAppValue('user_ldap', $param, base64_encode($_POST[$param]));
  29. } else {
  30. OCP\Config::setAppValue('user_ldap', $param, $_POST[$param]);
  31. }
  32. }
  33. elseif('ldap_tls' == $param) {
  34. // unchecked checkboxes are not included in the post paramters
  35. OCP\Config::setAppValue('user_ldap', $param, 0);
  36. }
  37. elseif('ldap_nocase' == $param) {
  38. OCP\Config::setAppValue('user_ldap', $param, 0);
  39. }
  40. }
  41. }
  42. // fill template
  43. $tmpl = new OCP\Template( 'user_ldap', 'settings');
  44. foreach($params as $param){
  45. $value = OCP\Config::getAppValue('user_ldap', $param,'');
  46. $tmpl->assign($param, $value);
  47. }
  48. // settings with default values
  49. $tmpl->assign( 'ldap_port', OCP\Config::getAppValue('user_ldap', 'ldap_port', OC_USER_BACKEND_LDAP_DEFAULT_PORT));
  50. $tmpl->assign( 'ldap_display_name', OCP\Config::getAppValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME));
  51. $tmpl->assign( 'ldap_group_member_assoc_attribute', OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember'));
  52. $tmpl->assign( 'ldap_agent_password', base64_decode(OCP\Config::getAppValue('user_ldap', 'ldap_agent_password')));
  53. return $tmpl->fetchPage();