summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-01-18 01:23:15 +0100
committerArthur Schiwon <blizzz@owncloud.com>2013-01-18 01:23:15 +0100
commita53addf8250ea47a36837463f15122339123aeff (patch)
tree53c89eb8549106000a418e58cf72bb9cf7881b85
parentd8be83029b107359884f9e23dd5bded71fea8999 (diff)
downloadnextcloud-server-a53addf8250ea47a36837463f15122339123aeff.tar.gz
nextcloud-server-a53addf8250ea47a36837463f15122339123aeff.zip
LDAP: first basics for multiserver config ui
-rw-r--r--apps/user_ldap/ajax/getNewServerConfigPrefix.php39
-rw-r--r--apps/user_ldap/js/settings.js33
-rw-r--r--apps/user_ldap/settings.php1
-rw-r--r--apps/user_ldap/templates/settings.php5
4 files changed, 78 insertions, 0 deletions
diff --git a/apps/user_ldap/ajax/getNewServerConfigPrefix.php b/apps/user_ldap/ajax/getNewServerConfigPrefix.php
new file mode 100644
index 00000000000..1a5f78cf214
--- /dev/null
+++ b/apps/user_ldap/ajax/getNewServerConfigPrefix.php
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * ownCloud - user_ldap
+ *
+ * @author Arthur Schiwon
+ * @copyright 2013 Arthur Schiwon blizzz@owncloud.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+// Check user and app status
+OCP\JSON::checkAdminUser();
+OCP\JSON::checkAppEnabled('user_ldap');
+OCP\JSON::callCheck();
+
+$query = \OCP\DB::prepare('
+ SELECT DISTINCT `configkey`
+ FROM `*PREFIX*appconfig`
+ WHERE `configkey` LIKE ?
+');
+$serverConnections = $query->execute(array('%ldap_login_filter'))->fetchAll();
+sort($serverConnections);
+$lk = array_pop($serverConnections);
+$ln = intval(str_replace('s', '', $lk));
+$nk = 's'.str_pad($ln+1, 2, '0', STR_PAD_LEFT);
+OCP\JSON::success(array('configPrefix' => $nk)); \ No newline at end of file
diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js
index 7063eead96a..8cd31301f2e 100644
--- a/apps/user_ldap/js/settings.js
+++ b/apps/user_ldap/js/settings.js
@@ -21,4 +21,37 @@ $(document).ready(function() {
}
);
});
+
+ $('#ldap_serverconfig_chooser').change(function(event) {
+ value = $('#ldap_serverconfig_chooser option:selected:first').attr('value');
+ if(value == 'NEW') {
+ $.post(
+ OC.filePath('user_ldap','ajax','getNewServerConfigPrefix.php'),
+ function (result) {
+ if(result.status == 'success') {
+ OC.dialogs.confirm(
+ 'Take over settings from recent server configuration?',
+ '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_serverconfig_chooser option:selected:first').removeAttr('selected');
+ var html = '<option value="'+result.configPrefix+'" selected>'+$('#ldap_serverconfig_chooser option').length+'. Server</option>';
+ $('#ldap_serverconfig_chooser option:last').before(html);
+ } else {
+ OC.dialogs.alert(
+ result.message,
+ 'Cannot add server configuration'
+ );
+ }
+ }
+ );
+ } else {
+ alert(value);
+ }
+ });
}); \ No newline at end of file
diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php
index e49f37da2de..35233dc987a 100644
--- a/apps/user_ldap/settings.php
+++ b/apps/user_ldap/settings.php
@@ -76,5 +76,6 @@ $tmpl->assign( 'ldap_cache_ttl', OCP\Config::getAppValue('user_ldap', 'ldap_cach
$hfnr = OCP\Config::getAppValue('user_ldap', 'home_folder_naming_rule', 'opt:username');
$hfnr = ($hfnr == 'opt:username') ? '' : substr($hfnr, strlen('attr:'));
$tmpl->assign( 'home_folder_naming_rule', $hfnr, '');
+$tmpl->assign('serverConfigurationOptions', '', false);
return $tmpl->fetchPage();
diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php
index 030fbff4aac..c3ec20fc847 100644
--- a/apps/user_ldap/templates/settings.php
+++ b/apps/user_ldap/templates/settings.php
@@ -12,6 +12,11 @@
}
?>
<fieldset id="ldapSettings-1">
+ <p><label for="ldap_serverconfig_chooser"><?php echo $l->t('Server configuration');?></label><select id="ldap_serverconfig_chooser" name="ldap_serverconfig_chooser">
+ <option value="" selected><?php echo $l->t('Default (1. Server)');?></option>
+ <?php echo $_['serverConfigurationOptions']; ?>
+ <option value="NEW"><?php echo $l->t('Add Server Configuration');?></option>
+ </select></p>
<p><label for="ldap_host"><?php echo $l->t('Host');?></label><input type="text" id="ldap_host" name="ldap_host" value="<?php echo $_['ldap_host']; ?>" title="<?php echo $l->t('You can omit the protocol, except you require SSL. Then start with ldaps://');?>"></p>
<p><label for="ldap_base"><?php echo $l->t('Base DN');?></label><textarea id="ldap_base" name="ldap_base" placeholder="<?php echo $l->t('One Base DN per line');?>" title="<?php echo $l->t('You can specify Base DN for users and groups in the Advanced tab');?>"><?php echo $_['ldap_base']; ?></textarea></p>
<p><label for="ldap_dn"><?php echo $l->t('User DN');?></label><input type="text" id="ldap_dn" name="ldap_dn" value="<?php echo $_['ldap_dn']; ?>" title="<?php echo $l->t('The DN of the client user with which the bind shall be done, e.g. uid=agent,dc=example,dc=com. For anonymous access, leave DN and Password empty.');?>" /></p>