From 7e132310045db2c9d562c3d29bd7dec036682137 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 29 Oct 2023 20:49:41 +0100 Subject: [PATCH] refactoring --- lam/templates/pdfedit/pdfmain.php | 85 +++++++++++++------------- lam/templates/pdfedit/pdfpage.php | 74 +++++++++++----------- lam/templates/profedit/profilemain.php | 53 ++++++++-------- lam/templates/profedit/profilepage.php | 36 +++++------ lam/templates/tests/index.php | 4 +- lam/templates/tests/lamdaemonTest.php | 20 +++--- lam/templates/tests/schemaTest.php | 10 +-- 7 files changed, 142 insertions(+), 140 deletions(-) diff --git a/lam/templates/pdfedit/pdfmain.php b/lam/templates/pdfedit/pdfmain.php index f9a3c557e..d2f6b173e 100644 --- a/lam/templates/pdfedit/pdfmain.php +++ b/lam/templates/pdfedit/pdfmain.php @@ -103,7 +103,7 @@ $typeManager = new TypeManager(); $types = $typeManager->getConfiguredTypes(); -$sortedTypes = array(); +$sortedTypes = []; foreach ($types as $type) { if ($type->isHidden() || !checkIfWriteAccessIsAllowed($type->getId())) { continue; @@ -169,8 +169,8 @@ } $serverProfilePersistenceManager = new ServerProfilePersistenceManager(); -$serverProfiles = array(); -$configProfiles = array(); +$serverProfiles = []; +$configProfiles = []; try { $configProfiles = $serverProfilePersistenceManager->getProfiles(); foreach ($configProfiles as $profileName) { @@ -190,10 +190,10 @@ $errMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!')); } elseif (!empty($_POST['importProfiles_' . $typeId])) { - $options = array(); + $options = []; foreach ($_POST['importProfiles_' . $typeId] as $importProfiles) { $parts = explode('##', $importProfiles); - $options[] = array('conf' => $parts[0], 'typeId' => $parts[1], 'name' => $parts[2]); + $options[] = ['conf' => $parts[0], 'typeId' => $parts[1], 'name' => $parts[2]]; } $errMessage = importStructures($_POST['typeId'], $options, $serverProfiles, $typeManager); } @@ -212,10 +212,10 @@ $errMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!')); } elseif (!empty($_POST['exportProfiles_' . $typeId])) { - $options = array(); + $options = []; foreach ($_POST['exportProfiles_' . $typeId] as $importProfiles) { $parts = explode('##', $importProfiles); - $options[] = array('conf' => $parts[0], 'typeId' => $parts[1]); + $options[] = ['conf' => $parts[0], 'typeId' => $parts[1]]; } $typeId = $_POST['typeId']; $name = $_POST['name_' . $typeId]; @@ -234,7 +234,7 @@ if ($handle === false) { throw new LAMException(_('Unable to create temporary file.')); } - $data = fread($handle, 100000000); + $data = fread($handle, 100_000_000); if ($data === false) { throw new LAMException(_('Unable to create temporary file.')); } @@ -313,16 +313,17 @@ } // get list of account types -$availableTypes = array(); -$templateClasses = array(); +$availableTypes = []; +$templateClasses = []; foreach ($sortedTypes as $typeId => $title) { $type = $typeManager->getConfiguredType($typeId); - $templateClasses[] = array( + $templateClasses[] = [ 'typeId' => $type->getId(), 'scope' => $type->getScope(), 'title' => $title, 'icon' => $type->getIcon(), - 'templates' => $pdfStructurePersistenceManager->getPDFStructures($_SESSION['config']->getName(), $type->getId())); + 'templates' => $pdfStructurePersistenceManager->getPDFStructures($_SESSION['config']->getName(), $type->getId()) + ]; $availableTypes[$title] = $type->getId(); } // check if a template should be edited @@ -356,7 +357,7 @@ $newProfileSelect->setHasDescriptiveElements(true); $container->addLabel($newProfileSelect); $createButton = new htmlButton('createNewTemplate', _('Create')); - $createButton->setCSSClasses(array('lam-primary')); + $createButton->setCSSClasses(['lam-primary']); $container->addField($createButton); $container->addVerticalSpacer('2rem'); } @@ -380,7 +381,7 @@ $deleteLink->setOnClick("profileShowDeleteDialog('" . _('Delete') . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . $templateClass['typeId'] . "', '" . 'template_' . $templateClass['typeId'] . "'); return false;"); - $deleteLink->setCSSClasses(array('margin3')); + $deleteLink->setCSSClasses(['margin3']); $buttonGroup->addElement($deleteLink); if (count($configProfiles) > 1) { @@ -389,7 +390,7 @@ $importLink->setOnClick("window.lam.profilePdfEditor.showDistributionDialog('" . _("Import PDF structures") . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . $templateClass['typeId'] . "', 'import'); return false;"); - $importLink->setCSSClasses(array('margin3')); + $importLink->setCSSClasses(['margin3']); $buttonGroup->addElement($importLink); } $exportLink = new htmlLink(null, '#', '../../graphics/export.svg'); @@ -398,7 +399,7 @@ _('Ok') . "', '" . _('Cancel') . "', '" . $templateClass['typeId'] . "', 'export', '" . 'template_' . $templateClass['typeId'] . "', '" . $_SESSION['config']->getName() . "'); return false;"); - $exportLink->setCSSClasses(array('margin3')); + $exportLink->setCSSClasses(['margin3']); $buttonGroup->addElement($exportLink); $container->add($buttonGroup, 12, 4); $container->addVerticalSpacer('1rem'); @@ -407,7 +408,7 @@ // manage logos $container->addVerticalSpacer('4rem'); $container->add(new htmlSubTitle(_('Manage logos')), 12); - $logoOptions = array(); + $logoOptions = []; try { $logos = $pdfStructurePersistenceManager->getPdfLogos($_SESSION['config']->getName(), true); foreach ($logos as $logo) { @@ -429,31 +430,31 @@ $importLogoLink->setTitle(_('Import logo')); $importLogoLink->setOnClick("window.lam.profilePdfEditor.showPdfLogoImportDialog('" . _("Import logo") . "', '" . _('Ok') . "', '" . _('Cancel') . "'); return false;"); - $importLogoLink->setCSSClasses(array('margin3')); + $importLogoLink->setCSSClasses(['margin3']); $logoButtonGroup->addElement($importLogoLink); $exportLogoLink = new htmlLink(null, '#', '../../graphics/export.svg'); $exportLogoLink->setTitle(_('Export logo')); $exportLogoLink->setOnClick("window.lam.profilePdfEditor.showPdfLogoExportDialog('" . _("Export logo") . "', '" . _('Ok') . "', '" . _('Cancel') . "'); return false;"); - $exportLogoLink->setCSSClasses(array('margin3')); + $exportLogoLink->setCSSClasses(['margin3']); $logoButtonGroup->addElement($exportLogoLink); $container->addField($logoButtonGroup); $container->addVerticalSpacer('2rem'); $container->addLabel(new htmlInputFileUpload('logoUpload')); $logoUpload = new htmlButton('uploadLogo', _('Upload')); - $logoUpload->setCSSClasses(array('lam-secondary')); + $logoUpload->setCSSClasses(['lam-secondary']); $container->addField($logoUpload); $container->addVerticalSpacer('4rem'); // generate content - parseHtml(null, $container, array(), false, 'user'); + parseHtml(null, $container, [], false, 'user'); echo "\n"; // export logo form $container = new htmlResponsiveRow(); $logoExportFormContent = new htmlResponsiveRow(); - $exportOptions = array(); + $exportOptions = []; foreach ($configProfiles as $profile) { if ($profile != $_SESSION['config']->getName()) { $exportOptions[$profile] = $profile; @@ -461,7 +462,7 @@ } asort($exportOptions); $exportOptions['*' . _('Global templates')] = 'templates*'; - $logoExportConfigSelect = new htmlResponsiveSelect('exportLogoTargetProfile', $exportOptions, array(), _('Target server profile'), null, 5); + $logoExportConfigSelect = new htmlResponsiveSelect('exportLogoTargetProfile', $exportOptions, [], _('Target server profile'), null, 5); $logoExportConfigSelect->setHasDescriptiveElements(true); $logoExportConfigSelect->setSortElements(false); $logoExportConfigSelect->setMultiSelect(true); @@ -474,14 +475,14 @@ $logoExportFormContent->add($logoExportFormPwd, 12); addSecurityTokenToMetaHTML($logoExportFormContent); $logoExportForm = new htmlForm('logoExportForm', 'pdfmain.php', $logoExportFormContent); - $logoExportDialog = new htmlDiv('logoExportDiv', $logoExportForm, array('hidden')); + $logoExportDialog = new htmlDiv('logoExportDiv', $logoExportForm, ['hidden']); $container->add($logoExportDialog, 12); - parseHtml(null, $container, array(), false, 'user'); + parseHtml(null, $container, [], false, 'user'); // import logo form $container = new htmlResponsiveRow(); $logoImportFormContent = new htmlResponsiveRow(); - $importOptions = array(); + $importOptions = []; foreach ($configProfiles as $profileName) { if ($profileName != $_SESSION['config']->getName()) { $availableLogos = $pdfStructurePersistenceManager->getPdfLogos($profileName); @@ -491,7 +492,7 @@ } } } - $logoImportConfigSelect = new htmlResponsiveSelect('importLogoSourceProfile', $importOptions, array(), _('PDF structures'), null, 5); + $logoImportConfigSelect = new htmlResponsiveSelect('importLogoSourceProfile', $importOptions, [], _('PDF structures'), null, 5); $logoImportConfigSelect->setHasDescriptiveElements(true); $logoImportConfigSelect->setContainsOptgroups(true); $logoImportConfigSelect->setMultiSelect(true); @@ -503,14 +504,14 @@ $logoImportFormContent->add($logoImportFormPwd, 12); addSecurityTokenToMetaHTML($logoImportFormContent); $logoImportForm = new htmlForm('logoImportForm', 'pdfmain.php', $logoImportFormContent); - $logoImportDialog = new htmlDiv('logoImportDiv', $logoImportForm, array('hidden')); + $logoImportDialog = new htmlDiv('logoImportDiv', $logoImportForm, ['hidden']); $container->add($logoImportDialog, 12); - parseHtml(null, $container, array(), false, 'user'); + parseHtml(null, $container, [], false, 'user'); foreach ($templateClasses as $templateClass) { $typeId = $templateClass['typeId']; $scope = $templateClass['scope']; - $importOptions = array(); + $importOptions = []; foreach ($configProfiles as $profile) { $typeManagerImport = new TypeManager($serverProfiles[$profile]); $typesImport = $typeManagerImport->getConfiguredTypesForScope($scope); @@ -531,7 +532,7 @@ $containerStructures = new htmlResponsiveRow(); $containerStructures->add(new htmlOutputText(_('PDF structures')), 12); - $select = new htmlSelect('importProfiles_' . $typeId, $importOptions, array(), count($importOptions, 1) < 15 ? count($importOptions, 1) : 15); + $select = new htmlSelect('importProfiles_' . $typeId, $importOptions, [], count($importOptions, 1) < 15 ? count($importOptions, 1) : 15); $select->setMultiSelect(true); $select->setHasDescriptiveElements(true); $select->setContainsOptgroups(true); @@ -550,7 +551,7 @@ $containerStructures->add(new htmlHiddenInput('typeId', $typeId), 12); addSecurityTokenToMetaHTML($containerStructures); - parseHtml(null, $containerStructures, array(), false, 'user'); + parseHtml(null, $containerStructures, [], false, 'user'); echo ''; echo "\n"; @@ -562,7 +563,7 @@ $containerTarget = new htmlResponsiveRow(); $containerTarget->add(new htmlOutputText(_("Target server profile")), 12); - $exportOptions = array(); + $exportOptions = []; foreach ($configProfiles as $profile) { $typeManagerExport = new TypeManager($serverProfiles[$profile]); $typesExport = $typeManagerExport->getConfiguredTypesForScope($scope); @@ -575,7 +576,7 @@ $exportOptions['*' . _('Global templates')][_('Global templates')] = 'templates*##'; $exportSize = count($exportOptions) < 10 ? count($exportOptions, 1) : 10; - $select = new htmlSelect('exportProfiles_' . $typeId, $exportOptions, array(), $exportSize); + $select = new htmlSelect('exportProfiles_' . $typeId, $exportOptions, [], $exportSize); $select->setHasDescriptiveElements(true); $select->setContainsOptgroups(true); $select->setMultiSelect(true); @@ -595,7 +596,7 @@ $containerTarget->add(new htmlHiddenInput('name_' . $typeId, '_'), 12); addSecurityTokenToMetaHTML($containerTarget); - parseHtml(null, $containerTarget, array(), false, 'user'); + parseHtml(null, $containerTarget, [], false, 'user'); echo ''; echo "\n"; @@ -614,7 +615,7 @@ // delete global templates $globalTemplates = $pdfStructurePersistenceManager->getPdfStructureTemplateNames(); -$globalDeletableTemplates = array(); +$globalDeletableTemplates = []; foreach ($globalTemplates as $typeId => $availableTemplates) { if (empty($availableTemplates)) { continue; @@ -631,13 +632,13 @@ $globalTemplatesSubtitle = new htmlSubTitle(_('Global templates')); $globalTemplatesSubtitle->setHelpId('364'); $container->add($globalTemplatesSubtitle); - $globalTemplatesSelect = new htmlResponsiveSelect('globalTemplatesDelete', $globalDeletableTemplates, array(), _('Delete')); + $globalTemplatesSelect = new htmlResponsiveSelect('globalTemplatesDelete', $globalDeletableTemplates, [], _('Delete')); $globalTemplatesSelect->setContainsOptgroups(true); $globalTemplatesSelect->setHasDescriptiveElements(true); $container->add($globalTemplatesSelect); $container->addVerticalSpacer('1rem'); $globalTemplateDeleteButton = new htmlButton('deleteGlobalProfileButton', _('Delete')); - $globalTemplateDeleteButton->setCSSClasses(array('lam-danger')); + $globalTemplateDeleteButton->setCSSClasses(['lam-danger']); $globalTemplateDeleteButton->setOnClick("window.lam.dialog.requestPasswordAndSendForm('" . _('Do you really want to delete this profile?') . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . _('Master password') . "', 'globalTemplateDeletePassword', 'deleteGlobalTemplatesForm'); return false;"); $container->addLabel(new htmlOutputText(' ', false)); @@ -646,7 +647,7 @@ $container->add(new htmlHiddenInput('deleteGlobalTemplate', 'true')); $container->addVerticalSpacer('1rem'); $globalTemplateDeleteForm = new htmlForm('deleteGlobalTemplatesForm', 'pdfmain.php', $container); - parseHtml(null, $globalTemplateDeleteForm, array(), false, 'user'); + parseHtml(null, $globalTemplateDeleteForm, [], false, 'user'); } // delete global PDF logos @@ -656,11 +657,11 @@ $globalLogosSubtitle = new htmlSubTitle(_('Global template logos')); $globalLogosSubtitle->setHelpId('365'); $container->add($globalLogosSubtitle); - $globalTemplateLogosSelect = new htmlResponsiveSelect('globalLogoDelete', $globalPdfLogos, array(), _('Delete')); + $globalTemplateLogosSelect = new htmlResponsiveSelect('globalLogoDelete', $globalPdfLogos, [], _('Delete')); $container->add($globalTemplateLogosSelect); $container->addVerticalSpacer('1rem'); $globalLogoDeleteButton = new htmlButton('deleteGlobalLogoButton', _('Delete')); - $globalLogoDeleteButton->setCSSClasses(array('lam-danger')); + $globalLogoDeleteButton->setCSSClasses(['lam-danger']); $globalLogoDeleteButton->setOnClick("window.lam.dialog.requestPasswordAndSendForm('" . _('Do you really want to delete this logo?') . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . _('Master password') . "', 'globalLogoDeletePassword', 'deleteGlobalLogoForm'); return false;"); $container->addLabel(new htmlOutputText(' ', false)); @@ -669,7 +670,7 @@ $container->add(new htmlHiddenInput('deleteGlobalLogo', 'true')); $container->addVerticalSpacer('1rem'); $globalLogoDeleteForm = new htmlForm('deleteGlobalLogoForm', 'pdfmain.php', $container); - parseHtml(null, $globalLogoDeleteForm, array(), false, 'user'); + parseHtml(null, $globalLogoDeleteForm, [], false, 'user'); } echo "\n"; diff --git a/lam/templates/pdfedit/pdfpage.php b/lam/templates/pdfedit/pdfpage.php index 5b9d96b16..dee1b6399 100644 --- a/lam/templates/pdfedit/pdfpage.php +++ b/lam/templates/pdfedit/pdfpage.php @@ -24,7 +24,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Michael Duergner - 2007 - 2022 Roland Gruber + 2007 - 2023 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 @@ -146,7 +146,7 @@ // Check if pdfname is valid, then save current structure to file and go to // main pdf structure page -$saveErrors = array(); +$saveErrors = []; if(isset($_GET['submit'])) { try { $pdfStructurePersistenceManager->savePdfStructure($_SESSION['config']->getName(), $type->getId(), $_POST['pdfname'], $_SESSION['currentPDFStructure']); @@ -155,7 +155,7 @@ exit; } catch (LAMException $e) { - $saveErrors[] = array('ERROR', $e->getTitle(), $e->getMessage()); + $saveErrors[] = ['ERROR', $e->getTitle(), $e->getMessage()]; } } @@ -163,10 +163,10 @@ // Create the values for the dropdown boxes for section headline defined by // value entries and fetch all available modules -$modules = array(); -$section_items_array = array(); +$modules = []; +$section_items_array = []; $section_items = ''; -$sortedModules = array(); +$sortedModules = []; foreach($availablePDFFields as $module => $fields) { if ($module != 'main') { $title = getModuleAlias($module, $type->getScope()); @@ -207,11 +207,11 @@ echo "
\n"; } -$newFieldFieldElements = array(); +$newFieldFieldElements = []; foreach($sortedModules as $module => $title) { $fields = $availablePDFFields[$module]; if (isset($fields) && is_array($fields) && (sizeof($fields) > 0)) { - $moduleFields = array(); + $moduleFields = []; foreach ($fields as $field => $fieldLabel) { $moduleFields[$fieldLabel] = $module . "_" . $field; } @@ -230,20 +230,20 @@ // headline $headline = $_SESSION['currentPDFStructure']->getTitle(); // logo -$logos = array(_('No logo') => 'none'); +$logos = [_('No logo') => 'none']; foreach($logoFiles as $logoFile) { $logos[$logoFile->getName() . ' (' . $logoFile->getWidth() . ' x ' . $logoFile->getHeight() . ")"] = $logoFile->getName(); } -$selectedLogo = array('printLogo.jpg'); +$selectedLogo = ['printLogo.jpg']; if (isset($_SESSION['currentPDFStructure'])) { - $selectedLogo = array($_SESSION['currentPDFStructure']->getLogo()); + $selectedLogo = [$_SESSION['currentPDFStructure']->getLogo()]; } ?>
add(new htmlTitle(_('PDF editor')), 12); @@ -261,8 +261,8 @@ if (isset($_SESSION['currentPDFStructure'])) { $foldingMarks = $_SESSION['currentPDFStructure']->getFoldingMarks(); } -$possibleFoldingMarks = array(_('No') => 'no', _('Yes') => 'standard'); -$foldingMarksSelect = new htmlResponsiveSelect('foldingmarks', $possibleFoldingMarks, array($foldingMarks), _('Folding marks')); +$possibleFoldingMarks = [_('No') => 'no', _('Yes') => 'standard']; +$foldingMarksSelect = new htmlResponsiveSelect('foldingmarks', $possibleFoldingMarks, [$foldingMarks], _('Folding marks')); $foldingMarksSelect->setHasDescriptiveElements(true); $mainContent->add($foldingMarksSelect, 12); $mainContent->addVerticalSpacer('3rem'); @@ -296,11 +296,11 @@ $structureContent->addVerticalSpacer('2rem'); // Section headline is a value entry if($section->isAttributeTitle()) { - $headlineElements = array(); + $headlineElements = []; foreach($section_items_array as $item) { $headlineElements[translateFieldIDToName($item, $type->getScope(), $availablePDFFields)] = '_' . $item; } - $sectionHeadlineSelect = new htmlSelect('section_' . $key, $headlineElements, array('_' . $section->getPdfKey())); + $sectionHeadlineSelect = new htmlSelect('section_' . $key, $headlineElements, ['_' . $section->getPdfKey()]); $sectionHeadlineSelect->setHasDescriptiveElements(true); $structureContent->addLabel($sectionHeadlineSelect); } @@ -363,7 +363,7 @@ // Add current satic text for dropdown box needed for the position when inserting a new // section or static text entry $textSnippet = $section->getText(); - $textSnippet = str_replace(array("\n", "\r"), array(" ", " "), $textSnippet); + $textSnippet = str_replace(["\n", "\r"], [" ", " "], $textSnippet); $textSnippet = trim($textSnippet); if (strlen($textSnippet) > 15) { $textSnippet = substr($textSnippet, 0, 15) . '...'; @@ -402,11 +402,11 @@ if (!empty($nonTextSectionElements)) { $newFieldContainer = new htmlResponsiveRow(); $newFieldContainer->add(new htmlSubTitle(_('New field')), 12); - $newFieldFieldSelect = new htmlResponsiveSelect('new_field', $newFieldFieldElements, array(), _('Field')); + $newFieldFieldSelect = new htmlResponsiveSelect('new_field', $newFieldFieldElements, [], _('Field')); $newFieldFieldSelect->setHasDescriptiveElements(true); $newFieldFieldSelect->setContainsOptgroups(true); $newFieldContainer->add($newFieldFieldSelect, 12); - $newFieldSectionSelect = new htmlResponsiveSelect('add_field_position', $nonTextSectionElements, array(), _('Position')); + $newFieldSectionSelect = new htmlResponsiveSelect('add_field_position', $nonTextSectionElements, [], _('Position')); $newFieldSectionSelect->setHasDescriptiveElements(true); $newFieldContainer->add($newFieldSectionSelect, 12); $newFieldContainer->addLabel(new htmlOutputText(' ', false)); @@ -420,7 +420,7 @@ $newSectionContent->add(new htmlSubTitle(_('New section')), 12); // add new section with text title $newSectionContent->add(new htmlResponsiveInputField(_("Headline"), 'new_section_text'), 12); -$newSectionPositionSelect1 = new htmlResponsiveSelect('add_sectionText_position', $sectionElements, array(), _('Position')); +$newSectionPositionSelect1 = new htmlResponsiveSelect('add_sectionText_position', $sectionElements, [], _('Position')); $newSectionPositionSelect1->setHasDescriptiveElements(true); $newSectionPositionSelect1->setSortElements(false); $newSectionContent->add($newSectionPositionSelect1, 12); @@ -428,11 +428,11 @@ $newSectionContent->addField(new htmlButton('add_sectionText', _('Add'))); $newSectionContent->addVerticalSpacer('2rem'); // add new section with field title -$newSectionFieldSelect = new htmlResponsiveSelect('new_section_item', $newFieldFieldElements, array(), _("Headline")); +$newSectionFieldSelect = new htmlResponsiveSelect('new_section_item', $newFieldFieldElements, [], _("Headline")); $newSectionFieldSelect->setHasDescriptiveElements(true); $newSectionFieldSelect->setContainsOptgroups(true); $newSectionContent->add($newSectionFieldSelect, 12); -$newSectionPositionSelect2 = new htmlResponsiveSelect('add_section_position', $sectionElements, array(), _('Position')); +$newSectionPositionSelect2 = new htmlResponsiveSelect('add_section_position', $sectionElements, [], _('Position')); $newSectionPositionSelect2->setHasDescriptiveElements(true); $newSectionPositionSelect2->setSortElements(false); $newSectionContent->add($newSectionPositionSelect2, 12); @@ -445,7 +445,7 @@ $newTextFieldContent = new htmlResponsiveRow(); $newTextFieldContent->add(new htmlSubTitle(_('New text area')), 12); $newTextFieldContent->add(new htmlResponsiveInputTextarea('text_text', '', 40, 3, _('Static text')), 12); -$newTextFieldPositionSelect = new htmlResponsiveSelect('add_text_position', $sectionElements, array(), _('Position')); +$newTextFieldPositionSelect = new htmlResponsiveSelect('add_text_position', $sectionElements, [], _('Position')); $newTextFieldPositionSelect->setHasDescriptiveElements(true); $newTextFieldPositionSelect->setSortElements(false); $newTextFieldContent->add($newTextFieldPositionSelect, 12); @@ -457,7 +457,7 @@ // buttons $buttonContainer = new htmlResponsiveRow(); $saveButton = new htmlButton('submit', _("Save")); -$saveButton->setCSSClasses(array('lam-primary')); +$saveButton->setCSSClasses(['lam-primary']); $cancelButton = new htmlButton('abort', _("Cancel")); $cancelButton->disableFormValidation(); $buttonGroup = new htmlGroup(); @@ -471,7 +471,7 @@ $container->add($buttonContainer, 12); addSecurityTokenToMetaHTML($container); -parseHtml(null, $container, array(), false, $type->getScope()); +parseHtml(null, $container, [], false, $type->getScope()); if ((sizeof($saveErrors) == 0) && isset($_POST['scrollPositionTop']) && isset($_POST['scrollPositionLeft'])) { // scroll to last position @@ -497,7 +497,7 @@ */ function translateFieldIDToName($id, $scope, $availablePDFFields): ?string { foreach ($availablePDFFields as $module => $fields) { - if (!(strpos($id, $module . '_') === 0)) { + if (!(str_starts_with($id, $module . '_'))) { continue; } foreach ($fields as $name => $label) { @@ -556,7 +556,7 @@ function updateBasicSettings(PDFStructure &$structure, array $logoFiles): void { function updateSectionTitles(PDFStructure &$structure): void { $sections = $structure->getSections(); foreach ($_POST as $key => $value) { - if (strpos($key, 'section_') === 0) { + if (str_starts_with($key, 'section_')) { $pos = substr($key, strlen('section_')); $sections[$pos]->setTitle($value); } @@ -578,7 +578,7 @@ function addSection(PDFStructure &$structure): void { } else { $section = new PDFTextSection(str_replace("\r", "", $_POST['text_text'])); - array_splice($sections, $_POST['add_text_position'], 0, array($section)); + array_splice($sections, $_POST['add_text_position'], 0, [$section]); $structure->setSections($sections); } } @@ -590,14 +590,14 @@ function addSection(PDFStructure &$structure): void { } else { $section = new PDFEntrySection($_POST['new_section_text']); - array_splice($sections, $_POST['add_sectionText_position'], 0, array($section)); + array_splice($sections, $_POST['add_sectionText_position'], 0, [$section]); $structure->setSections($sections); } } // Add a new section with item as headline elseif(isset($_POST['add_section'])) { $section = new PDFEntrySection('_' . $_POST['new_section_item']); - array_splice($sections, $_POST['add_section_position'], 0, array($section)); + array_splice($sections, $_POST['add_section_position'], 0, [$section]); $structure->setSections($sections); } } @@ -628,14 +628,14 @@ function removeItem(PDFStructure &$structure): void { $sections = $structure->getSections(); foreach ($_POST as $key => $value) { // remove section - if (strpos($key, 'remove_section_') === 0) { + if (str_starts_with($key, 'remove_section_')) { $pos = substr($key, strlen('remove_section_')); unset($sections[$pos]); $sections = array_values($sections); $structure->setSections($sections); } // remove section entry - if (strpos($key, 'remove_entry_') === 0) { + if (str_starts_with($key, 'remove_entry_')) { $parts = substr($key, strlen('remove_entry_')); $parts = explode('_', $parts); $sectionPos = $parts[0]; @@ -658,7 +658,7 @@ function moveUp(PDFStructure &$structure): void { $sections = $structure->getSections(); foreach ($_POST as $key => $value) { // move section - if (strpos($key, 'up_section_') === 0) { + if (str_starts_with($key, 'up_section_')) { $pos = intval(substr($key, strlen('up_section_'))); $sectionTmp = $sections[$pos - 1]; $sections[$pos - 1] = $sections[$pos]; @@ -666,7 +666,7 @@ function moveUp(PDFStructure &$structure): void { $structure->setSections($sections); } // move section entry - if (strpos($key, 'up_entry_') === 0) { + if (str_starts_with($key, 'up_entry_')) { $parts = substr($key, strlen('up_entry_')); $parts = explode('_', $parts); $sectionPos = $parts[0]; @@ -690,7 +690,7 @@ function moveDown(PDFStructure &$structure): void { $sections = $structure->getSections(); foreach ($_POST as $key => $value) { // move section - if (strpos($key, 'down_section_') === 0) { + if (str_starts_with($key, 'down_section_')) { $pos = intval(substr($key, strlen('down_section_'))); $sectionTmp = $sections[$pos + 1]; $sections[$pos + 1] = $sections[$pos]; @@ -698,7 +698,7 @@ function moveDown(PDFStructure &$structure): void { $structure->setSections($sections); } // move section entry - if (strpos($key, 'down_entry_') === 0) { + if (str_starts_with($key, 'down_entry_')) { $parts = substr($key, strlen('down_entry_')); $parts = explode('_', $parts); $sectionPos = $parts[0]; diff --git a/lam/templates/profedit/profilemain.php b/lam/templates/profedit/profilemain.php index 6803d8414..72a930705 100644 --- a/lam/templates/profedit/profilemain.php +++ b/lam/templates/profedit/profilemain.php @@ -124,8 +124,8 @@ } $serverProfilePersistenceManager = new ServerProfilePersistenceManager(); -$serverProfiles = array(); -$configProfiles = array(); +$serverProfiles = []; +$configProfiles = []; try { $configProfiles = $serverProfilePersistenceManager->getProfiles(); foreach ($configProfiles as $profileName) { @@ -144,10 +144,10 @@ $errMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!')); } elseif (!empty($_POST['importProfiles'])) { - $options = array(); + $options = []; foreach ($_POST['importProfiles'] as $importProfiles) { $parts = explode('##', $importProfiles); - $options[] = array('conf' => $parts[0], 'typeId' => $parts[1], 'name' => $parts[2]); + $options[] = ['conf' => $parts[0], 'typeId' => $parts[1], 'name' => $parts[2]]; } $errMessage = importProfiles($_POST['typeId'], $options, $serverProfiles, $typeManager); } @@ -164,10 +164,10 @@ $errMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!')); } elseif (!empty($_POST['exportProfiles'])) { - $options = array(); + $options = []; foreach ($_POST['exportProfiles'] as $importProfiles) { $parts = explode('##', $importProfiles); - $options[] = array('conf' => $parts[0], 'typeId' => $parts[1]); + $options[] = ['conf' => $parts[0], 'typeId' => $parts[1]]; } $typeId = $_POST['typeId']; $name = $_POST['name_' . $typeId]; @@ -178,20 +178,21 @@ } } -$profileClasses = array(); -$profileClassesTemp = array(); +$profileClasses = []; +$profileClassesTemp = []; foreach ($types as $type) { if ($type->isHidden() || !checkIfWriteAccessIsAllowed($type->getId())) { continue; } $profileList = $accountProfilePersistenceManager->getAccountProfileNames($type->getId(), $_SESSION['config']->getName()); natcasesort($profileList); - $profileClassesTemp[$type->getAlias()] = array( + $profileClassesTemp[$type->getAlias()] = [ 'typeId' => $type->getId(), 'scope' => $type->getScope(), 'title' => $type->getAlias(), 'icon' => $type->getIcon(), - 'profiles' => $profileList); + 'profiles' => $profileList + ]; } $profileClassesKeys = array_keys($profileClassesTemp); natcasesort($profileClassesKeys); @@ -233,7 +234,7 @@ // new profile if (!empty($profileClasses)) { $container->add(new htmlSubTitle(_('Create a new profile')), 12); - $sortedTypes = array(); + $sortedTypes = []; foreach ($profileClasses as $profileClass) { $sortedTypes[$profileClass['title']] = $profileClass['typeId']; } @@ -242,7 +243,7 @@ $newProfileSelect->setHasDescriptiveElements(true); $container->addLabel($newProfileSelect); $createButton = new htmlButton('createProfileButton', _('Create')); - $createButton->setCSSClasses(array('lam-primary')); + $createButton->setCSSClasses(['lam-primary']); $container->addField($createButton); } @@ -266,21 +267,21 @@ $deleteLink = new htmlLink(null, '#', '../../graphics/del.svg'); $deleteLink->setTitle(_('Delete')); $deleteLink->setOnClick("profileShowDeleteDialog('" . _('Delete') . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . $profileClass['typeId'] . "', '" . 'profile_' . $profileClass['typeId'] . "'); return false;"); - $deleteLink->setCSSClasses(array('margin3')); + $deleteLink->setCSSClasses(['margin3']); $buttonGroup->addElement($deleteLink); if (count($configProfiles) > 1) { $importLink = new htmlLink(null, '#', '../../graphics/import.svg'); $importLink->setTitle(_('Import profiles')); $importLink->setOnClick("window.lam.profilePdfEditor.showDistributionDialog('" . _("Import profiles") . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . $profileClass['typeId'] . "', 'import'); return false;"); - $importLink->setCSSClasses(array('margin3')); + $importLink->setCSSClasses(['margin3']); $buttonGroup->addElement($importLink); } $exportLink = new htmlLink(null, '#', '../../graphics/export.svg'); $exportLink->setTitle(_('Export profile')); $exportLink->setOnClick("window.lam.profilePdfEditor.showDistributionDialog('" . _("Export profile") . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . $profileClass['typeId'] . "', 'export', '" . 'profile_' . $profileClass['typeId'] . "'); return false;"); - $exportLink->setCSSClasses(array('margin3')); + $exportLink->setCSSClasses(['margin3']); $buttonGroup->addElement($exportLink); $container->add($buttonGroup, 12, 4); $container->addVerticalSpacer('1rem'); @@ -288,12 +289,12 @@ $container->addVerticalSpacer('1rem'); // generate content -parseHtml(null, $container, array(), false, 'user'); +parseHtml(null, $container, [], false, 'user'); echo "
\n"; // delete global templates -$globalDeletableTemplates = array(); +$globalDeletableTemplates = []; try { $globalTemplates = $accountProfilePersistenceManager->getAccountProfileTemplateNames(); foreach ($globalTemplates as $typeId => $availableTemplates) { @@ -316,13 +317,13 @@ $globalTemplatesSubtitle = new htmlSubTitle(_('Global templates')); $globalTemplatesSubtitle->setHelpId('364'); $container->add($globalTemplatesSubtitle); - $globalTemplatesSelect = new htmlResponsiveSelect('globalTemplatesDelete', $globalDeletableTemplates, array(), _('Delete')); + $globalTemplatesSelect = new htmlResponsiveSelect('globalTemplatesDelete', $globalDeletableTemplates, [], _('Delete')); $globalTemplatesSelect->setContainsOptgroups(true); $globalTemplatesSelect->setHasDescriptiveElements(true); $container->add($globalTemplatesSelect); $container->addVerticalSpacer('1rem'); $globalTemplateDeleteButton = new htmlButton('deleteGlobalProfileButton', _('Delete')); - $globalTemplateDeleteButton->setCSSClasses(array('lam-danger')); + $globalTemplateDeleteButton->setCSSClasses(['lam-danger']); $globalTemplateDeleteButton->setOnClick("window.lam.dialog.requestPasswordAndSendForm('" . _('Do you really want to delete this profile?') . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . _('Master password') . "', 'globalTemplateDeletePassword', 'deleteGlobalTemplatesForm'); return false;"); $container->addLabel(new htmlOutputText(' ', false)); @@ -331,7 +332,7 @@ $container->add(new htmlHiddenInput('deleteGlobalTemplate', 'true')); $container->addVerticalSpacer('1rem'); $globalTemplateDeleteForm = new htmlForm('deleteGlobalTemplatesForm', 'profilemain.php', $container); - parseHtml(null, $globalTemplateDeleteForm, array(), false, 'user'); + parseHtml(null, $globalTemplateDeleteForm, [], false, 'user'); } echo "\n"; @@ -339,7 +340,7 @@ foreach ($profileClasses as $profileClass) { $typeId = $profileClass['typeId']; $scope = $profileClass['scope']; - $importOptions = array(); + $importOptions = []; foreach ($configProfiles as $profile) { $typeManagerImport = new TypeManager($serverProfiles[$profile]); $typesImport = $typeManagerImport->getConfiguredTypesForScope($scope); @@ -360,7 +361,7 @@ $containerProfiles = new htmlResponsiveRow(); $containerProfiles->add(new htmlOutputText(_('Profiles')), 12); - $select = new htmlSelect('importProfiles', $importOptions, array(), count($importOptions, 1) < 15 ? count($importOptions, 1) : 15); + $select = new htmlSelect('importProfiles', $importOptions, [], count($importOptions, 1) < 15 ? count($importOptions, 1) : 15); $select->setMultiSelect(true); $select->setHasDescriptiveElements(true); $select->setContainsOptgroups(true); @@ -379,7 +380,7 @@ $containerProfiles->add(new htmlHiddenInput('typeId', $typeId), 0); addSecurityTokenToMetaHTML($containerProfiles); - parseHtml(null, $containerProfiles, array(), false, 'user'); + parseHtml(null, $containerProfiles, [], false, 'user'); echo ''; echo "\n"; @@ -391,7 +392,7 @@ $containerTarget = new htmlResponsiveRow(); $containerTarget->add(new htmlOutputText(_("Target server profile")), 12); - $exportOptions = array(); + $exportOptions = []; foreach ($configProfiles as $profile) { $typeManagerExport = new TypeManager($serverProfiles[$profile]); $typesExport = $typeManagerExport->getConfiguredTypesForScope($scope); @@ -403,7 +404,7 @@ } $exportOptions['*' . _('Global templates')][_('Global templates')] = 'templates*##'; - $select = new htmlSelect('exportProfiles', $exportOptions, array(), count($exportOptions) < 10 ? count($exportOptions, 1) : 10); + $select = new htmlSelect('exportProfiles', $exportOptions, [], count($exportOptions) < 10 ? count($exportOptions, 1) : 10); $select->setHasDescriptiveElements(true); $select->setContainsOptgroups(true); $select->setMultiSelect(true); @@ -423,7 +424,7 @@ $containerTarget->add(new htmlHiddenInput('name_' . $typeId, '_'), 0); addSecurityTokenToMetaHTML($containerTarget); - parseHtml(null, $containerTarget, array(), false, 'user'); + parseHtml(null, $containerTarget, [], false, 'user'); echo ''; echo "\n"; diff --git a/lam/templates/profedit/profilepage.php b/lam/templates/profedit/profilepage.php index 27e0bedf0..d8eccdacf 100644 --- a/lam/templates/profedit/profilepage.php +++ b/lam/templates/profedit/profilepage.php @@ -13,7 +13,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2003 - 2021 Roland Gruber + Copyright (C) 2003 - 2023 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 @@ -96,31 +96,31 @@ $accountProfilePersistenceManager = new AccountProfilePersistenceManager(); -$errors = array(); +$errors = []; // save button was pressed if (isset($_POST['save'])) { // create option array to check and save - $options = array(); + $options = []; $opt_keys = array_keys($_SESSION['profile_types']); foreach ($opt_keys as $element) { // text fields if ($_SESSION['profile_types'][$element] == "text") { - $options[$element] = array($_POST[$element]); + $options[$element] = [$_POST[$element]]; } // checkboxes elseif ($_SESSION['profile_types'][$element] == "checkbox") { - if (isset($_POST[$element]) && ($_POST[$element] == "on")) $options[$element] = array('true'); - else $options[$element] = array('false'); + if (isset($_POST[$element]) && ($_POST[$element] == "on")) $options[$element] = ['true']; + else $options[$element] = ['false']; } // dropdownbox elseif ($_SESSION['profile_types'][$element] == "select") { - $options[$element] = array($_POST[$element]); + $options[$element] = [$_POST[$element]]; } // multiselect elseif ($_SESSION['profile_types'][$element] == "multiselect") { if (isset($_POST[$element])) $options[$element] = $_POST[$element]; // value is already an array - else $options[$element] = array(); + else $options[$element] = []; } // textareas if ($_SESSION['profile_types'][$element] == "textarea") { @@ -138,7 +138,7 @@ exit(); } catch (LAMException $e) { - $errors[] = array("ERROR", _("Unable to save profile!"), $_POST['profname']); + $errors[] = ["ERROR", _("Unable to save profile!"), $_POST['profname']]; } } } @@ -156,17 +156,17 @@ } // empty list of attribute types -$_SESSION['profile_types'] = array(); +$_SESSION['profile_types'] = []; // get module options $options = getProfileOptions($type->getId()); // load old profile or POST values if needed -$old_options = array(); +$old_options = []; if (isset($_POST['save'])) { foreach ($_POST as $key => $value) { if (!is_array($value)) { - $old_options[$key] = array($value); + $old_options[$key] = [$value]; } else { $old_options[$key] = $value; @@ -203,12 +203,12 @@ // get root suffix $rootsuffix = $type->getSuffix(); // get subsuffixes -$suffixes = array('-' => '-'); +$suffixes = ['-' => '-']; $possibleSuffixes = $type->getSuffixList(); foreach ($possibleSuffixes as $suffix) { $suffixes[getAbstractDN($suffix)] = $suffix; } -$selectedSuffix = array(); +$selectedSuffix = []; if (isset($old_options['ldap_suffix'][0])) { $selectedSuffix[] = $old_options['ldap_suffix'][0]; } @@ -219,7 +219,7 @@ $container->add($suffixSelect, 12); // RDNs $rdns = getRDNAttributes($type->getId()); -$selectedRDN = array(); +$selectedRDN = []; if (isset($old_options['ldap_rdn'][0])) { $selectedRDN[] = $old_options['ldap_rdn'][0]; } @@ -237,7 +237,7 @@ } $module = new $moduleName($type->getScope()); $icon = $module->getIcon(); - if (!empty($icon) && !(strpos($icon, 'http') === 0) && !(strpos($icon, '/') === 0)) { + if (!empty($icon) && !(str_starts_with($icon, 'http')) && !(str_starts_with($icon, '/'))) { $icon = '../../graphics/' . $icon; } $modContainer = new htmlResponsiveRow(); @@ -250,10 +250,10 @@ // profile name and submit/abort buttons $buttonTable = new htmlResponsiveRow(); $saveButton = new htmlButton('save', _('Save')); -$saveButton->setCSSClasses(array('lam-primary fullwidth-mobile-only')); +$saveButton->setCSSClasses(['lam-primary fullwidth-mobile-only']); $buttonTable->addLabel($saveButton); $cancelButton = new htmlButton('abort', _('Cancel')); -$cancelButton->setCSSClasses(array('fullwidth-mobile-only')); +$cancelButton->setCSSClasses(['fullwidth-mobile-only']); $cancelButton->disableFormValidation(); $buttonTable->addField($cancelButton); $buttonTable->add(new htmlHiddenInput('accounttype', $type->getId()), 0); diff --git a/lam/templates/tests/index.php b/lam/templates/tests/index.php index dbabb732f..d2a03a76b 100644 --- a/lam/templates/tests/index.php +++ b/lam/templates/tests/index.php @@ -7,7 +7,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2006 - 2021 Roland Gruber + Copyright (C) 2006 - 2023 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 @@ -64,7 +64,7 @@ $container->add(new htmlLink(_("Schema test"), 'schemaTest.php', '../../graphics/search-color.svg'), 12, 4); $container->add(new htmlOutputText(_("Check if the LDAP schema fits the requirements of the selected account modules.")), 12, 8); -parseHtml(null, $container, array(), true, 'user'); +parseHtml(null, $container, [], true, 'user'); echo "\n"; include '../../lib/adminFooter.inc'; diff --git a/lam/templates/tests/lamdaemonTest.php b/lam/templates/tests/lamdaemonTest.php index 8eb085590..bf40b892a 100644 --- a/lam/templates/tests/lamdaemonTest.php +++ b/lam/templates/tests/lamdaemonTest.php @@ -16,7 +16,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2006 - 2022 Roland Gruber + Copyright (C) 2006 - 2023 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 @@ -68,8 +68,8 @@ $container->add(new htmlTitle(_("Lamdaemon test")), 12); $servers = $_SESSION['config']->getConfiguredScriptServers(); -$serverIDs = array(); -$serverTitles = array(); +$serverIDs = []; +$serverTitles = []; foreach ($servers as $server) { $serverName = $server->getServer(); $label = $server->getLabel(); @@ -84,7 +84,7 @@ lamRunTestSuite($_POST['server'], $serverTitles[$_POST['server']] , isset($_POST['checkQuotas']), $container); } elseif (!empty($servers)) { - $serverOptions = array(); + $serverOptions = []; foreach ($servers as $server) { $serverName = $server->getServer(); $label = $server->getLabel(); @@ -93,7 +93,7 @@ } $serverOptions[$label] = $serverName; } - $serverSelect = new htmlResponsiveSelect('server', $serverOptions, array(), _("Server")); + $serverSelect = new htmlResponsiveSelect('server', $serverOptions, [], _("Server")); $serverSelect->setHasDescriptiveElements(true); $container->add($serverSelect, 12); @@ -110,7 +110,7 @@ $container->add(new htmlStatusMessage("ERROR", _('No lamdaemon server set, please update your LAM configuration settings.')), 12); } -parseHtml(null, $container, array(), false, 'user'); +parseHtml(null, $container, [], false, 'user'); echo "\n"; echo "\n"; @@ -136,7 +136,7 @@ function testRemoteCommand($command, $stopTest, $remote, $testText, $container) flush(); $lamdaemonOk = false; $output = $remote->execute($command); - if ((stripos(strtolower($output), "error") === false) && ((strpos($output, 'INFO,') === 0) || (strpos($output, 'QUOTA_ENTRY') === 0))) { + if ((stripos(strtolower($output), "error") === false) && ((str_starts_with($output, 'INFO,')) || (str_starts_with($output, 'QUOTA_ENTRY')))) { $lamdaemonOk = true; } if ($lamdaemonOk) { @@ -145,7 +145,7 @@ function testRemoteCommand($command, $stopTest, $remote, $testText, $container) } else { $container->add(new htmlImage($failImage), 2); - if (!(strpos($output, 'ERROR,') === 0) && !(strpos($output, 'WARN,') === 0)) { + if (!(str_starts_with($output, 'ERROR,')) && !(str_starts_with($output, 'WARN,'))) { // error messages from console (e.g. sudo) $container->add(new htmlStatusMessage('ERROR', $output), 12, 6); } @@ -199,7 +199,7 @@ function lamRunTestSuite($serverName, $serverTitle, $testQuota, $container): voi $container->add(new htmlOutputText(_("No lamdaemon path set, please update your LAM configuration settings.")), 12, 6); $stopTest = true; } - elseif (substr($_SESSION['config']->get_scriptPath(), -3) != '.pl') { + elseif (!str_ends_with($_SESSION['config']->get_scriptPath(), '.pl')) { $container->add(new htmlImage($failImage), 2); $container->add(new htmlOutputText(_("Lamdaemon path does not end with \".pl\". Did you enter the full path to the script?")), 12, 6); $stopTest = true; @@ -218,7 +218,7 @@ function lamRunTestSuite($serverName, $serverTitle, $testQuota, $container): voi if (empty($scriptUserName)) { $container->add(new htmlOutputText(_("Unix account")), 10, 4); $unixOk = false; - $sr = @ldap_read($_SESSION['ldap']->server(), $ldapUser, "objectClass=posixAccount", array('uid'), 0, 0, 0, LDAP_DEREF_NEVER); + $sr = @ldap_read($_SESSION['ldap']->server(), $ldapUser, "objectClass=posixAccount", ['uid'], 0, 0, 0, LDAP_DEREF_NEVER); if ($sr) { $entry = @ldap_get_entries($_SESSION['ldap']->server(), $sr); if (($entry !== false) && isset($entry[0]['uid'][0])) { diff --git a/lam/templates/tests/schemaTest.php b/lam/templates/tests/schemaTest.php index c59f7cef7..36812aef2 100644 --- a/lam/templates/tests/schemaTest.php +++ b/lam/templates/tests/schemaTest.php @@ -11,7 +11,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2007 - 2022 Roland Gruber + Copyright (C) 2007 - 2023 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 @@ -97,7 +97,7 @@ } } -parseHtml(null, $container, array(), true, 'user'); +parseHtml(null, $container, [], true, 'user'); echo "\n"; include '../../lib/adminFooter.inc'; @@ -119,7 +119,7 @@ function checkSchemaForModule($name, $scope, $typeId): ?string { return null; } $schemaClasses = get_cached_schema('objectclasses'); - $schemaAttrs = array(); + $schemaAttrs = []; // check if object classes are supported for ($o = 0; $o < sizeof($classes); $o++) { if (!isset($schemaClasses[strtolower($classes[$o])])) { @@ -130,7 +130,7 @@ function checkSchemaForModule($name, $scope, $typeId): ?string { } // check if attributes are supported for ($a = 0; $a < sizeof($attrs); $a++) { - if (strpos($attrs[$a], 'INFO.') === 0) { + if (str_starts_with($attrs[$a], 'INFO.')) { continue; } if (!in_array_ignore_case($attrs[$a], $schemaAttrs) && !in_array_ignore_case(str_replace(';binary', '', $attrs[$a]), $schemaAttrs)) { @@ -150,7 +150,7 @@ function checkSchemaForModule($name, $scope, $typeId): ?string { * @return array list of attribute names */ function getRecursiveAttributesFromObjectClass($oClass): array { - $attrs = array(); + $attrs = []; $attrs = array_merge($attrs, $oClass->getMustAttrNames()); $attrs = array_merge($attrs, $oClass->getMayAttrNames()); $subClassNames = $oClass->getSupClasses();