diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 01d14b06c..fa893a026 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -1748,8 +1748,8 @@ class moduleCache { /** * Returns a new/cached module with the given name and scope. * - * @param String $name module name - * @param String $scope module scope (e.g. user) + * @param string $name module name + * @param string|null $scope module scope (e.g. user) * @return null|baseModule module object */ public static function getModule($name, $scope): ?object { diff --git a/lam/templates/config/moduleSettings.php b/lam/templates/config/moduleSettings.php index 12fcc8fdf..93ac45345 100644 --- a/lam/templates/config/moduleSettings.php +++ b/lam/templates/config/moduleSettings.php @@ -3,17 +3,20 @@ namespace LAM\CONFIG; use htmlJavaScript; -use \moduleCache; -use \htmlSpacer; -use \htmlTable; -use \htmlButton; -use \htmlResponsiveRow; -use \htmlSubTitle; +use LAM\TYPES\TypeManager; +use LAMConfig; +use moduleCache; +use htmlSpacer; +use htmlTable; +use htmlButton; +use htmlResponsiveRow; +use htmlSubTitle; +use function LAM\TYPES\getTypes; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2009 - 2024 Roland Gruber + Copyright (C) 2009 - 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 @@ -70,6 +73,9 @@ if (isset($_POST['cancelSettings'])) { } $conf = &$_SESSION['conf_config']; +if (!($conf instanceof LAMConfig)) { + die(); +} $errorsToDisplay = checkInput(); @@ -105,8 +111,6 @@ if ((isset($_POST['saveSettings']) || isset($_POST['editmodules']) } } -$allTypes = \LAM\TYPES\getTypes(); - echo $_SESSION['header']; printHeaderContents(_("LDAP Account Manager Configuration"), '../..'); echo "
\n"; @@ -130,7 +134,7 @@ printConfigurationPageTabs(ConfigurationPageTab::MODULE_SETTINGS); // module settings -$typeManager = new \LAM\TYPES\TypeManager($conf); +$typeManager = new TypeManager($conf); $types = $typeManager->getConfiguredTypes(); // get list of scopes of modules @@ -156,19 +160,22 @@ for ($i = 0; $i < count($modules); $i++) { continue; } $module = moduleCache::getModule($modules[$i], null); + if ($module === null) { + continue; + } $iconImage = $module->getIcon(); if (($iconImage != null) && !(str_starts_with($iconImage, 'http')) && !(str_starts_with($iconImage, '/'))) { $iconImage = '../../graphics/' . $iconImage; } $row = new htmlResponsiveRow(); - $row->add(new htmlSubTitle(getModuleAlias($modules[$i], null), $iconImage, null, true), 12); + $row->add(new htmlSubTitle($module->get_alias(), $iconImage, null, true)); if (is_array($options[$modules[$i]])) { foreach ($options[$modules[$i]] as $option) { - $row->add($option, 12); + $row->add($option); } } else { - $row->add($options[$modules[$i]], 12); + $row->add($options[$modules[$i]]); } $configTypes = parseHtml($modules[$i], $row, $old_options, false, null); $_SESSION['conf_types'] = array_merge($configTypes, $_SESSION['conf_types']); @@ -210,7 +217,10 @@ function checkInput(): array { return []; } $conf = &$_SESSION['conf_config']; - $typeManager = new \LAM\TYPES\TypeManager($conf); + if (!($conf instanceof LAMConfig)) { + return []; + } + $typeManager = new TypeManager($conf); $types = $typeManager->getConfiguredTypes(); // check module options diff --git a/lam/templates/delete.php b/lam/templates/delete.php index 6405e1296..d4336ea7b 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -1,18 +1,23 @@ $value) { } } -$typeManager = new \LAM\TYPES\TypeManager(); +$typeManager = new TypeManager(); if (isset($_POST['type']) && ($typeManager->getConfiguredType($_POST['type']) === null)) { logNewMessage(LOG_ERR, 'Invalid type: ' . $_POST['type']); @@ -109,42 +114,45 @@ if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) { $users[] = substr($dn, $start, $end-$start); } - $sessionKey = $sessionAccountPrefix . (new \DateTime('now', getTimeZone()))->getTimestamp() . generateRandomText(); + $sessionKey = $sessionAccountPrefix . (new DateTime('now', getTimeZone()))->getTimestamp() . generateRandomText(); //load account - $_SESSION[$sessionKey] = new \accountContainer($type, $sessionKey); + $_SESSION[$sessionKey] = new accountContainer($type, $sessionKey); // Show HTML Page include __DIR__ . '/../lib/adminHeader.inc'; echo "