go back in DN selection
This commit is contained in:
parent
d0388973e5
commit
f0cbe217eb
|
@ -1043,10 +1043,6 @@ window.lam.html.showDnSelection = function(fieldId, title, okText, cancelText, t
|
||||||
})
|
})
|
||||||
.done(function(jsonData) {
|
.done(function(jsonData) {
|
||||||
jQuery('#dlg_' + fieldId).html(jsonData.dialogData);
|
jQuery('#dlg_' + fieldId).html(jsonData.dialogData);
|
||||||
})
|
|
||||||
.fail(function() {
|
|
||||||
jQuery(this).dialog("close");
|
|
||||||
});
|
|
||||||
var buttonList = {};
|
var buttonList = {};
|
||||||
buttonList[cancelText] = function() { jQuery(this).dialog("close"); };
|
buttonList[cancelText] = function() { jQuery(this).dialog("close"); };
|
||||||
jQuery('#dlg_' + fieldId).dialog({
|
jQuery('#dlg_' + fieldId).dialog({
|
||||||
|
@ -1056,6 +1052,7 @@ window.lam.html.showDnSelection = function(fieldId, title, okText, cancelText, t
|
||||||
buttons: buttonList,
|
buttons: buttonList,
|
||||||
width: 'auto'
|
width: 'auto'
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1073,6 +1070,39 @@ window.lam.html.selectDn = function(el, fieldId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the DN selection.
|
||||||
|
*
|
||||||
|
* @param el element
|
||||||
|
* @param fieldId field id of dialog
|
||||||
|
* @param tokenName CSRF token name
|
||||||
|
* @param tokenValue CSRF token value
|
||||||
|
*/
|
||||||
|
window.lam.html.updateDnSelection = function(el, fieldId, tokenName, tokenValue) {
|
||||||
|
var fieldDiv = jQuery('#dlg_' + fieldId);
|
||||||
|
var dn = jQuery(el).parents('.row').data('dn');
|
||||||
|
var data = {
|
||||||
|
jsonInput: ''
|
||||||
|
};
|
||||||
|
data[tokenName] = tokenValue;
|
||||||
|
data['fieldId'] = fieldId;
|
||||||
|
data['dn'] = dn;
|
||||||
|
jQuery.ajax({
|
||||||
|
url: '../misc/ajax.php?function=dnselection',
|
||||||
|
method: 'POST',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
.done(function(jsonData) {
|
||||||
|
jQuery('#dlg_' + fieldId).html(jsonData.dialogData);
|
||||||
|
jQuery(fieldDiv).dialog({
|
||||||
|
position: {my: 'center', at: 'center', of: window}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.fail(function() {
|
||||||
|
jQuery(fieldDiv).dialog("close");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
window.lam.gui.equalHeight();
|
window.lam.gui.equalHeight();
|
||||||
window.lam.form.autoTrim();
|
window.lam.form.autoTrim();
|
||||||
|
|
|
@ -4,8 +4,7 @@ use \LAM\TOOLS\IMPORT_EXPORT\Importer;
|
||||||
use \LAM\TOOLS\IMPORT_EXPORT\Exporter;
|
use \LAM\TOOLS\IMPORT_EXPORT\Exporter;
|
||||||
use \LAM\TYPES\TypeManager;
|
use \LAM\TYPES\TypeManager;
|
||||||
use \htmlResponsiveRow;
|
use \htmlResponsiveRow;
|
||||||
use \htmlDiv;
|
use \htmlLink;
|
||||||
use \htmlGroup;
|
|
||||||
use \htmlOutputText;
|
use \htmlOutputText;
|
||||||
use \htmlButton;
|
use \htmlButton;
|
||||||
/*
|
/*
|
||||||
|
@ -181,9 +180,12 @@ class Ajax {
|
||||||
$dn = trim($_POST['dn']);
|
$dn = trim($_POST['dn']);
|
||||||
if (empty($dn) || !get_preg($dn, 'dn')) {
|
if (empty($dn) || !get_preg($dn, 'dn')) {
|
||||||
$dnList = $this->getDefaultDns();
|
$dnList = $this->getDefaultDns();
|
||||||
|
$dn = null;
|
||||||
}
|
}
|
||||||
$dnList = $this->getDefaultDns(); // TODO remove
|
else {
|
||||||
$html = $this->buildDnSelectionHtml($dnList);
|
$dnList = $this->getSubDns($dn);
|
||||||
|
}
|
||||||
|
$html = $this->buildDnSelectionHtml($dnList, $dn);
|
||||||
return json_encode(array('dialogData' => $html));
|
return json_encode(array('dialogData' => $html));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +208,7 @@ class Ajax {
|
||||||
$baseDnList[] = $suffix;
|
$baseDnList[] = $suffix;
|
||||||
}
|
}
|
||||||
$baseDnList = array_unique($baseDnList);
|
$baseDnList = array_unique($baseDnList);
|
||||||
sort($baseDnList);
|
usort($baseDnList, 'compareDN');
|
||||||
return $baseDnList;
|
return $baseDnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,14 +216,49 @@ class Ajax {
|
||||||
* Returns the HTML to build the DN selection list.
|
* Returns the HTML to build the DN selection list.
|
||||||
*
|
*
|
||||||
* @param string[] $dnList DN list
|
* @param string[] $dnList DN list
|
||||||
|
* @param string $currentDn current DN
|
||||||
*/
|
*/
|
||||||
private function buildDnSelectionHtml($dnList) {
|
private function buildDnSelectionHtml($dnList, $currentDn) {
|
||||||
$fieldId = trim($_POST['fieldId']);
|
$fieldId = trim($_POST['fieldId']);
|
||||||
$mainRow = new htmlResponsiveRow();
|
$mainRow = new htmlResponsiveRow();
|
||||||
|
if (!empty($currentDn)) {
|
||||||
|
$row = new htmlResponsiveRow();
|
||||||
|
$row->addDataAttribute('dn', $currentDn);
|
||||||
|
$text = new htmlOutputText($currentDn);
|
||||||
|
$text->setIsBold(true);
|
||||||
|
$row->add($text, 12, 9);
|
||||||
|
$row->setCSSClasses(array('text-right'));
|
||||||
|
$buttonId = base64_encode($currentDn);
|
||||||
|
$buttonId = str_replace('=', '', $buttonId);
|
||||||
|
$button = new htmlButton($buttonId, _('Ok'));
|
||||||
|
$button->setIconClass('okButton');
|
||||||
|
$button->setOnClick('window.lam.html.selectDn(this, \'' . htmlspecialchars($fieldId) . '\')');
|
||||||
|
$row->add($button, 12, 3);
|
||||||
|
$mainRow->add($row, 12);
|
||||||
|
// back up
|
||||||
|
$onclickUp = 'window.lam.html.updateDnSelection(this, \''
|
||||||
|
. htmlspecialchars($fieldId) . '\', \'' . getSecurityTokenName() . '\', \''
|
||||||
|
. getSecurityTokenValue() . '\')';
|
||||||
|
$row = new htmlResponsiveRow();
|
||||||
|
$row->addDataAttribute('dn', extractDNSuffix($currentDn));
|
||||||
|
$text = new htmlLink('..', '#');
|
||||||
|
$text->setCSSClasses(array('bold'));
|
||||||
|
$text->setOnClick($onclickUp);
|
||||||
|
$row->add($text, 12, 9);
|
||||||
|
$row->setCSSClasses(array('text-right'));
|
||||||
|
$buttonId = base64_encode('..');
|
||||||
|
$buttonId = str_replace('=', '', $buttonId);
|
||||||
|
$button = new htmlButton($buttonId, _('Up'));
|
||||||
|
$button->setIconClass('upButton');
|
||||||
|
$button->setOnClick($onclickUp);
|
||||||
|
$row->add($button, 12, 3);
|
||||||
|
$mainRow->add($row, 12);
|
||||||
|
}
|
||||||
foreach ($dnList as $dn) {
|
foreach ($dnList as $dn) {
|
||||||
$row = new htmlResponsiveRow();
|
$row = new htmlResponsiveRow();
|
||||||
$row->addDataAttribute('dn', $dn);
|
$row->addDataAttribute('dn', $dn);
|
||||||
$row->add(new htmlOutputText($dn), 12, 9);
|
$row->add(new htmlOutputText($dn), 12, 9);
|
||||||
|
$row->setCSSClasses(array('text-right'));
|
||||||
$buttonId = base64_encode($dn);
|
$buttonId = base64_encode($dn);
|
||||||
$buttonId = str_replace('=', '', $buttonId);
|
$buttonId = str_replace('=', '', $buttonId);
|
||||||
$button = new htmlButton($buttonId, _('Ok'));
|
$button = new htmlButton($buttonId, _('Ok'));
|
||||||
|
@ -238,6 +275,22 @@ class Ajax {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the sub DNs of given DN.
|
||||||
|
*
|
||||||
|
* @param string $dn DN
|
||||||
|
* @return string[] sub DNs
|
||||||
|
*/
|
||||||
|
private function getSubDns($dn) {
|
||||||
|
$dnEntries = ldapListDN($dn);
|
||||||
|
$dnList = array();
|
||||||
|
foreach ($dnEntries as $entry) {
|
||||||
|
$dnList[] = $entry['dn'];
|
||||||
|
}
|
||||||
|
usort($dnList, 'compareDN');
|
||||||
|
return $dnList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue