mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 09:49:16 +02:00
refactoring
This commit is contained in:
parent
d9bced28b4
commit
5fcf2bb7a1
6 changed files with 51 additions and 49 deletions
|
@ -1072,9 +1072,9 @@ class htmlButton extends htmlElement {
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param String $name button name
|
* @param string $name button name
|
||||||
* @param String $value button text or image (16x16px, relative to graphics folder)
|
* @param string $value button text or image (16x16px, relative to graphics folder)
|
||||||
* @param String $isImageButton image or text button (default text)
|
* @param bool $isImageButton image or text button (default text)
|
||||||
*/
|
*/
|
||||||
function __construct($name, $value, $isImageButton = false) {
|
function __construct($name, $value, $isImageButton = false) {
|
||||||
$this->name = htmlspecialchars($name);
|
$this->name = htmlspecialchars($name);
|
||||||
|
|
|
@ -204,7 +204,6 @@ class AccountProfilePersistenceManager {
|
||||||
* @param string $confName server profile name
|
* @param string $confName server profile name
|
||||||
* @return bool profile exists
|
* @return bool profile exists
|
||||||
* @throws LAMException error while checking
|
* @throws LAMException error while checking
|
||||||
* @throws LAMException error writing template
|
|
||||||
*/
|
*/
|
||||||
public function isAccountProfileExisting(string $typeId, string $name, string $confName): bool {
|
public function isAccountProfileExisting(string $typeId, string $name, string $confName): bool {
|
||||||
if (!$this->isValidAccountProfileName($name)
|
if (!$this->isValidAccountProfileName($name)
|
||||||
|
|
|
@ -1,26 +1,28 @@
|
||||||
<?php
|
<?php
|
||||||
namespace LAM\TOOLS\MULTI_EDIT;
|
namespace LAM\TOOLS\MULTI_EDIT;
|
||||||
use htmlProgressbar;
|
use htmlProgressbar;
|
||||||
use \htmlTable;
|
use htmlTable;
|
||||||
use \htmlTitle;
|
use htmlTitle;
|
||||||
use \htmlSelect;
|
use htmlSelect;
|
||||||
use \htmlOutputText;
|
use htmlOutputText;
|
||||||
use \htmlInputField;
|
use htmlInputField;
|
||||||
use \htmlSubTitle;
|
use htmlSubTitle;
|
||||||
use \htmlButton;
|
use htmlButton;
|
||||||
use \htmlStatusMessage;
|
use htmlStatusMessage;
|
||||||
use \htmlSpacer;
|
use htmlSpacer;
|
||||||
use \htmlHiddenInput;
|
use htmlHiddenInput;
|
||||||
use \htmlGroup;
|
use htmlGroup;
|
||||||
use \htmlDiv;
|
use htmlDiv;
|
||||||
use \htmlJavaScript;
|
use htmlJavaScript;
|
||||||
use \htmlLink;
|
use htmlLink;
|
||||||
use \htmlInputTextarea;
|
use htmlInputTextarea;
|
||||||
use \htmlResponsiveRow;
|
use htmlResponsiveRow;
|
||||||
use \htmlResponsiveSelect;
|
use htmlResponsiveSelect;
|
||||||
use \htmlResponsiveInputField;
|
use htmlResponsiveInputField;
|
||||||
use \htmlResponsiveTable;
|
use htmlResponsiveTable;
|
||||||
use LAM\TOOLS\TREEVIEW\TreeViewTool;
|
use LAM\TOOLS\TREEVIEW\TreeViewTool;
|
||||||
|
use LAM\TYPES\TypeManager;
|
||||||
|
use LAMException;
|
||||||
use LamTemporaryFilesManager;
|
use LamTemporaryFilesManager;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -106,11 +108,11 @@ function displayStartPage(): void {
|
||||||
echo "<form action=\"multiEdit.php\" method=\"post\">\n";
|
echo "<form action=\"multiEdit.php\" method=\"post\">\n";
|
||||||
$errors = [];
|
$errors = [];
|
||||||
$container = new htmlResponsiveRow();
|
$container = new htmlResponsiveRow();
|
||||||
$container->add(new htmlTitle(_("Multi edit")), 12);
|
$container->add(new htmlTitle(_("Multi edit")));
|
||||||
// LDAP suffix
|
// LDAP suffix
|
||||||
$showRules = ['-' => ['otherSuffix']];
|
$showRules = ['-' => ['otherSuffix']];
|
||||||
$hideRules = [];
|
$hideRules = [];
|
||||||
$typeManager = new \LAM\TYPES\TypeManager();
|
$typeManager = new TypeManager();
|
||||||
$types = $typeManager->getConfiguredTypes();
|
$types = $typeManager->getConfiguredTypes();
|
||||||
$suffixes = [];
|
$suffixes = [];
|
||||||
foreach ($types as $type) {
|
foreach ($types as $type) {
|
||||||
|
@ -144,16 +146,16 @@ function displayStartPage(): void {
|
||||||
$suffixSelect->setSortElements(false);
|
$suffixSelect->setSortElements(false);
|
||||||
$suffixSelect->setTableRowsToShow($showRules);
|
$suffixSelect->setTableRowsToShow($showRules);
|
||||||
$suffixSelect->setTableRowsToHide($hideRules);
|
$suffixSelect->setTableRowsToHide($hideRules);
|
||||||
$container->add($suffixSelect, 12);
|
$container->add($suffixSelect);
|
||||||
$valOtherSuffix = empty($_POST['otherSuffix']) ? '' : $_POST['otherSuffix'];
|
$valOtherSuffix = empty($_POST['otherSuffix']) ? '' : (string) $_POST['otherSuffix'];
|
||||||
$container->add(new htmlResponsiveInputField(_('Other'), 'otherSuffix', $valOtherSuffix), 12);
|
$container->add(new htmlResponsiveInputField(_('Other'), 'otherSuffix', $valOtherSuffix));
|
||||||
// LDAP filter
|
// LDAP filter
|
||||||
$valFilter = empty($_POST['filter']) ? '(objectClass=inetOrgPerson)' : $_POST['filter'];
|
$valFilter = empty($_POST['filter']) ? '(objectClass=inetOrgPerson)' : (string) $_POST['filter'];
|
||||||
$container->add(new htmlResponsiveInputField(_('LDAP filter'), 'filter', $valFilter, '701'), 12);
|
$container->add(new htmlResponsiveInputField(_('LDAP filter'), 'filter', $valFilter, '701'));
|
||||||
// operation fields
|
// operation fields
|
||||||
$operationsTitle = new htmlSubTitle(_('Operations'));
|
$operationsTitle = new htmlSubTitle(_('Operations'));
|
||||||
$operationsTitle->setHelpId('702');
|
$operationsTitle->setHelpId('702');
|
||||||
$container->add($operationsTitle, 12);
|
$container->add($operationsTitle);
|
||||||
$operationsTitles = [_('Type'), _('Attribute name'), _('Value')];
|
$operationsTitles = [_('Type'), _('Attribute name'), _('Value')];
|
||||||
$data = [];
|
$data = [];
|
||||||
$opCount = empty($_POST['opcount']) ? '3' : $_POST['opcount'];
|
$opCount = empty($_POST['opcount']) ? '3' : $_POST['opcount'];
|
||||||
|
@ -168,9 +170,9 @@ function displayStartPage(): void {
|
||||||
$opSelect->setHasDescriptiveElements(true);
|
$opSelect->setHasDescriptiveElements(true);
|
||||||
$data[$i][] = $opSelect;
|
$data[$i][] = $opSelect;
|
||||||
// attribute name
|
// attribute name
|
||||||
$attrVal = empty($_POST['attr_' . $i]) ? '' : $_POST['attr_' . $i];
|
$attrVal = empty($_POST['attr_' . $i]) ? '' : (string) $_POST['attr_' . $i];
|
||||||
$data[$i][] = new htmlInputField('attr_' . $i, $attrVal);
|
$data[$i][] = new htmlInputField('attr_' . $i, $attrVal);
|
||||||
$valVal = empty($_POST['val_' . $i]) ? '' : $_POST['val_' . $i];
|
$valVal = empty($_POST['val_' . $i]) ? '' : (string) $_POST['val_' . $i];
|
||||||
$data[$i][] = new htmlInputField('val_' . $i, $valVal);
|
$data[$i][] = new htmlInputField('val_' . $i, $valVal);
|
||||||
// check input
|
// check input
|
||||||
if (($selOp == ADD) && !empty($attrVal) && empty($valVal)) {
|
if (($selOp == ADD) && !empty($attrVal) && empty($valVal)) {
|
||||||
|
@ -181,17 +183,17 @@ function displayStartPage(): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$operationsTable = new htmlResponsiveTable($operationsTitles, $data);
|
$operationsTable = new htmlResponsiveTable($operationsTitles, $data);
|
||||||
$container->add($operationsTable, 12);
|
$container->add($operationsTable);
|
||||||
// add more fields
|
// add more fields
|
||||||
$container->addVerticalSpacer('1rem');
|
$container->addVerticalSpacer('1rem');
|
||||||
$container->add(new htmlButton('addFields', _('Add more fields')), 12);
|
$container->add(new htmlButton('addFields', _('Add more fields')));
|
||||||
$container->add(new htmlHiddenInput('opcount', $opCount), 12);
|
$container->add(new htmlHiddenInput('opcount', $opCount));
|
||||||
// error messages
|
// error messages
|
||||||
if ($errors !== []) {
|
if ($errors !== []) {
|
||||||
$container->addVerticalSpacer('5rem');
|
$container->addVerticalSpacer('5rem');
|
||||||
foreach ($errors as $error) {
|
foreach ($errors as $error) {
|
||||||
$error->colspan = 5;
|
$error->colspan = 5;
|
||||||
$container->add($error, 12);
|
$container->add($error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// action buttons
|
// action buttons
|
||||||
|
@ -205,7 +207,7 @@ function displayStartPage(): void {
|
||||||
$dryRunButton = new htmlButton('dryRun', _('Dry run'));
|
$dryRunButton = new htmlButton('dryRun', _('Dry run'));
|
||||||
$dryRunButton->setCSSClasses(['lam-secondary']);
|
$dryRunButton->setCSSClasses(['lam-secondary']);
|
||||||
$buttonGroup->addElement($dryRunButton);
|
$buttonGroup->addElement($dryRunButton);
|
||||||
$container->add($buttonGroup, 12);
|
$container->add($buttonGroup);
|
||||||
$container->addVerticalSpacer('1rem');
|
$container->addVerticalSpacer('1rem');
|
||||||
|
|
||||||
// run actions
|
// run actions
|
||||||
|
@ -226,13 +228,13 @@ function displayStartPage(): void {
|
||||||
*
|
*
|
||||||
* @param htmlResponsiveRow $container container
|
* @param htmlResponsiveRow $container container
|
||||||
*/
|
*/
|
||||||
function runActions(htmlResponsiveRow &$container): void {
|
function runActions(htmlResponsiveRow $container): void {
|
||||||
// LDAP suffix
|
// LDAP suffix
|
||||||
$suffix = ($_POST['suffix'] === '-') ? trim($_POST['otherSuffix']) : $_POST['suffix'];
|
$suffix = ($_POST['suffix'] === '-') ? trim($_POST['otherSuffix']) : $_POST['suffix'];
|
||||||
if (empty($suffix)) {
|
if (empty($suffix)) {
|
||||||
$error = new htmlStatusMessage('ERROR', _('LDAP Suffix is invalid!'));
|
$error = new htmlStatusMessage('ERROR', _('LDAP Suffix is invalid!'));
|
||||||
$error->colspan = 5;
|
$error->colspan = 5;
|
||||||
$container->add($error, 12);
|
$container->add($error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// LDAP filter
|
// LDAP filter
|
||||||
|
@ -247,7 +249,7 @@ function runActions(htmlResponsiveRow &$container): void {
|
||||||
if (count($operations) == 0) {
|
if (count($operations) == 0) {
|
||||||
$error = new htmlStatusMessage('ERROR', _('Please specify at least one operation.'));
|
$error = new htmlStatusMessage('ERROR', _('Please specify at least one operation.'));
|
||||||
$error->colspan = 5;
|
$error->colspan = 5;
|
||||||
$container->add($error, 12);
|
$container->add($error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$_SESSION['multiEdit_suffix'] = $suffix;
|
$_SESSION['multiEdit_suffix'] = $suffix;
|
||||||
|
@ -264,7 +266,7 @@ function runActions(htmlResponsiveRow &$container): void {
|
||||||
$ajaxBlock = '
|
$ajaxBlock = '
|
||||||
window.lam.multiedit.runActions();
|
window.lam.multiedit.runActions();
|
||||||
';
|
';
|
||||||
$container->add(new htmlJavaScript($ajaxBlock), 12);
|
$container->add(new htmlJavaScript($ajaxBlock));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -419,6 +421,7 @@ function generateActions(): array {
|
||||||
* Prints the dryRun output.
|
* Prints the dryRun output.
|
||||||
*
|
*
|
||||||
* @return array<mixed> status
|
* @return array<mixed> status
|
||||||
|
* @throws LAMException error simulating actions
|
||||||
*/
|
*/
|
||||||
function dryRun(): array {
|
function dryRun(): array {
|
||||||
$pro = isLAMProVersion() ? ' Pro' : '';
|
$pro = isLAMProVersion() ? ' Pro' : '';
|
||||||
|
|
|
@ -18,7 +18,7 @@ use LAM\TYPES\TypeManager;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||||
Copyright (C) 2003 - 2024 Roland Gruber
|
Copyright (C) 2003 - 2025 Roland Gruber
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -206,6 +206,9 @@ function display_main(?string $message, ?string $error): void {
|
||||||
$optionsToInsert = [];
|
$optionsToInsert = [];
|
||||||
foreach ($types as $typeId => $title) {
|
foreach ($types as $typeId => $title) {
|
||||||
$type = $typeManager->getConfiguredType($typeId);
|
$type = $typeManager->getConfiguredType($typeId);
|
||||||
|
if ($type === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$elements = [];
|
$elements = [];
|
||||||
$units = searchLDAP($type->getSuffix(), '(|(objectclass=organizationalunit)(objectclass=organization))', ['dn']);
|
$units = searchLDAP($type->getSuffix(), '(|(objectclass=organizationalunit)(objectclass=organization))', ['dn']);
|
||||||
foreach ($units as $unit) {
|
foreach ($units as $unit) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -180,7 +180,7 @@ if (isset($monitorEntries['cn=time,cn=monitor']) || isset($monitorEntries['cn=st
|
||||||
if (isset($monitorEntries['cn=start,cn=time,cn=monitor'])) {
|
if (isset($monitorEntries['cn=start,cn=time,cn=monitor'])) {
|
||||||
$time = formatLDAPTimestamp($monitorEntries['cn=start,cn=time,cn=monitor']['monitortimestamp'][0]);
|
$time = formatLDAPTimestamp($monitorEntries['cn=start,cn=time,cn=monitor']['monitortimestamp'][0]);
|
||||||
$container->addLabel(new htmlOutputText('<b>' . _("Start time") . '</b>', false));
|
$container->addLabel(new htmlOutputText('<b>' . _("Start time") . '</b>', false));
|
||||||
$container->addField(new htmlOutputText($time), 12);
|
$container->addField(new htmlOutputText($time));
|
||||||
}
|
}
|
||||||
elseif (isset($monitorEntries['cn=monitor']['starttime'])) { // Fedora 389
|
elseif (isset($monitorEntries['cn=monitor']['starttime'])) { // Fedora 389
|
||||||
$time = formatLDAPTimestamp($monitorEntries['cn=monitor']['starttime'][0]);
|
$time = formatLDAPTimestamp($monitorEntries['cn=monitor']['starttime'][0]);
|
||||||
|
|
|
@ -22,15 +22,12 @@ parameters:
|
||||||
- '#Used function [a-zA-Z0-9\\_-]+ not found.#'
|
- '#Used function [a-zA-Z0-9\\_-]+ not found.#'
|
||||||
- '#Variable \$helpArray might not be defined.#'
|
- '#Variable \$helpArray might not be defined.#'
|
||||||
- '#Function [a-zA-Z0-9\(\)\\_-]+ has invalid return type [a-zA-Z0-9\\_-]+.#'
|
- '#Function [a-zA-Z0-9\(\)\\_-]+ has invalid return type [a-zA-Z0-9\\_-]+.#'
|
||||||
- '#PHPDoc tag @throws with type LAMException is not subtype of Throwable#'
|
|
||||||
- '#Throwing object of an unknown class [a-zA-Z0-9\\_-]+.#'
|
|
||||||
- '#Parameter \#[0-9] \$[a-zA-Z_]+ of function [a-zA-Z_]+ expects [(]?callable.*#'
|
- '#Parameter \#[0-9] \$[a-zA-Z_]+ of function [a-zA-Z_]+ expects [(]?callable.*#'
|
||||||
- '#Call to an undefined method object::.*#'
|
- '#Call to an undefined method object::.*#'
|
||||||
- '#Parameter \#2 \$string of function explode expects string, .* given.#'
|
- '#Parameter \#2 \$string of function explode expects string, .* given.#'
|
||||||
- '#Parameter \#2 \$result of function ldap_.* expects LDAP\\Result, array\|LDAP\\Result given.#'
|
- '#Parameter \#2 \$result of function ldap_.* expects LDAP\\Result, array\|LDAP\\Result given.#'
|
||||||
- '#Cannot access an offset on mixed.#'
|
- '#Cannot access an offset on mixed.#'
|
||||||
- '#Cannot access offset .* on mixed.#'
|
- '#Cannot access offset .* on mixed.#'
|
||||||
- '#Cannot access offset .* on array\|int.#'
|
|
||||||
- '#Cannot access an offset on array\|Countable.#'
|
- '#Cannot access an offset on array\|Countable.#'
|
||||||
- '#Cannot assign new offset to list\<string\>\|string.#'
|
- '#Cannot assign new offset to list\<string\>\|string.#'
|
||||||
- '#Parameter \#1 \$haystack of function str_starts_with expects string, int\|string given.#'
|
- '#Parameter \#1 \$haystack of function str_starts_with expects string, int\|string given.#'
|
||||||
|
@ -40,7 +37,6 @@ parameters:
|
||||||
- '#Parameter \#1 \$array of function array_keys expects array, mixed given.#'
|
- '#Parameter \#1 \$array of function array_keys expects array, mixed given.#'
|
||||||
- '#Argument of an invalid type mixed supplied for foreach, only iterables are supported.#'
|
- '#Argument of an invalid type mixed supplied for foreach, only iterables are supported.#'
|
||||||
- '#Parameter \#2 \$args of function call_user_func_array expects array<int\|string, mixed>, mixed given.#'
|
- '#Parameter \#2 \$args of function call_user_func_array expects array<int\|string, mixed>, mixed given.#'
|
||||||
- '#Cannot access offset non-falsy-string on array<string>\|object.#'
|
|
||||||
- '#Unable to resolve the template type T in call to function array_values#'
|
- '#Unable to resolve the template type T in call to function array_values#'
|
||||||
- '#Cannot call method .* on mixed.*#'
|
- '#Cannot call method .* on mixed.*#'
|
||||||
- '#Cannot cast mixed to string.#'
|
- '#Cannot cast mixed to string.#'
|
||||||
|
@ -50,3 +46,4 @@ parameters:
|
||||||
- '#Cannot access property .* on mixed#'
|
- '#Cannot access property .* on mixed#'
|
||||||
- '#.* function lamEncrypt expects string.*#'
|
- '#.* function lamEncrypt expects string.*#'
|
||||||
- '#.*class htmlHiddenInput constructor expects string, mixed given.*#'
|
- '#.*class htmlHiddenInput constructor expects string, mixed given.*#'
|
||||||
|
- '#Parameter \#1 \$string of class htmlOutputText constructor expects string, \(array\|float\|int\) given.#'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue