refactoring

This commit is contained in:
Roland Gruber 2022-04-27 08:05:19 +02:00
parent 72b99d2f3f
commit a567ab0e7e
5 changed files with 26 additions and 28 deletions

View file

@ -11,7 +11,7 @@ use htmlStatusMessage;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2020 - 2021 Roland Gruber
Copyright (C) 2020 - 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

View file

@ -11,7 +11,7 @@ use \htmlStatusMessage;
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz
Copyright (C) 2007 - 2021 Roland Gruber
Copyright (C) 2007 - 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
@ -207,26 +207,24 @@ if (isset($_POST['delete'])) {
$attributes = array();
$errors = array();
// predelete actions
if (!$stopprocessing) {
foreach ($moduleNames as $singlemodule) {
$success = true;
$messages = $modules[$singlemodule]->preDeleteActions();
foreach ($messages as $message) {
$errors[] = $message;
if ($message[0] == 'ERROR') {
$success = false;
$allOk = false;
}
elseif ($message[0] == 'WARN') {
$allOk = false;
}
}
if (!$success) {
$stopprocessing = true;
break;
}
}
}
foreach ($moduleNames as $singlemodule) {
$success = true;
$messages = $modules[$singlemodule]->preDeleteActions();
foreach ($messages as $message) {
$errors[] = $message;
if ($message[0] == 'ERROR') {
$success = false;
$allOk = false;
}
elseif ($message[0] == 'WARN') {
$allOk = false;
}
}
if (!$success) {
$stopprocessing = true;
break;
}
}
if (!$stopprocessing) {
// load attributes
foreach ($moduleNames as $singlemodule) {
@ -260,7 +258,7 @@ if (isset($_POST['delete'])) {
}
if (!$stopprocessing) {
// modify attributes
if (isset($attributes[$dn]['modify']) && !$stopprocessing) {
if (isset($attributes[$dn]['modify'])) {
$success = ldap_mod_replace($_SESSION['ldap']->server(), $dn, $attributes[$dn]['modify']);
if (!$success) {
$errors[] = array ('ERROR', sprintf(_('Was unable to modify attributes from DN: %s.'), $dn), getDefaultLDAPErrorString($_SESSION['ldap']->server()));

View file

@ -294,7 +294,7 @@ function displayAttributeList(htmlResponsiveRow $row) {
if (isset($_GET['sel']) && (empty($_GET['sel']) || array_key_exists(strtolower($_GET['sel']), $attributes))) {
$selectedAttribute[0] = $_GET['sel'];
}
if (empty($selectedAttribute) && (sizeof($availableAttributes) > 0)) {
if (empty($selectedAttribute) && (sizeof($availableAttributes) > 1)) {
// select first attribute by default
$attributeNames = array_keys($availableAttributes);
$selectedAttribute[0] = $attributeNames[1];

View file

@ -156,10 +156,10 @@ display_main($message, $error);
/**
* Displays the main page of the OU editor
*
* @param String $message info message
* @param String $error error message
* @param string|null $message info message
* @param string|null $error error message
*/
function display_main($message, $error) {
function display_main(?string $message, ?string $error): void {
// display main page
include __DIR__ . '/../../lib/adminHeader.inc';
echo '<div class="smallPaddingContent">';

View file

@ -1,5 +1,5 @@
parameters:
level: 3
level: 4
scanDirectories:
- lam/lib
- lam/templates