refactoring

This commit is contained in:
Roland Gruber 2022-09-09 08:02:32 +02:00
parent 364a41c7a6
commit 1934e89b53
5 changed files with 72 additions and 54 deletions

View file

@ -476,6 +476,7 @@ 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");
if ($out !== false) {
fwrite($out, $ldif); fwrite($out, $ldif);
$container->addElement(new htmlOutputText(_('LDIF file')), true); $container->addElement(new htmlOutputText(_('LDIF file')), true);
$ldifLink = new htmlLink($filename, '../../tmp/' . $filename); $ldifLink = new htmlLink($filename, '../../tmp/' . $filename);
@ -486,6 +487,7 @@ function dryRun(): array {
$container->addElement(new htmlInputTextarea('log', $log, 100, 30), true); $container->addElement(new htmlInputTextarea('log', $log, 100, 30), true);
// generate HTML // generate HTML
fclose ($out); 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;
} }

View file

@ -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,8 +115,12 @@ 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(""));
if ($sr === false) {
$error = _("OU is not empty or invalid!");
}
else {
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr); $info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
if ($sr && ($info['count'] === 0)) { if (($info !== false) && ($info['count'] === 0)) {
// print header // print header
include '../../lib/adminHeader.inc'; include '../../lib/adminHeader.inc';
echo '<div class="smallPaddingContent">'; echo '<div class="smallPaddingContent">';
@ -150,6 +154,7 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
} }
} }
} }
}
display_main($message, $error); display_main($message, $error);

View file

@ -75,6 +75,7 @@ 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);
if ($dnParts !== false) {
unset($dnParts['count']); unset($dnParts['count']);
$dnPartsCount = sizeof($dnParts); $dnPartsCount = sizeof($dnParts);
for ($i = 0; $i < $dnPartsCount; $i++) { for ($i = 0; $i < $dnPartsCount; $i++) {
@ -84,6 +85,7 @@ function showTree(): void {
} }
} }
} }
}
$openInitialJsArray = '[' . implode(', ', $openInitial) . ']'; $openInitialJsArray = '[' . implode(', ', $openInitial) . ']';
$row = new htmlResponsiveRow(); $row = new htmlResponsiveRow();
$row->setCSSClasses(array('maxrow')); $row->setCSSClasses(array('maxrow'));

View file

@ -126,6 +126,7 @@ 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 ($handle !== false) {
if (($head = fgetcsv($handle, 2000)) !== false ) { // head row if (($head = fgetcsv($handle, 2000)) !== false ) { // head row
foreach ($head as $i => $headItem) { foreach ($head as $i => $headItem) {
$ids[$headItem] = $i; $ids[$headItem] = $i;
@ -134,6 +135,8 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
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();

View file

@ -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.#'