mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 09:49:16 +02:00
refactoring
This commit is contained in:
parent
cff1728603
commit
f1b3ecd63f
5 changed files with 28 additions and 32 deletions
|
@ -244,7 +244,7 @@ function checkImportData(): void {
|
|||
$importer = new Importer();
|
||||
$tasks = $importer->getTasks($lines);
|
||||
$_SESSION[Importer::SESSION_KEY_TASKS] = $tasks;
|
||||
$_SESSION[Importer::SESSION_KEY_COUNT] = sizeof($tasks);
|
||||
$_SESSION[Importer::SESSION_KEY_COUNT] = count($tasks);
|
||||
$_SESSION[Importer::SESSION_KEY_STOP_ON_ERROR] = (!isset($_POST['noStop']) || ($_POST['noStop'] != 'on'));
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ function displayStartPage(): void {
|
|||
}
|
||||
$treeSuffixes = TreeViewTool::getRootDns();
|
||||
if (!empty($treeSuffixes)) {
|
||||
if (sizeof($treeSuffixes) === 1) {
|
||||
if (count($treeSuffixes) === 1) {
|
||||
$suffixes[_('Tree view')] = $treeSuffixes[0];
|
||||
$hideRules[$treeSuffixes[0]] = ['otherSuffix'];
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ function displayStartPage(): void {
|
|||
$container->add(new htmlButton('addFields', _('Add more fields')), 12);
|
||||
$container->add(new htmlHiddenInput('opcount', $opCount), 12);
|
||||
// error messages
|
||||
if (sizeof($errors) > 0) {
|
||||
if ($errors !== []) {
|
||||
$container->addVerticalSpacer('5rem');
|
||||
foreach ($errors as $error) {
|
||||
$error->colspan = 5;
|
||||
|
@ -209,7 +209,7 @@ function displayStartPage(): void {
|
|||
$container->addVerticalSpacer('1rem');
|
||||
|
||||
// run actions
|
||||
if ((sizeof($errors) == 0) && (isset($_POST['dryRun']) || isset($_POST['applyChanges']))) {
|
||||
if ((count($errors) == 0) && (isset($_POST['dryRun']) || isset($_POST['applyChanges']))) {
|
||||
runActions($container);
|
||||
}
|
||||
|
||||
|
@ -228,12 +228,7 @@ function displayStartPage(): void {
|
|||
*/
|
||||
function runActions(htmlResponsiveRow &$container): void {
|
||||
// LDAP suffix
|
||||
if ($_POST['suffix'] == '-') {
|
||||
$suffix = trim($_POST['otherSuffix']);
|
||||
}
|
||||
else {
|
||||
$suffix = $_POST['suffix'];
|
||||
}
|
||||
$suffix = ($_POST['suffix'] === '-') ? trim($_POST['otherSuffix']) : $_POST['suffix'];
|
||||
if (empty($suffix)) {
|
||||
$error = new htmlStatusMessage('ERROR', _('LDAP Suffix is invalid!'));
|
||||
$error->colspan = 5;
|
||||
|
@ -249,7 +244,7 @@ function runActions(htmlResponsiveRow &$container): void {
|
|||
$operations[] = [$_POST['op_' . $i], strtolower(trim($_POST['attr_' . $i])), trim($_POST['val_' . $i])];
|
||||
}
|
||||
}
|
||||
if (sizeof($operations) == 0) {
|
||||
if (count($operations) == 0) {
|
||||
$error = new htmlStatusMessage('ERROR', _('Please specify at least one operation.'));
|
||||
$error->colspan = 5;
|
||||
$container->add($error, 12);
|
||||
|
@ -290,12 +285,7 @@ function runAjaxActions(): void {
|
|||
break;
|
||||
case STAGE_ACTIONS_CALCULATED:
|
||||
case STAGE_WRITING:
|
||||
if ($_SESSION['multiEdit_dryRun']) {
|
||||
$jsonReturn = dryRun();
|
||||
}
|
||||
else {
|
||||
$jsonReturn = doModify();
|
||||
}
|
||||
$jsonReturn = $_SESSION['multiEdit_dryRun'] ? dryRun() : doModify();
|
||||
break;
|
||||
}
|
||||
echo json_encode($jsonReturn, JSON_THROW_ON_ERROR);
|
||||
|
@ -515,7 +505,7 @@ function doModify(): array {
|
|||
}
|
||||
// run 10 modifications in each call
|
||||
$localCount = 0;
|
||||
while (($localCount < 10) && ($_SESSION['multiEdit_status']['index'] < sizeof($_SESSION['multiEdit_status']['actions']))) {
|
||||
while (($localCount < 10) && ($_SESSION['multiEdit_status']['index'] < count($_SESSION['multiEdit_status']['actions']))) {
|
||||
$action = $_SESSION['multiEdit_status']['actions'][$_SESSION['multiEdit_status']['index']];
|
||||
$opType = $action[0];
|
||||
$dn = $action[1];
|
||||
|
@ -548,7 +538,7 @@ function doModify(): array {
|
|||
$_SESSION['multiEdit_status']['index']++;
|
||||
}
|
||||
// check if finished
|
||||
if ($_SESSION['multiEdit_status']['index'] == sizeof($_SESSION['multiEdit_status']['actions'])) {
|
||||
if ($_SESSION['multiEdit_status']['index'] == count($_SESSION['multiEdit_status']['actions'])) {
|
||||
$_SESSION['multiEdit_status']['modContent'] .= '<br><br>' . _('Finished all operations.');
|
||||
return [
|
||||
'status' => STAGE_FINISHED,
|
||||
|
@ -559,7 +549,7 @@ function doModify(): array {
|
|||
// return current status
|
||||
return [
|
||||
'status' => STAGE_WRITING,
|
||||
'progress' => 20 + (($_SESSION['multiEdit_status']['index'] / sizeof($_SESSION['multiEdit_status']['actions'])) * 80),
|
||||
'progress' => 20 + (($_SESSION['multiEdit_status']['index'] / count($_SESSION['multiEdit_status']['actions'])) * 80),
|
||||
'content' => $_SESSION['multiEdit_status']['modContent']
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace LAM\TOOLS\OU_EDIT;
|
||||
|
||||
use \htmlSpacer;
|
||||
use \htmlOutputText;
|
||||
use \htmlButton;
|
||||
|
@ -55,7 +57,9 @@ startSecureSession();
|
|||
enforceUserIsLoggedIn();
|
||||
|
||||
// die if no write access
|
||||
if (!checkIfWriteAccessIsAllowed()) die();
|
||||
if (!checkIfWriteAccessIsAllowed()) {
|
||||
die();
|
||||
}
|
||||
|
||||
checkIfToolIsActive('toolOUEditor');
|
||||
|
||||
|
@ -96,7 +100,9 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
|
|||
$error = _("Unable to create new OU!");
|
||||
}
|
||||
}
|
||||
else $error = _("OU already exists!");
|
||||
else {
|
||||
$error = _("OU already exists!");
|
||||
}
|
||||
}
|
||||
// show errormessage if ou is invalid
|
||||
else {
|
||||
|
@ -124,7 +130,7 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
|
|||
$info = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||
if (($info !== false) && ($info['count'] === 0)) {
|
||||
// print header
|
||||
include '../../lib/adminHeader.inc';
|
||||
include __DIR__ . '/../../lib/adminHeader.inc';
|
||||
echo '<div class="smallPaddingContent">';
|
||||
echo "<form action=\"ou_edit.php\" method=\"post\">\n";
|
||||
$container = new htmlResponsiveRow();
|
||||
|
@ -149,7 +155,7 @@ if (isset($_POST['createOU']) || isset($_POST['deleteOU'])) {
|
|||
parseHtml(null, $container, [], false, 'user');
|
||||
echo "</form>";
|
||||
echo '</div>';
|
||||
include '../../lib/adminFooter.inc';
|
||||
include __DIR__ . '/../../lib/adminFooter.inc';
|
||||
exit();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -54,7 +54,7 @@ if ($result) {
|
|||
$info = ldap_get_entries($_SESSION['ldap']->server(), $result);
|
||||
if (is_array($info) && is_array($info[0])) {
|
||||
$info = $info[0];
|
||||
foreach ($info as $key => $value) {
|
||||
foreach (array_keys($info) as $key) {
|
||||
if (is_array($info[$key]) && isset($info[$key]['count'])) {
|
||||
unset($info[$key]['count']);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ if ($configcontext != '') {
|
|||
$container->addLabel(new htmlOutputText('<b>' . _("Schema suffix") . '</b>', false));
|
||||
$container->addField(new htmlOutputText($subschemasubentry));
|
||||
|
||||
if ($dynamicSubtrees != '') {
|
||||
if ($dynamicSubtrees !== '') {
|
||||
$container->addLabel(new htmlOutputText('<b>' . _("Dynamic subtrees") . '</b>', false));
|
||||
$container->addField(new htmlOutputText($dynamicSubtrees));
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ function showTree(): void {
|
|||
$dnParts = ldap_explode_dn($extraDnPart, 0);
|
||||
if ($dnParts !== false) {
|
||||
unset($dnParts['count']);
|
||||
$dnPartsCount = sizeof($dnParts);
|
||||
$dnPartsCount = count($dnParts);
|
||||
for ($i = 0; $i < $dnPartsCount; $i++) {
|
||||
$currentParts = array_slice($dnParts, $dnPartsCount - ($i + 1));
|
||||
$openInitial[] = '"' . base64_encode(implode(',', $currentParts) . ',' . $rootDn) . '"';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue