go back in DN selection
This commit is contained in:
parent
d0388973e5
commit
f0cbe217eb
|
@ -1043,18 +1043,15 @@ window.lam.html.showDnSelection = function(fieldId, title, okText, cancelText, t
|
|||
})
|
||||
.done(function(jsonData) {
|
||||
jQuery('#dlg_' + fieldId).html(jsonData.dialogData);
|
||||
})
|
||||
.fail(function() {
|
||||
jQuery(this).dialog("close");
|
||||
});
|
||||
var buttonList = {};
|
||||
buttonList[cancelText] = function() { jQuery(this).dialog("close"); };
|
||||
jQuery('#dlg_' + fieldId).dialog({
|
||||
modal: true,
|
||||
title: title,
|
||||
dialogClass: 'defaultBackground',
|
||||
buttons: buttonList,
|
||||
width: 'auto'
|
||||
var buttonList = {};
|
||||
buttonList[cancelText] = function() { jQuery(this).dialog("close"); };
|
||||
jQuery('#dlg_' + fieldId).dialog({
|
||||
modal: true,
|
||||
title: title,
|
||||
dialogClass: 'defaultBackground',
|
||||
buttons: buttonList,
|
||||
width: 'auto'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1073,6 +1070,39 @@ window.lam.html.selectDn = function(el, fieldId) {
|
|||
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() {
|
||||
window.lam.gui.equalHeight();
|
||||
window.lam.form.autoTrim();
|
||||
|
|
|
@ -4,8 +4,7 @@ use \LAM\TOOLS\IMPORT_EXPORT\Importer;
|
|||
use \LAM\TOOLS\IMPORT_EXPORT\Exporter;
|
||||
use \LAM\TYPES\TypeManager;
|
||||
use \htmlResponsiveRow;
|
||||
use \htmlDiv;
|
||||
use \htmlGroup;
|
||||
use \htmlLink;
|
||||
use \htmlOutputText;
|
||||
use \htmlButton;
|
||||
/*
|
||||
|
@ -181,9 +180,12 @@ class Ajax {
|
|||
$dn = trim($_POST['dn']);
|
||||
if (empty($dn) || !get_preg($dn, 'dn')) {
|
||||
$dnList = $this->getDefaultDns();
|
||||
$dn = null;
|
||||
}
|
||||
$dnList = $this->getDefaultDns(); // TODO remove
|
||||
$html = $this->buildDnSelectionHtml($dnList);
|
||||
else {
|
||||
$dnList = $this->getSubDns($dn);
|
||||
}
|
||||
$html = $this->buildDnSelectionHtml($dnList, $dn);
|
||||
return json_encode(array('dialogData' => $html));
|
||||
}
|
||||
|
||||
|
@ -206,7 +208,7 @@ class Ajax {
|
|||
$baseDnList[] = $suffix;
|
||||
}
|
||||
$baseDnList = array_unique($baseDnList);
|
||||
sort($baseDnList);
|
||||
usort($baseDnList, 'compareDN');
|
||||
return $baseDnList;
|
||||
}
|
||||
|
||||
|
@ -214,14 +216,49 @@ class Ajax {
|
|||
* Returns the HTML to build the DN selection list.
|
||||
*
|
||||
* @param string[] $dnList DN list
|
||||
* @param string $currentDn current DN
|
||||
*/
|
||||
private function buildDnSelectionHtml($dnList) {
|
||||
private function buildDnSelectionHtml($dnList, $currentDn) {
|
||||
$fieldId = trim($_POST['fieldId']);
|
||||
$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) {
|
||||
$row = new htmlResponsiveRow();
|
||||
$row->addDataAttribute('dn', $dn);
|
||||
$row->add(new htmlOutputText($dn), 12, 9);
|
||||
$row->setCSSClasses(array('text-right'));
|
||||
$buttonId = base64_encode($dn);
|
||||
$buttonId = str_replace('=', '', $buttonId);
|
||||
$button = new htmlButton($buttonId, _('Ok'));
|
||||
|
@ -238,6 +275,22 @@ class Ajax {
|
|||
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