mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 09:49:16 +02:00
refactoring
This commit is contained in:
parent
364a41c7a6
commit
1934e89b53
5 changed files with 72 additions and 54 deletions
|
@ -476,16 +476,18 @@ function dryRun(): array {
|
||||||
// store LDIF
|
// store LDIF
|
||||||
$filename = 'ldif' . getRandomNumber() . '.ldif';
|
$filename = 'ldif' . getRandomNumber() . '.ldif';
|
||||||
$out = @fopen(dirname(__FILE__) . '/../../tmp/' . $filename, "wb");
|
$out = @fopen(dirname(__FILE__) . '/../../tmp/' . $filename, "wb");
|
||||||
fwrite($out, $ldif);
|
if ($out !== false) {
|
||||||
$container->addElement(new htmlOutputText(_('LDIF file')), true);
|
fwrite($out, $ldif);
|
||||||
$ldifLink = new htmlLink($filename, '../../tmp/' . $filename);
|
$container->addElement(new htmlOutputText(_('LDIF file')), true);
|
||||||
$ldifLink->setTargetWindow('_blank');
|
$ldifLink = new htmlLink($filename, '../../tmp/' . $filename);
|
||||||
$container->addElement($ldifLink, true);
|
$ldifLink->setTargetWindow('_blank');
|
||||||
$container->addVerticalSpace('20px');
|
$container->addElement($ldifLink, true);
|
||||||
$container->addElement(new htmlOutputText(_('Log output')), true);
|
$container->addVerticalSpace('20px');
|
||||||
$container->addElement(new htmlInputTextarea('log', $log, 100, 30), true);
|
$container->addElement(new htmlOutputText(_('Log output')), true);
|
||||||
// generate HTML
|
$container->addElement(new htmlInputTextarea('log', $log, 100, 30), true);
|
||||||
fclose ($out);
|
// generate HTML
|
||||||
|
fclose ($out);
|
||||||
|
}
|
||||||
ob_start();
|
ob_start();
|
||||||
$tabindex = 1;
|
$tabindex = 1;
|
||||||
parseHtml(null, $container, array(), true, $tabindex, 'user');
|
parseHtml(null, $container, array(), true, $tabindex, 'user');
|
||||||
|
@ -587,13 +589,16 @@ function doModify(): array {
|
||||||
* Returns the HTML code for a htmlStatusMessage
|
* Returns the HTML code for a htmlStatusMessage
|
||||||
*
|
*
|
||||||
* @param htmlStatusMessage $msg message
|
* @param htmlStatusMessage $msg message
|
||||||
* @return String HTML code
|
* @return string HTML code
|
||||||
*/
|
*/
|
||||||
function getMessageHTML($msg) {
|
function getMessageHTML(htmlStatusMessage $msg): string {
|
||||||
$tabindex = 0;
|
$tabindex = 0;
|
||||||
ob_start();
|
ob_start();
|
||||||
parseHtml(null, $msg, array(), true, $tabindex, 'user');
|
parseHtml(null, $msg, array(), true, $tabindex, 'user');
|
||||||
$content = ob_get_contents();
|
$content = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
if ($content === false) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use \htmlGroup;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||||
Copyright (C) 2003 - 2021 Roland Gruber
|
Copyright (C) 2003 - 2022 Roland Gruber
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -115,38 +115,43 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
|
||||||
elseif (isset($_POST['deleteOU'])) {
|
elseif (isset($_POST['deleteOU'])) {
|
||||||
// check for sub entries
|
// check for sub entries
|
||||||
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['deleteableOU'], "ObjectClass=*", array(""));
|
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['deleteableOU'], "ObjectClass=*", array(""));
|
||||||
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
if ($sr === false) {
|
||||||
if ($sr && ($info['count'] === 0)) {
|
$error = _("OU is not empty or invalid!");
|
||||||
// print header
|
|
||||||
include '../../lib/adminHeader.inc';
|
|
||||||
echo '<div class="smallPaddingContent">';
|
|
||||||
echo "<form action=\"ou_edit.php\" method=\"post\">\n";
|
|
||||||
$tabindex = 1;
|
|
||||||
$container = new htmlResponsiveRow();
|
|
||||||
$label = new htmlOutputText(_("Do you really want to delete this OU?"));
|
|
||||||
$label->colspan = 5;
|
|
||||||
$container->add($label, 12);
|
|
||||||
$container->addVerticalSpacer('1rem');
|
|
||||||
$dnLabel = new htmlOutputText(getAbstractDN($_POST['deleteableOU']));
|
|
||||||
$dnLabel->colspan = 5;
|
|
||||||
$container->add($dnLabel, 12);
|
|
||||||
$container->addVerticalSpacer('1rem');
|
|
||||||
$buttonGroup = new htmlGroup();
|
|
||||||
$buttonGroup->addElement(new htmlButton('sure', _("Delete")));
|
|
||||||
$buttonGroup->addElement(new htmlSpacer('0.5rem', null));
|
|
||||||
$buttonGroup->addElement(new htmlButton('abort', _("Cancel")));
|
|
||||||
$container->add($buttonGroup, 12);
|
|
||||||
$container->add(new htmlHiddenInput('deleteOU', 'submit'), 12);
|
|
||||||
$container->add(new htmlHiddenInput('deletename', $_POST['deleteableOU']), 12);
|
|
||||||
addSecurityTokenToMetaHTML($container);
|
|
||||||
parseHtml(null, $container, array(), false, $tabindex, 'user');
|
|
||||||
echo "</form>";
|
|
||||||
echo '</div>';
|
|
||||||
include '../../lib/adminFooter.inc';
|
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$error = _("OU is not empty or invalid!");
|
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||||
|
if (($info !== false) && ($info['count'] === 0)) {
|
||||||
|
// print header
|
||||||
|
include '../../lib/adminHeader.inc';
|
||||||
|
echo '<div class="smallPaddingContent">';
|
||||||
|
echo "<form action=\"ou_edit.php\" method=\"post\">\n";
|
||||||
|
$tabindex = 1;
|
||||||
|
$container = new htmlResponsiveRow();
|
||||||
|
$label = new htmlOutputText(_("Do you really want to delete this OU?"));
|
||||||
|
$label->colspan = 5;
|
||||||
|
$container->add($label, 12);
|
||||||
|
$container->addVerticalSpacer('1rem');
|
||||||
|
$dnLabel = new htmlOutputText(getAbstractDN($_POST['deleteableOU']));
|
||||||
|
$dnLabel->colspan = 5;
|
||||||
|
$container->add($dnLabel, 12);
|
||||||
|
$container->addVerticalSpacer('1rem');
|
||||||
|
$buttonGroup = new htmlGroup();
|
||||||
|
$buttonGroup->addElement(new htmlButton('sure', _("Delete")));
|
||||||
|
$buttonGroup->addElement(new htmlSpacer('0.5rem', null));
|
||||||
|
$buttonGroup->addElement(new htmlButton('abort', _("Cancel")));
|
||||||
|
$container->add($buttonGroup, 12);
|
||||||
|
$container->add(new htmlHiddenInput('deleteOU', 'submit'), 12);
|
||||||
|
$container->add(new htmlHiddenInput('deletename', $_POST['deleteableOU']), 12);
|
||||||
|
addSecurityTokenToMetaHTML($container);
|
||||||
|
parseHtml(null, $container, array(), false, $tabindex, 'user');
|
||||||
|
echo "</form>";
|
||||||
|
echo '</div>';
|
||||||
|
include '../../lib/adminFooter.inc';
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$error = _("OU is not empty or invalid!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,11 +75,13 @@ function showTree(): void {
|
||||||
if ((strlen($initialDn) > strlen($rootDn)) && substr($initialDn, -1 * strlen($rootDn)) === $rootDn) {
|
if ((strlen($initialDn) > strlen($rootDn)) && substr($initialDn, -1 * strlen($rootDn)) === $rootDn) {
|
||||||
$extraDnPart = substr($initialDn, 0, (-1 * strlen($rootDn)) - 1);
|
$extraDnPart = substr($initialDn, 0, (-1 * strlen($rootDn)) - 1);
|
||||||
$dnParts = ldap_explode_dn($extraDnPart, 0);
|
$dnParts = ldap_explode_dn($extraDnPart, 0);
|
||||||
unset($dnParts['count']);
|
if ($dnParts !== false) {
|
||||||
$dnPartsCount = sizeof($dnParts);
|
unset($dnParts['count']);
|
||||||
for ($i = 0; $i < $dnPartsCount; $i++) {
|
$dnPartsCount = sizeof($dnParts);
|
||||||
$currentParts = array_slice($dnParts, $dnPartsCount - ($i + 1));
|
for ($i = 0; $i < $dnPartsCount; $i++) {
|
||||||
$openInitial[] = '"' . base64_encode(implode(',', $currentParts) . ',' . $rootDn) . '"';
|
$currentParts = array_slice($dnParts, $dnPartsCount - ($i + 1));
|
||||||
|
$openInitial[] = '"' . base64_encode(implode(',', $currentParts) . ',' . $rootDn) . '"';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,13 +126,16 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
|
||||||
$uploadColumns = getUploadColumns($type, $selectedModules);
|
$uploadColumns = getUploadColumns($type, $selectedModules);
|
||||||
// read input file
|
// read input file
|
||||||
$handle = fopen ($_FILES['inputfile']['tmp_name'], "r");
|
$handle = fopen ($_FILES['inputfile']['tmp_name'], "r");
|
||||||
if (($head = fgetcsv($handle, 2000)) !== false ) { // head row
|
if ($handle !== false) {
|
||||||
foreach ($head as $i => $headItem) {
|
if (($head = fgetcsv($handle, 2000)) !== false ) { // head row
|
||||||
$ids[$headItem] = $i;
|
foreach ($head as $i => $headItem) {
|
||||||
|
$ids[$headItem] = $i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
while (($line = fgetcsv($handle, 2000)) !== false ) { // account rows
|
||||||
while (($line = fgetcsv($handle, 2000)) !== false ) { // account rows
|
$data[] = $line;
|
||||||
$data[] = $line;
|
}
|
||||||
|
fclose($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
|
@ -28,3 +28,6 @@ parameters:
|
||||||
- '#Cannot assign new offset to array<int, string>\|string.#'
|
- '#Cannot assign new offset to array<int, string>\|string.#'
|
||||||
- '#Parameter \#1 \$result of function ldap_free_result expects LDAP\\Result, array\|LDAP\\Result given.#'
|
- '#Parameter \#1 \$result of function ldap_free_result expects LDAP\\Result, array\|LDAP\\Result given.#'
|
||||||
- '#Cannot access offset .* on array\|int.#'
|
- '#Cannot access offset .* on array\|int.#'
|
||||||
|
- '#Parameter \#1 \$haystack of function strpos expects string, int\|string given.#'
|
||||||
|
- '#Argument of an invalid type array\|int supplied for foreach, only iterables are supported.#'
|
||||||
|
- '#Cannot access offset mixed on non-empty-array\|int.#'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue