diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/user_ldap/css/settings.css | 5 | ||||
-rw-r--r-- | apps/user_ldap/js/wizard/wizardTabElementary.js | 14 | ||||
-rw-r--r-- | apps/user_ldap/js/wizard/wizardTabGeneric.js | 35 | ||||
-rw-r--r-- | apps/user_ldap/lib/Configuration.php | 14 | ||||
-rw-r--r-- | apps/user_ldap/lib/Connection.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/templates/part.wizard-server.php | 12 |
6 files changed, 62 insertions, 20 deletions
diff --git a/apps/user_ldap/css/settings.css b/apps/user_ldap/css/settings.css index 129064ff8b0..54d0e2dbb0c 100644 --- a/apps/user_ldap/css/settings.css +++ b/apps/user_ldap/css/settings.css @@ -209,11 +209,6 @@ select[multiple=multiple] + button { color: #777; } -.outoftheway { - position: absolute; - left: -2000px; -} - #ldapSettings { background-color: white; padding: 0; diff --git a/apps/user_ldap/js/wizard/wizardTabElementary.js b/apps/user_ldap/js/wizard/wizardTabElementary.js index c8cb308952b..7ce1009565d 100644 --- a/apps/user_ldap/js/wizard/wizardTabElementary.js +++ b/apps/user_ldap/js/wizard/wizardTabElementary.js @@ -43,11 +43,15 @@ OCA = OCA || {}; }, ldap_dn: { $element: $('#ldap_dn'), - setMethod: 'setAgentDN' + setMethod: 'setAgentDN', + preventAutoSave: true, + $saveButton: $('.ldapSaveAgentCredentials') }, ldap_agent_password: { $element: $('#ldap_agent_password'), - setMethod: 'setAgentPwd' + setMethod: 'setAgentPwd', + preventAutoSave: true, + $saveButton: $('.ldapSaveAgentCredentials') }, ldap_base: { $element: $('#ldap_base'), @@ -65,7 +69,11 @@ OCA = OCA || {}; } }; this.setManagedItems(items); - _.bindAll(this, 'onPortButtonClick', 'onBaseDNButtonClick', 'onBaseDNTestButtonClick'); + _.bindAll(this, + 'onPortButtonClick', + 'onBaseDNButtonClick', + 'onBaseDNTestButtonClick' + ); this.managedItems.ldap_port.$relatedElements.click(this.onPortButtonClick); this.managedItems.ldap_base.$detectButton.click(this.onBaseDNButtonClick); this.managedItems.ldap_base.$testButton.click(this.onBaseDNTestButtonClick); diff --git a/apps/user_ldap/js/wizard/wizardTabGeneric.js b/apps/user_ldap/js/wizard/wizardTabGeneric.js index 98e26d303b5..57ac375e321 100644 --- a/apps/user_ldap/js/wizard/wizardTabGeneric.js +++ b/apps/user_ldap/js/wizard/wizardTabGeneric.js @@ -53,6 +53,7 @@ OCA = OCA || {}; setManagedItems: function(managedItems) { this.managedItems = managedItems; this._enableAutoSave(); + this._enableSaveButton(); }, /** @@ -319,7 +320,10 @@ OCA = OCA || {}; for(var id in this.managedItems) { if(_.isUndefined(this.managedItems[id].$element) - || _.isUndefined(this.managedItems[id].setMethod)) { + || _.isUndefined(this.managedItems[id].setMethod) + || (!_.isUndefined(this.managedItems[id].preventAutoSave) + && this.managedItems[id].preventAutoSave === true) + ) { continue; } var $element = this.managedItems[id].$element; @@ -332,6 +336,35 @@ OCA = OCA || {}; }, /** + * set's up save-button behavior (essentially used for agent dn and pwd) + * + * @private + */ + _enableSaveButton: function() { + var view = this; + + // TODO: this is not nice, because it fires one request per change + // in the scenario this happens twice, causes detectors to run + // duplicated etc. To have this work properly, the wizard endpoint + // must accept setting multiple changes. Instead of messing around + // with old ajax/wizard.php use this opportunity and create a + // Controller + for(var id in this.managedItems) { + if(_.isUndefined(this.managedItems[id].$element) + || _.isUndefined(this.managedItems[id].$saveButton) + ) { + continue; + } + (function (item) { + item.$saveButton.click(function(event) { + event.preventDefault(); + view._requestSave(item.$element); + }); + })(this.managedItems[id]); + } + }, + + /** * initializes a multiSelect element * * @param {jQuery} $element diff --git a/apps/user_ldap/lib/Configuration.php b/apps/user_ldap/lib/Configuration.php index bf8a9095a68..d971f2ffefd 100644 --- a/apps/user_ldap/lib/Configuration.php +++ b/apps/user_ldap/lib/Configuration.php @@ -37,9 +37,13 @@ namespace OCA\User_LDAP; * @property int ldapPagingSize holds an integer */ class Configuration { - protected $configPrefix = null; protected $configRead = false; + /** + * @var string[] pre-filled with one reference key so that at least one entry is written on save request and + * the config ID is registered + */ + protected $unsavedChanges = ['ldapConfigurationActive' => 'ldapConfigurationActive']; //settings protected $config = array( @@ -187,7 +191,9 @@ class Configuration { $this->$setMethod($key, $val); if(is_array($applied)) { $applied[] = $inputKey; + // storing key as index avoids duplication, and as value for simplicity } + $this->unsavedChanges[$key] = $key; } return null; } @@ -240,11 +246,12 @@ class Configuration { } /** - * saves the current Configuration in the database + * saves the current config changes in the database */ public function saveConfiguration() { $cta = array_flip($this->getConfigTranslationArray()); - foreach($this->config as $key => $value) { + foreach($this->unsavedChanges as $key) { + $value = $this->config[$key]; switch ($key) { case 'ldapAgentPassword': $value = base64_encode($value); @@ -275,6 +282,7 @@ class Configuration { } $this->saveValue($cta[$key], $value); } + $this->unsavedChanges = []; } /** diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 0f10874bc2f..79d66189c27 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -150,7 +150,7 @@ class Connection extends LDAPUtility { $this->configuration->$name = $value; $after = $this->configuration->$name; if($before !== $after) { - if ($this->configID !== '') { + if ($this->configID !== '' && $this->configID !== null) { $this->configuration->saveConfiguration(); } $this->validateConfiguration(); diff --git a/apps/user_ldap/templates/part.wizard-server.php b/apps/user_ldap/templates/part.wizard-server.php index f4f2abe0f91..9803fb3cd3c 100644 --- a/apps/user_ldap/templates/part.wizard-server.php +++ b/apps/user_ldap/templates/part.wizard-server.php @@ -1,10 +1,3 @@ -<div class="outoftheway"> - <!-- Hack for Safari and Chromium/Chrome which ignore autocomplete="off" --> - <input type="text" id="fake_user" name="fake_user" autocomplete="off" /> - <input type="password" id="fake_password" name="fake_password" - autocomplete="off" /> -</div> - <fieldset id="ldapWizard1"> <p> <select id="ldap_serverconfig_chooser" name="ldap_serverconfig_chooser"> @@ -54,6 +47,7 @@ </div> </div> </div> + <div class="tablerow"> </div> <div class="tablerow"> <input type="text" id="ldap_dn" name="ldap_dn" class="tablecell" @@ -68,7 +62,11 @@ placeholder="<?php p($l->t('Password'));?>" autocomplete="off" title="<?php p($l->t('For anonymous access, leave DN and Password empty.'));?>" /> + <button class="ldapSaveAgentCredentials" name="ldapSaveAgentCredentials" type="button"> + <?php p($l->t('Save Credentials'));?> + </button> </div> + <div class="tablerow"> </div> <div class="tablerow"> <textarea id="ldap_base" name="ldap_base" |