Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Nov 2, 2023
1 parent 9f2868a commit 855c05d
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 162 deletions.
8 changes: 3 additions & 5 deletions lam/lib/modules/asteriskExtension.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use LAM\TYPES\ConfiguredType;
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2009 - 2012 Pavel Pozdniak
2009 - 2022 Roland Gruber
2009 - 2023 Roland Gruber
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
Expand Down Expand Up @@ -834,11 +834,10 @@ class asteriskExtension extends baseModule {
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskExtension_AstExtension', 'AstExtension');

$extensionName = $partialAccounts[$i]['AstExtension'];
$astPriorityTmp = 0;
if(isset ($extensionNamePriorityMap[$extensionName])){
if (isset($extensionNamePriorityMap[$extensionName])){
$astPriorityTmp = $extensionNamePriorityMap[$extensionName] + 1;
$extensionNamePriorityMap[$extensionName] = $astPriorityTmp;
}else{
} else {
$astPriorityTmp = 1;
$extensionNamePriorityMap[$extensionName] = $astPriorityTmp;
}
Expand Down Expand Up @@ -870,7 +869,6 @@ class asteriskExtension extends baseModule {
if ($this->isMoveToNewSuffix()) {
$oldDN = "cn=" . $rowOrig["cn"][0] . "," . extractDNSuffix($this->getAccountContainer()->dn_orig);
$newRDN = "cn=" . $rowOrig["cn"][0];
$is_rename_success = false;
$is_rename_success = @ldap_rename($_SESSION['ldap']->server(), $oldDN, $newRDN, $this->getAccountContainer()->dnSuffix, true);
if (!$is_rename_success) {
$errors[] = array('ERROR', sprintf(_('Was unable to rename DN: %s.'), $this->getAccountContainer()->dn_orig), getDefaultLDAPErrorString($_SESSION['ldap']->server()));
Expand Down
2 changes: 1 addition & 1 deletion lam/lib/modules/courierMailAlias.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
* Copyright (C) 2017 Lars Althof
* 2017 - 2022 Roland Gruber
* 2017 - 2023 Roland Gruber
*
* 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
Expand Down
6 changes: 1 addition & 5 deletions lam/lib/modules/ddns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2008 Thomas Manninger
2008 - 2022 Roland Gruber
2008 - 2023 Roland Gruber
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
Expand Down Expand Up @@ -234,8 +234,6 @@ class ddns extends baseModule {
* @return array list of info/error messages
*/
public function process_attributes() {
$errors = array();

// Main Settings and Account have to different processes.
if ($this->isRootNode()) {
// main settings:
Expand All @@ -246,10 +244,8 @@ class ddns extends baseModule {
if (!$this->check_if_ddns_is_enable()) {
return array();
}

$errors = $this->process_attributes_account();
}

return $errors;
}

Expand Down
6 changes: 3 additions & 3 deletions lam/lib/modules/fixed_ip.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use LAM\TYPES\ConfiguredType;
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2008 Thomas Manninger
2008 - 2022 Roland Gruber
2008 - 2023 Roland Gruber
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
Expand Down Expand Up @@ -60,10 +60,10 @@ class fixed_ip extends baseModule {
public $attributes;

/** cached host entries (list of array('cn' => ..., 'iphostnumber' => ..., 'macaddress' => ...)) */
private $hostCache = null;
private $hostCache;

/** cache for existing host entries */
private $existingDhcpHostsCache = null;
private $existingDhcpHostsCache;

/**
* Returns true if this module can manage accounts of the current type, otherwise false.
Expand Down
12 changes: 5 additions & 7 deletions lam/lib/modules/freeRadius.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class freeRadius extends baseModule {
);

/** cache for profile DNs */
private $profileCache = null;
private $profileCache;


/**
Expand Down Expand Up @@ -187,13 +187,11 @@ class freeRadius extends baseModule {
$profileElements[] = $profileSelect;
$return['profile_mappings']['freeRadius_radiusProfileDn'] = 'radiusProfileDn';
}
if (sizeof($profileElements) > 0) {
$profileContainer = new htmlResponsiveRow();
for ($i = 0; $i < sizeof($profileElements); $i++) {
$profileContainer->add($profileElements[$i], 12);
}
$return['profile_options'] = $profileContainer;
$profileContainer = new htmlResponsiveRow();
for ($i = 0; $i < sizeof($profileElements); $i++) {
$profileContainer->add($profileElements[$i], 12);
}
$return['profile_options'] = $profileContainer;
// upload fields
$return['upload_columns'] = array();
if (!$this->isBooleanConfigOptionSet('freeRadius_hideRadiusRealm')) {
Expand Down
10 changes: 5 additions & 5 deletions lam/lib/modules/imapAccess.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2010 - 2011 Pavel Pozdniak
2010 - 2020 Roland Gruber
2010 - 2023 Roland Gruber
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
Expand Down Expand Up @@ -43,7 +43,7 @@ class imapAccess extends baseModule {
const QUOTA_LIMIT = 'limit';

/** quota limit from profile */
private $profileQuotaLimit = null;
private $profileQuotaLimit;

/** user name */
private $user;
Expand Down Expand Up @@ -867,9 +867,9 @@ class imapAccess extends baseModule {
$attributes[$name] = array($value);
}
}
$extractErrors = $this->extractUserAndEmail($attributes);
if (!empty($extractErrors)) {
$errors = array_merge($errors, $extractErrors);
$extractError = $this->extractUserAndEmail($attributes);
if ($extractError !== null) {
$errors[] = $extractError;
}
$temp['users'][] = array(
'uid' => $this->user,
Expand Down
22 changes: 9 additions & 13 deletions lam/lib/modules/inetOrgPerson.inc
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,19 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP
const STATUS_PASSWORD_LOCKED = "INETORG_PERSON_PASSWORD_LOCKED";

/** clear text password */
private $clearTextPassword = null;
private $clearTextPassword;
/** cache for departments */
private $departmentCache = null;
private $departmentCache;
/** organization cache */
private $oCache = null;
private $oCache;
/** organizational unit cache */
private $ouCache = null;
private $ouCache;
/** title cache */
private $titleCache = null;
private $titleCache;
/** employee type cache */
private $employeeTypeCache = null;
private $employeeTypeCache;
/** business category cache */
private $businessCategoryCache = null;
/** cache for email duplication checks */
private $emailCheckCache = array();
private $businessCategoryCache;

/** session variable for existing user certificates in self service */
const SESS_CERTIFICATES_LIST = 'inetOrgPerson_certificatesList';
Expand Down Expand Up @@ -3353,7 +3351,7 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP
$jsonReturn = $this->ajaxDeleteSelfServiceUserCertificate($jsonInput);
}
elseif ($jsonInput['action'] == 'deletePhoto') {
$jsonReturn = $this->ajaxDeleteSelfServicePhoto($jsonInput);
$jsonReturn = $this->ajaxDeleteSelfServicePhoto();
}
}
echo json_encode($jsonReturn);
Expand Down Expand Up @@ -3437,10 +3435,8 @@ class inetOrgPerson extends baseModule implements passwordService,AccountStatusP

/**
* Manages the deletion of a photo.
*
* @param array $data JSON data
*/
private function ajaxDeleteSelfServicePhoto($data) {
private function ajaxDeleteSelfServicePhoto() {
$_SESSION[self::SESS_PHOTO] = null;
ob_start();
$contentElement = $this->getSelfServicePhoto(false, false);
Expand Down
2 changes: 1 addition & 1 deletion lam/lib/modules/kolabGroup.inc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use LAM\TYPES\TypeManager;
class kolabGroup extends baseModule {

/** cache for mail attribute */
private $mailCache = null;
private $mailCache;

/**
* Creates a new kolabGroup object.
Expand Down
1 change: 0 additions & 1 deletion lam/lib/modules/ldapPublicKey.inc
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ class ldapPublicKey extends baseModule {
* @return htmlJavaScript JS block
*/
private static function getSelfServiceKeysJSBlock() {
$keys = $_SESSION[self::SESS_KEY_LIST];
$content = '
function ldapPublicKeyDeleteKey(id) {
var actionJSON = {
Expand Down
7 changes: 3 additions & 4 deletions lam/lib/modules/nisMailAlias.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2004 - 2022 Roland Gruber
Copyright (C) 2004 - 2023 Roland Gruber
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
Expand Down Expand Up @@ -36,9 +36,9 @@ use LAM\TYPES\ConfiguredType;
class nisMailAlias extends baseModule {

/** mail cache */
private $cachedMailList = null;
private $cachedMailList;
/** user cache */
private $cachedUserList = null;
private $cachedUserList;
/** display limit */
const DISPLAY_LIMIT = 50;

Expand Down Expand Up @@ -343,7 +343,6 @@ class nisMailAlias extends baseModule {
* @return htmlElement meta HTML code
*/
function display_html_select($isMail) {
$options = array();
if ($isMail) {
$regex = 'email';
$options = $this->getMailList();
Expand Down
14 changes: 3 additions & 11 deletions lam/lib/modules/nisMailAliasUser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use \LAM\TYPES\TypeManager;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2014 - 2022 Roland Gruber
Copyright (C) 2014 - 2023 Roland Gruber
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
Expand Down Expand Up @@ -35,7 +35,7 @@ use \LAM\TYPES\TypeManager;
class nisMailAliasUser extends baseModule {

/** alias cache */
private $cachedAliasList = null;
private $cachedAliasList;

/** recipient entries to delete (list of arrays: dn => attributes) */
private $recipientsToDelete = array();
Expand Down Expand Up @@ -76,18 +76,10 @@ class nisMailAliasUser extends baseModule {
"Headline" => _("Alias names with user name"),
"Text" => _('Sets the alias names linked to the current user name.')
),
'aliasUserList' => array(
"Headline" => _("Alias names with user name"),
"Text" => _('Sets the alias names linked to the current user name.') . ' ' . _("Multiple values are separated by semicolon.")
),
'aliasMail' => array(
"Headline" => _("Alias names with email address"),
"Text" => _('Sets the alias names linked to the user\'s email address.')
),
'aliasUserList' => array(
"Headline" => _("Alias names with email address"),
"Text" => _('Sets the alias names linked to the user\'s email address.') . ' ' . _("Multiple values are separated by semicolon.")
),
'suffix' => array(
"Headline" => _("Suffix"),
"Text" => _("Location where new alias is stored.")
Expand Down Expand Up @@ -277,7 +269,7 @@ class nisMailAliasUser extends baseModule {
}
else {
$this->aliasesToAdd[$dn]['rfc822mailmember'] = array_values(array_delete(array($recipient), $this->aliasesToAdd[$dn]['rfc822mailmember']));
foreach ($this->cachedAliasList as $index => &$attrs) {
foreach ($this->cachedAliasList as &$attrs) {
if ($dn == $attrs['dn']) {
$attrs['rfc822mailmember'] = array_values(array_delete(array($recipient), $attrs['rfc822mailmember']));
}
Expand Down
7 changes: 3 additions & 4 deletions lam/lib/modules/nisNetGroupUser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use \LAM\TYPES\TypeManager;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2015 - 2019 Roland Gruber
Copyright (C) 2015 - 2023 Roland Gruber
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
Expand Down Expand Up @@ -43,9 +43,9 @@ class nisNetGroupUser extends baseModule {
/** list of NIS netgroups the user was memberOf (array(array(name => '', dn => '', host => '', domain => ''))) */
protected $groupsOrig = array();
/** group cache (array(array(cn => '', dn => '', nisnetgrouptriple => array()))) */
protected $groupCache = null;
protected $groupCache;
/** original uid */
protected $uidOrig = null;
protected $uidOrig;

/**
* Returns true if this module can manage accounts of the current type, otherwise false.
Expand Down Expand Up @@ -284,7 +284,6 @@ class nisNetGroupUser extends baseModule {
* @return String user ID
*/
protected function getUid() {
$moduleAttributes = array();
if ($this->getAccountContainer()->getAccountModule('posixAccount') != null) {
$moduleAttributes = $this->getAccountContainer()->getAccountModule('posixAccount')->getAttributes();
}
Expand Down
9 changes: 4 additions & 5 deletions lam/lib/modules/nisnetgroup.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use LAM\TYPES\ConfiguredType;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2022 Roland Gruber
Copyright (C) 2009 - 2023 Roland Gruber
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
Expand Down Expand Up @@ -41,11 +41,11 @@ class nisnetgroup extends baseModule {

/* caches to reduce LDAP queries */
/** user cache */
private $cachedUserList = null;
private $cachedUserList;
/** host cache */
private $cachedHostList = null;
private $cachedHostList;
/** group cache */
private $cachedGroupList = null;
private $cachedGroupList;

/**
* Returns true if this module can manage accounts of the current type, otherwise false.
Expand Down Expand Up @@ -459,7 +459,6 @@ class nisnetgroup extends baseModule {
break;
}
}
$options = array();
if ($selectHost) {
// load list with all hosts
$options = $this->getHostList();
Expand Down
Loading

0 comments on commit 855c05d

Please sign in to comment.