mirror of
https://github.com/LDAPAccountManager/lam.git
synced 2025-10-03 17:59:21 +02:00
refactoring
This commit is contained in:
parent
c3bd3c1762
commit
72f0ccf488
7 changed files with 43 additions and 49 deletions
|
@ -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 [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue