refactoring

This commit is contained in:
Roland Gruber 2023-10-12 07:59:09 +02:00
parent c3bd3c1762
commit 72f0ccf488
7 changed files with 43 additions and 49 deletions

View file

@ -1268,10 +1268,10 @@ abstract class baseModule {
* <br>
* It allows additional LDAP changes when an account is deleted.
*
* @return List of LDAP operations, same as for save_attributes()
* @return array of LDAP operations, same as for save_attributes()
*/
public function delete_attributes() {
return 0;
public function delete_attributes(): array {
return [];
}
/**

View file

@ -386,18 +386,17 @@ class nisNetGroupUser extends baseModule {
}
/**
* Additional LDAP operations on delete.
*
* @return List of LDAP operations, same as for save_attributes()
* {@inheritDoc}
* @see baseModule::delete_attributes()
*/
function delete_attributes() {
function delete_attributes(): array {
$uid = $this->getUid();
if (empty($uid)) {
return array();
return [];
}
$return = array();
$return = [];
// remove from NIS netgroups
$changes = array();
$changes = [];
foreach ($this->groups as $group) {
$changes[$group['dn']][] = $this->createNetGroupValue($group, $uid);
}

View file

@ -998,12 +998,11 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr
}
/**
* Additional LDAP operations on delete.
*
* @return List of LDAP operations, same as for save_attributes()
* {@inheritDoc}
* @see baseModule::delete_attributes()
*/
function delete_attributes() {
$return = array();
function delete_attributes(): array {
$return = [];
// remove memberUids if set
$groups = searchLDAPByAttribute('memberUid', $this->attributes['uid'][0], 'posixGroup', array('dn'), array('group'));
for ($i = 0; $i < sizeof($groups); $i++) {

View file

@ -164,12 +164,11 @@ class posixGroup extends baseModule implements passwordService {
}
/**
* Checks if the group which should be deleted is still used as primary group.
*
* @return List of LDAP operations, same as for save_attributes()
* {@inheritDoc}
* @see baseModule::delete_attributes()
*/
function delete_attributes() {
$return = array();
function delete_attributes(): array {
$return = [];
$result = searchLDAPByFilter('(&(objectClass=posixAccount)(gidNumber=' . $this->attributes['gidNumber'][0] . '))', array('dn'), array('user', 'host'));
if (sizeof($result) > 0) {
$max = 5;

View file

@ -229,7 +229,6 @@ if (isset($_POST['delete'])) {
foreach ($moduleNames as $singlemodule) {
// load changes
$temp = $modules[$singlemodule]->delete_attributes();
if (is_array($temp)) {
// merge changes
$DNs = array_keys($temp);
$attributes = array_merge_recursive($temp, $attributes);
@ -243,7 +242,6 @@ if (isset($_POST['delete'])) {
}
}
}
}
$DNs = array_keys($attributes);
foreach ($DNs as $dn) {
if (isset($attributes[$dn]['errors'])) {

View file

@ -479,7 +479,6 @@ function dryRun(): array {
$tempFilesManager = new LamTemporaryFilesManager();
$fileName = $tempFilesManager->registerTemporaryFile('.ldif', 'ldif_');
$out = $tempFilesManager->openTemporaryFileForWrite($fileName);
if ($out !== false) {
fwrite($out, $ldif);
$container->addElement(new htmlOutputText(_('LDIF file')), true);
$ldifLink = new htmlLink($fileName, $tempFilesManager->getDownloadLink($fileName));
@ -490,7 +489,6 @@ function dryRun(): array {
$container->addElement(new htmlInputTextarea('log', $log, 100, 30), true);
// generate HTML
fclose ($out);
}
ob_start();
parseHtml(null, $container, array(), true, 'user');
$content = ob_get_contents();

View file

@ -1,6 +1,7 @@
<?php
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (RectorConfig $rectorConfig): void {