mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 01:39:33 +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
|
||||
$filename = 'ldif' . getRandomNumber() . '.ldif';
|
||||
$out = @fopen(dirname(__FILE__) . '/../../tmp/' . $filename, "wb");
|
||||
fwrite($out, $ldif);
|
||||
$container->addElement(new htmlOutputText(_('LDIF file')), true);
|
||||
$ldifLink = new htmlLink($filename, '../../tmp/' . $filename);
|
||||
$ldifLink->setTargetWindow('_blank');
|
||||
$container->addElement($ldifLink, true);
|
||||
$container->addVerticalSpace('20px');
|
||||
$container->addElement(new htmlOutputText(_('Log output')), true);
|
||||
$container->addElement(new htmlInputTextarea('log', $log, 100, 30), true);
|
||||
// generate HTML
|
||||
fclose ($out);
|
||||
if ($out !== false) {
|
||||
fwrite($out, $ldif);
|
||||
$container->addElement(new htmlOutputText(_('LDIF file')), true);
|
||||
$ldifLink = new htmlLink($filename, '../../tmp/' . $filename);
|
||||
$ldifLink->setTargetWindow('_blank');
|
||||
$container->addElement($ldifLink, true);
|
||||
$container->addVerticalSpace('20px');
|
||||
$container->addElement(new htmlOutputText(_('Log output')), true);
|
||||
$container->addElement(new htmlInputTextarea('log', $log, 100, 30), true);
|
||||
// generate HTML
|
||||
fclose ($out);
|
||||
}
|
||||
ob_start();
|
||||
$tabindex = 1;
|
||||
parseHtml(null, $container, array(), true, $tabindex, 'user');
|
||||
|
@ -587,13 +589,16 @@ function doModify(): array {
|
|||
* Returns the HTML code for a htmlStatusMessage
|
||||
*
|
||||
* @param htmlStatusMessage $msg message
|
||||
* @return String HTML code
|
||||
* @return string HTML code
|
||||
*/
|
||||
function getMessageHTML($msg) {
|
||||
function getMessageHTML(htmlStatusMessage $msg): string {
|
||||
$tabindex = 0;
|
||||
ob_start();
|
||||
parseHtml(null, $msg, array(), true, $tabindex, 'user');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
if ($content === false) {
|
||||
return '';
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use \htmlGroup;
|
|||
/*
|
||||
|
||||
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
|
||||
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'])) {
|
||||
// check for sub entries
|
||||
$sr = ldap_list($_SESSION['ldap']->server(), $_POST['deleteableOU'], "ObjectClass=*", array(""));
|
||||
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||
if ($sr && ($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();
|
||||
if ($sr === false) {
|
||||
$error = _("OU is not empty or invalid!");
|
||||
}
|
||||
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) {
|
||||
$extraDnPart = substr($initialDn, 0, (-1 * strlen($rootDn)) - 1);
|
||||
$dnParts = ldap_explode_dn($extraDnPart, 0);
|
||||
unset($dnParts['count']);
|
||||
$dnPartsCount = sizeof($dnParts);
|
||||
for ($i = 0; $i < $dnPartsCount; $i++) {
|
||||
$currentParts = array_slice($dnParts, $dnPartsCount - ($i + 1));
|
||||
$openInitial[] = '"' . base64_encode(implode(',', $currentParts) . ',' . $rootDn) . '"';
|
||||
if ($dnParts !== false) {
|
||||
unset($dnParts['count']);
|
||||
$dnPartsCount = sizeof($dnParts);
|
||||
for ($i = 0; $i < $dnPartsCount; $i++) {
|
||||
$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);
|
||||
// read input file
|
||||
$handle = fopen ($_FILES['inputfile']['tmp_name'], "r");
|
||||
if (($head = fgetcsv($handle, 2000)) !== false ) { // head row
|
||||
foreach ($head as $i => $headItem) {
|
||||
$ids[$headItem] = $i;
|
||||
if ($handle !== false) {
|
||||
if (($head = fgetcsv($handle, 2000)) !== false ) { // head row
|
||||
foreach ($head as $i => $headItem) {
|
||||
$ids[$headItem] = $i;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (($line = fgetcsv($handle, 2000)) !== false ) { // account rows
|
||||
$data[] = $line;
|
||||
while (($line = fgetcsv($handle, 2000)) !== false ) { // account rows
|
||||
$data[] = $line;
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
|
|
|
@ -28,3 +28,6 @@ parameters:
|
|||
- '#Cannot assign new offset to array<int, string>\|string.#'
|
||||
- '#Parameter \#1 \$result of function ldap_free_result expects LDAP\\Result, array\|LDAP\\Result given.#'
|
||||
- '#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