diff --git a/lam/templates/upload/massBuildAccounts.php b/lam/templates/upload/massBuildAccounts.php index 58ba9e08c..af039ee47 100644 --- a/lam/templates/upload/massBuildAccounts.php +++ b/lam/templates/upload/massBuildAccounts.php @@ -56,7 +56,9 @@ enforceUserIsLoggedIn(); checkIfToolIsActive('toolFileUpload'); // die if no write access -if (!checkIfWriteAccessIsAllowed()) die(); +if (!checkIfWriteAccessIsAllowed()) { + die(); +} // Redirect to startpage if user is not logged in if (!isLoggedIn()) { @@ -196,7 +198,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) { $values_given[] = $dataRow[$colNumber]; } $values_unique = array_unique($values_given); - if (sizeof($values_given) != sizeof($values_unique)) { + if (count($values_given) !== count($values_unique)) { $duplicates = []; foreach ($values_given as $key => $value) { if (!isset($values_unique[$key]) && ($value !== null)) { @@ -211,7 +213,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) { logNewMessage(LOG_DEBUG, 'End of generic checks'); // if input data is invalid just display error messages (max 50) - if (sizeof($errors) > 0) { + if ($errors !== []) { foreach ($errors as $error) { $container->add(new htmlStatusMessage("ERROR", $error[0], $error[1]), 12); } @@ -237,12 +239,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) { $rdnValue = $rdnValue[0]; } $account_dn = $data[$i][$ids['dn_rdn']] . "=" . ldap_escape($rdnValue, '', LDAP_ESCAPE_DN) . ","; - if ($data[$i][$ids['dn_suffix']] == "") { - $account_dn = $account_dn . $suffix; - } - else { - $account_dn = $account_dn . $data[$i][$ids['dn_suffix']]; - } + $account_dn = ($data[$i][$ids['dn_suffix']] == "") ? $account_dn . $suffix : $account_dn . $data[$i][$ids['dn_suffix']]; $accounts[$i]['dn'] = $account_dn; } // set overwrite @@ -251,7 +248,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) { } } // print errors if DN could not be built - if (sizeof($errors) > 0) { + if ($errors !== []) { foreach ($errors as $error) { $container->add(new htmlStatusMessage("ERROR", $error[0], $error[1], $error[2]), 12); } diff --git a/lam/templates/upload/massDoUpload.php b/lam/templates/upload/massDoUpload.php index 912d5665d..e9f800e72 100644 --- a/lam/templates/upload/massDoUpload.php +++ b/lam/templates/upload/massDoUpload.php @@ -54,7 +54,9 @@ enforceUserIsLoggedIn(); checkIfToolIsActive('toolFileUpload'); // die if no write access -if (!checkIfWriteAccessIsAllowed()) die(); +if (!checkIfWriteAccessIsAllowed()) { + die(); +} // Redirect to startpage if user is not logged in if (!isLoggedIn()) { diff --git a/lam/templates/upload/masscreate.php b/lam/templates/upload/masscreate.php index 03fda066e..3f2d4cfd1 100644 --- a/lam/templates/upload/masscreate.php +++ b/lam/templates/upload/masscreate.php @@ -1,5 +1,7 @@ getConfiguredTypes(); -$count = sizeof($types); +$count = count($types); for ($i = 0; $i < $count; $i++) { $myType = $types[$i]; if (!$myType->getBaseType()->supportsFileUpload() || $myType->isHidden() - || !checkIfNewEntriesAreAllowed($myType->getId()) || !checkIfWriteAccessIsAllowed($myType->getId())) { + || !checkIfNewEntriesAreAllowed($myType->getId()) || !checkIfWriteAccessIsAllowed($myType->getId())) { unset($types[$i]); } } @@ -127,11 +132,11 @@ if (isset($_POST['type'])) { } $deps = getModulesDependencies($type->getScope()); $depErrors = check_module_depends($selectedModules, $deps); - if (is_array($depErrors) && (sizeof($depErrors) > 0)) { + if (is_array($depErrors) && ($depErrors !== [])) { foreach ($depErrors as $depError) { StatusMessage('ERROR', _("Unsolved dependency:") . ' ' . - getModuleAlias($depError[0], $type->getScope()) . " (" . - getModuleAlias($depError[1], $type->getScope()) . ")"); + getModuleAlias($depError[0], $type->getScope()) . " (" . + getModuleAlias($depError[1], $type->getScope()) . ")"); } } else { @@ -214,14 +219,14 @@ foreach ($types as $type) { $moduleGroup->addElement(new htmlLabel($type->getId() . '___' . $moduleName, getModuleAlias($moduleName, $type->getScope()))); $innerRow->add($moduleGroup, 12, 6, 4); } - $moduleCount = sizeof($modules); - if ($moduleCount%3 == 2) { + $moduleCount = count($modules); + if ($moduleCount % 3 == 2) { $innerRow->add(new htmlOutputText(' ', false), 0, 0, 4); } - if ($moduleCount%3 == 1) { + if ($moduleCount % 3 == 1) { $innerRow->add(new htmlOutputText(' ', false), 0, 0, 4); } - if ($moduleCount%2 == 1) { + if ($moduleCount % 2 == 1) { $innerRow->add(new htmlOutputText(' ', false), 0, 6, 0); } $typeDiv = new htmlDiv($type->getId(), $innerRow); @@ -232,8 +237,8 @@ foreach ($types as $type) { // ok button $row->addVerticalSpacer('3rem'); if (!empty($types)) { - $okButton = new htmlButton('submit', _('Ok')); - $okButton->setCSSClasses(['lam-primary']); + $okButton = new htmlButton('submit', _('Ok')); + $okButton->setCSSClasses(['lam-primary']); $row->add($okButton); } @@ -246,11 +251,11 @@ echo ''; include __DIR__ . '/../../lib/adminFooter.inc'; /** -* Displays the account type specific main page of the upload. -* -* @param \LAM\TYPES\ConfiguredType $type account type -* @param string[] $selectedModules list of selected account modules -*/ + * Displays the account type specific main page of the upload. + * + * @param \LAM\TYPES\ConfiguredType $type account type + * @param string[] $selectedModules list of selected account modules + */ function showMainPage(\LAM\TYPES\ConfiguredType $type, array $selectedModules): void { $scope = $type->getScope(); echo '