diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index aaa936156..b5a521268 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -1268,10 +1268,10 @@ abstract class baseModule { *
* 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 []; } /** diff --git a/lam/lib/modules/nisNetGroupUser.inc b/lam/lib/modules/nisNetGroupUser.inc index 29acd9e33..273a89906 100644 --- a/lam/lib/modules/nisNetGroupUser.inc +++ b/lam/lib/modules/nisNetGroupUser.inc @@ -386,18 +386,17 @@ class nisNetGroupUser extends baseModule { } /** - * Additional LDAP operations on delete. - * - * @return List of LDAP operations, same as for save_attributes() - */ - function delete_attributes() { + * {@inheritDoc} + * @see baseModule::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); } diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index b15455b6b..3025c85b9 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -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() - */ - function delete_attributes() { - $return = array(); + * {@inheritDoc} + * @see baseModule::delete_attributes() + */ + 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++) { diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index 0108f1a66..cc3b065b4 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -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() - */ - function delete_attributes() { - $return = array(); + * {@inheritDoc} + * @see baseModule::delete_attributes() + */ + 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; diff --git a/lam/templates/delete.php b/lam/templates/delete.php index 9376df34a..50dd8f5e6 100644 --- a/lam/templates/delete.php +++ b/lam/templates/delete.php @@ -229,20 +229,18 @@ 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); - foreach ($DNs as $dn) { - $ops = array_keys($temp[$dn]); - foreach ($ops as $op) { - $attrs = array_keys($temp[$dn][$op]); - foreach ($attrs as $attribute) { - $attributes[$dn][$op][$attribute] = array_unique($attributes[$dn][$op][$attribute]); - } - } - } - } + // merge changes + $DNs = array_keys($temp); + $attributes = array_merge_recursive($temp, $attributes); + foreach ($DNs as $dn) { + $ops = array_keys($temp[$dn]); + foreach ($ops as $op) { + $attrs = array_keys($temp[$dn][$op]); + foreach ($attrs as $attribute) { + $attributes[$dn][$op][$attribute] = array_unique($attributes[$dn][$op][$attribute]); + } + } + } } $DNs = array_keys($attributes); foreach ($DNs as $dn) { diff --git a/lam/templates/tools/multiEdit.php b/lam/templates/tools/multiEdit.php index 8b63e2e1c..01b96d511 100644 --- a/lam/templates/tools/multiEdit.php +++ b/lam/templates/tools/multiEdit.php @@ -479,18 +479,16 @@ 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)); - $ldifLink->setTargetWindow('_blank'); - $container->addElement($ldifLink, true); - $container->addVerticalSpace('20px'); - $container->addElement(new htmlOutputText(_('Log output')), true); - $container->addElement(new htmlInputTextarea('log', $log, 100, 30), true); - // generate HTML - fclose ($out); - } + fwrite($out, $ldif); + $container->addElement(new htmlOutputText(_('LDIF file')), true); + $ldifLink = new htmlLink($fileName, $tempFilesManager->getDownloadLink($fileName)); + $ldifLink->setTargetWindow('_blank'); + $container->addElement($ldifLink, true); + $container->addVerticalSpace('20px'); + $container->addElement(new htmlOutputText(_('Log output')), true); + $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(); diff --git a/rector.php b/rector.php index 3265a2a4e..281700713 100644 --- a/rector.php +++ b/rector.php @@ -1,6 +1,7 @@