From 805f900b1980ae1f5d69395fd646a9a4605b7c68 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 18 Jan 2013 13:45:39 +0100 Subject: [PATCH] LDAP: pass defaults to settings form, and restore them on creating a new configuration if wanted --- apps/user_ldap/js/settings.js | 12 +++++-- apps/user_ldap/settings.php | 13 +++++++- apps/user_ldap/templates/settings.php | 48 +++++++++++++-------------- 3 files changed, 46 insertions(+), 27 deletions(-) diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index 8cd31301f2e..0b8f141dfa2 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -34,8 +34,16 @@ $(document).ready(function() { 'Keep settings?', function(keep) { if(!keep) { - $('#ldap').find('input[type=text], input[type=password], textarea, select').val(''); - $('#ldap').find('input[type=checkbox]').removeAttr('checked'); + $('#ldap').find('input[type=text], input[type=number], input[type=password], textarea, select').each(function() { + $(this).val($(this).attr('data-default')); + }); + $('#ldap').find('input[type=checkbox]').each(function() { + if($(this).attr('data-default') == 1) { + $(this).attr('checked', 'checked'); + } else { + $(this).removeAttr('checked'); + } + }); } } ); diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index 73e4f0b6f4b..f3f0826739f 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -64,7 +64,7 @@ if($_POST) { } } if($clearCache) { - $ldap = new \OCA\user_ldap\lib\Connection('user_ldap'); + $ldap = new \OCA\user_ldap\lib\Connection(); $ldap->clearCache(); } } @@ -88,4 +88,15 @@ $hfnr = ($hfnr == 'opt:username') ? '' : substr($hfnr, strlen('attr:')); $tmpl->assign('home_folder_naming_rule', $hfnr, ''); $tmpl->assign('serverConfigurationOptions', '', false); +// assign default values +if(!isset($ldap)) { + $ldap = new \OCA\user_ldap\lib\Connection(); +} +$defaults = $ldap->getDefaults(); +foreach($defaults as $key => $default) { + $tmpl->assign($key.'_default', $default); +} + +// $tmpl->assign(); + return $tmpl->fetchPage(); diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index c3ec20fc847..90a46a1733a 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -17,32 +17,32 @@

-

-

-

-

-


t('use %%uid placeholder, e.g. "uid=%%uid"');?>

-


t('without any placeholder, e.g. "objectClass=person".');?>

-


t('without any placeholder, e.g. "objectClass=posixGroup".');?>

+

+

+

+

+


t('use %%uid placeholder, e.g. "uid=%%uid"');?>

+


t('without any placeholder, e.g. "objectClass=person".');?>

+


t('without any placeholder, e.g. "objectClass=posixGroup".');?>

-

-

-

-

title="t('When switched on, ownCloud will only connect to the replica server.');?>" />

-

-

-

-

title="t('Do not use it for SSL connections, it will fail.');?>" />

-

>

-

>
t('Not recommended, use for testing only.');?>

-

-

-

-

-

-

-

+

+

+

+

data-default="" title="t('When switched on, ownCloud will only connect to the replica server.');?>" />

+

+

+

+

data-default="" title="t('Do not use it for SSL connections, it will fail.');?>" />

+

>

+

>
t('Not recommended, use for testing only.');?>

+

+

+

+

+

+

+

t('Help');?>