refactoring

This commit is contained in:
Roland Gruber 2025-07-15 17:54:48 +02:00
parent 5fcf2bb7a1
commit d0cdf7fa94
6 changed files with 20 additions and 17 deletions

View file

@ -3338,12 +3338,11 @@ class htmlDiv extends htmlElement {
/**
* Constructor.
*
* @param String $id unique ID
* @param string|null $id unique ID
* @param htmlElement $content inner content
* @param array $classes CSS classes
* @param string[] $cssClasses CSS classes
* @param string[]|null $cssClasses CSS classes
*/
function __construct($id, $content, $cssClasses = null) {
function __construct(?string $id, htmlElement $content, ?array $cssClasses = null) {
if ($id !== null) {
$this->id = htmlspecialchars($id);
}

View file

@ -281,10 +281,10 @@ function check_module_conflicts($selected, $deps) {
* Returns an array with all available user module names
*
* @param string $scope account type (user, group, host)
* @param boolean $mustSupportAdminInterface module must support LAM admin interface (default: false)
* @return array list of possible modules
* @param bool $mustSupportAdminInterface module must support LAM admin interface (default: false)
* @return string[] list of possible modules
*/
function getAvailableModules($scope, $mustSupportAdminInterface = false) {
function getAvailableModules($scope, bool $mustSupportAdminInterface = false): array {
$dirname = substr(__FILE__, 0, strlen(__FILE__) - 12) . "/modules";
$dir = dir($dirname);
$return = [];

View file

@ -661,7 +661,7 @@ function validateSecurityToken() {
*
* @param htmlTable|htmlGroup|htmlResponsiveRow $container table
*/
function addSecurityTokenToMetaHTML(&$container) {
function addSecurityTokenToMetaHTML($container) {
$token = new htmlHiddenInput(getSecurityTokenName(), $_SESSION[getSecurityTokenName()]);
if ($container instanceof htmlResponsiveRow) {
$container->add($token);

View file

@ -125,7 +125,7 @@ function getSelfServiceOptions($scope, $fields, $attributes, $passwordChangeOnly
* Checks if all input values are correct and returns the LDAP commands which should be executed.
*
* @param string $scope account type
* @param string $fields input fields (array(<moduleName> => array(<field1>, <field2>, ...)))
* @param array $fields input fields (array(<moduleName> => array(<field1>, <field2>, ...)))
* @param array $attributes LDAP attributes
* @param boolean $passwordChangeOnly indicates that the user is only allowed to change his password and no LDAP content is readable
* @param array $readOnlyFields list of read-only fields

View file

@ -11,7 +11,7 @@ use function \LAM\SCHEMA\get_cached_schema;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2007 - 2023 Roland Gruber
Copyright (C) 2007 - 2025 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
@ -76,10 +76,10 @@ else {
$typeManager = new \LAM\TYPES\TypeManager();
$types = $typeManager->getConfiguredTypes();
foreach ($types as $type) {
$modules = $_SESSION['config']->get_AccountModules($type->getId());
$moduleNames = $_SESSION['config']->get_AccountModules($type->getId());
$container->add(new htmlSubTitle($type->getAlias()), 12);
for ($m = 0; $m < count($modules); $m++) {
$error = checkSchemaForModule($modules[$m], $type->getScope(), $type->getId());
foreach ($moduleNames as $moduleName) {
$error = checkSchemaForModule($moduleName, $type->getScope(), $type->getId());
$message = _("No problems found.");
$icon = '../../graphics/pass.svg';
if ($error != null) {
@ -87,7 +87,8 @@ else {
$message = $error;
}
// module name
$container->add(new htmlOutputText(getModuleAlias($modules[$m], $type->getScope())), 10, 3);
$aliasName = getModuleAlias($moduleName, $type->getScope()) ?? '';
$container->add(new htmlOutputText($aliasName), 10, 3);
// icon
$container->add(new htmlImage($icon), 2);
// text

View file

@ -160,7 +160,7 @@ function printImportTabContent(): void {
$container->add($sourceRadio, 12);
$container->addVerticalSpacer('1rem');
$container->add(new htmlResponsiveInputFileUpload('file', _('File'), '750'), 12);
$container->add(new htmlResponsiveInputTextarea('text', '', '60', '20', _('LDIF data'), '750'), 12);
$container->add(new htmlResponsiveInputTextarea('text', '', 60, 20, _('LDIF data'), '750'), 12);
$container->add(new htmlResponsiveInputCheckbox('noStop', false, _('Don\'t stop on errors')), 12);
$container->addVerticalSpacer('3rem');
@ -200,7 +200,7 @@ function printImportTabProcessing(): void {
$button = new htmlButton('submitImportCancel', _('Cancel'));
$container->add($button, 12, 12, 12, 'text-center');
$newImportButton = new htmlLink(_('New import'), null);
$newImportButton = new htmlLink(_('New import'), '');
$container->add($newImportButton, 12, 12, 12, 'text-center hidden newimport');
$container->addVerticalSpacer('3rem');
@ -241,6 +241,9 @@ function checkImportData(): void {
throw new LAMException(_('You must either upload a file or provide an import in the text box.'));
}
$lines = preg_split("/\n|\r\n|\r/", $ldif);
if ($lines === false) {
throw new LAMException(_('You must either upload a file or provide an import in the text box.'));
}
$importer = new Importer();
$tasks = $importer->getTasks($lines);
$_SESSION[Importer::SESSION_KEY_TASKS] = $tasks;
@ -395,7 +398,7 @@ function printExportTabProcessing(): void {
$button = new htmlButton('submitExportCancel', _('Cancel'));
$container->add($button, 12, 12, 12, 'text-center');
$newExportButton = new htmlLink(_('New export'), null);
$newExportButton = new htmlLink(_('New export'), '');
$container->add($newExportButton, 12, 12, 12, 'text-center hidden newexport');
$container->addVerticalSpacer('3rem');