Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions apps/user_ldap/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,6 @@ select[multiple=multiple] + button {
color: #777;
}

.outoftheway {
position: absolute;
left: -2000px;
}

#ldapSettings {
background-color: white;
padding: 0;
Expand Down
14 changes: 11 additions & 3 deletions apps/user_ldap/js/wizard/wizardTabElementary.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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);
Expand Down
35 changes: 34 additions & 1 deletion apps/user_ldap/js/wizard/wizardTabGeneric.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ OCA = OCA || {};
setManagedItems: function(managedItems) {
this.managedItems = managedItems;
this._enableAutoSave();
this._enableSaveButton();
},

/**
Expand Down Expand Up @@ -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;
Expand All @@ -331,6 +335,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
*
Expand Down
14 changes: 11 additions & 3 deletions apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@
* @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(
Expand Down Expand Up @@ -185,7 +189,9 @@ public function setConfiguration($config, &$applied = null) {
$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;
}
Expand Down Expand Up @@ -238,11 +244,12 @@ public function readConfiguration() {
}

/**
* 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);
Expand Down Expand Up @@ -273,6 +280,7 @@ public function saveConfiguration() {
}
$this->saveValue($cta[$key], $value);
}
$this->unsavedChanges = [];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function __set($name, $value) {
$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();
Expand Down
12 changes: 5 additions & 7 deletions apps/user_ldap/templates/part.wizard-server.php
Original file line number Diff line number Diff line change
@@ -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">
Expand Down Expand Up @@ -54,6 +47,7 @@ class="ldapIconCopy icon-default-style"
</div>
</div>
</div>
<div class="tablerow">&nbsp;</div>
<div class="tablerow">
<input type="text" id="ldap_dn" name="ldap_dn"
class="tablecell"
Expand All @@ -68,7 +62,11 @@ class="tablecell" name="ldap_agent_password"
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">&nbsp;</div>

<div class="tablerow">
<textarea id="ldap_base" name="ldap_base"
Expand Down