diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 3025c85b9..1562a2595 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -78,15 +78,15 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr /** lamdaemon servers */ private $lamdaemonServers = array(); /** cache for group objects */ - private $groupCache = null; + private $groupCache; /** cache for group of names objects */ - private $gonCache = null; + private $gonCache; /** clear text password */ private $clearTextPassword; /** caches the list of known UIDs */ - private $cachedUIDList = null; + private $cachedUIDList; /** caches the list of known user names */ - private $cachedUserNameList = null; + private $cachedUserNameList; /** replacements for common umlauts */ private $umlautReplacements = array( @@ -634,8 +634,7 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr for ($i = 0; $i < sizeof($gonList); $i++) { $userGoNs[] = $gonList[$i]['dn']; } - $userGoNs = array_values(array_unique($userGoNs)); - return $userGoNs; + return array_values(array_unique($userGoNs)); } /** @@ -1065,11 +1064,9 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr // lamdaemon results if (!empty($result)) { $singleresult = explode(",", $result); - if (is_array($singleresult)) { - if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { + if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { $return[] = $singleresult; } - } } } } @@ -1656,11 +1653,9 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr // lamdaemon results if (!empty($result)) { $singleresult = explode(",", $result); - if (is_array($singleresult)) { - if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { + if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { $return[] = $singleresult; } - } } } elseif (isset($_POST['form_subpage_' . get_class($this) . '_homedir_delete_' . $i])) { @@ -1687,11 +1682,9 @@ class posixAccount extends baseModule implements passwordService,AccountStatusPr // lamdaemon results if (!empty($result)) { $singleresult = explode(",", $result); - if (is_array($singleresult)) { - if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { + if (($singleresult[0] == 'ERROR') || ($singleresult[0] == 'WARN') || ($singleresult[0] == 'INFO')) { $return[] = $singleresult; } - } } } } diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index cc3b065b4..a5f7dc8a2 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -6,7 +6,7 @@ use LAM\TYPES\ConfiguredType; This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - 2007 - 2022 Roland Gruber + 2007 - 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 @@ -46,11 +46,11 @@ class posixGroup extends baseModule implements passwordService { /** password attribute */ protected $passwordAttrName = 'userPassword'; /** cache for existing GID numbers */ - private $cachedGIDList = null; + private $cachedGIDList; /** cache for existing users and their GIDs */ - private $cachedUserToGIDList = null; + private $cachedUserToGIDList; /** cache for existing groups */ - private $cachedGroupNameList = null; + private $cachedGroupNameList; /** * {@inheritDoc} @@ -864,18 +864,15 @@ class posixGroup extends baseModule implements passwordService { } } } - // $uids is always an array but not if no entries were found - if (is_array($gids)) { - // id-number is in use and account is a new account - if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]=='') { - $errors[] = $this->messages['gidNumber'][4]; - unset($this->attributes['gidNumber'][0]); - } - // id-number is in use, account is existing account and id-number is not used by itself - if ((in_array($this->attributes['gidNumber'][0], $gids)) && $this->orig['gidNumber'][0]!='' && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) { - $errors[] = $this->messages['gidNumber'][4]; - $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0]; - } + // id-number is in use and account is a new account + if ((in_array($this->attributes['gidNumber'][0], $gids)) && ($this->orig['gidNumber'][0] == '')) { + $errors[] = $this->messages['gidNumber'][4]; + unset($this->attributes['gidNumber'][0]); + } + // id-number is in use, account is existing account and id-number is changed + if ((in_array($this->attributes['gidNumber'][0], $gids)) && ($this->orig['gidNumber'][0] != '') && ($this->orig['gidNumber'][0] != $this->attributes['gidNumber'][0]) ) { + $errors[] = $this->messages['gidNumber'][4]; + $this->attributes['gidNumber'][0] = $this->orig['gidNumber'][0]; } } } @@ -1302,7 +1299,7 @@ class posixGroup extends baseModule implements passwordService { * @param ConfiguredType $type account type * @return array list of GID numbers */ - private function getGIDs($type) { + private function getGIDs(ConfiguredType $type): array { if ($this->cachedGIDList != null) { return $this->cachedGIDList; } diff --git a/lam/lib/modules/puppetClient.inc b/lam/lib/modules/puppetClient.inc index a0ef37b84..ae34d69ea 100644 --- a/lam/lib/modules/puppetClient.inc +++ b/lam/lib/modules/puppetClient.inc @@ -7,7 +7,7 @@ use LAM\TYPES\ConfiguredType; /* This code is not yet part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2012 - 2022 Roland Gruber + Copyright (C) 2012 - 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 @@ -41,9 +41,9 @@ use LAM\TYPES\ConfiguredType; class puppetClient extends baseModule { /** cache for classes */ - private $classCache = null; + private $classCache; /** cache for variables */ - private $variablesCache = null; + private $variablesCache; /** * Creates a new authorizedServiceObject object. @@ -430,9 +430,7 @@ class puppetClient extends baseModule { $possibleParentNodes = $this->getPossibleParentNodes(); array_unshift($possibleParentNodes, '-'); $possibleParentNodes = array_values($possibleParentNodes); - if (sizeof($possibleParentNodes) > 0) { - $return->add(new htmlResponsiveSelect('puppetClient_parentnode', $possibleParentNodes, array(), _('Parent node'), 'parentnode'), 12); - } + $return->add(new htmlResponsiveSelect('puppetClient_parentnode', $possibleParentNodes, array(), _('Parent node'), 'parentnode')); return $return; } @@ -470,7 +468,6 @@ class puppetClient extends baseModule { * @return array parent nodes (e.g. array('node1', 'node2')) */ private function getPossibleParentNodes() { - $possibleParentNodes = array(); $searchResult = searchLDAPByAttribute('cn', '*', 'puppetClient', array('cn'), array('host')); $possibleParentNodes = array(); for ($i = 0; $i < sizeof($searchResult); $i++) { diff --git a/lam/lib/modules/pykotaBillingCode.inc b/lam/lib/modules/pykotaBillingCode.inc index 271640233..dc951417e 100644 --- a/lam/lib/modules/pykotaBillingCode.inc +++ b/lam/lib/modules/pykotaBillingCode.inc @@ -2,7 +2,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2013 - 2022 Roland Gruber + Copyright (C) 2013 - 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 @@ -41,7 +41,7 @@ class pykotaBillingCode extends baseModule { const ATTRIBUTES_TO_IGNORE_ON_COPY = array('pykotaBalance', 'pykotaPageCounter', 'pykotaBillingCode'); /** cache for existing codes (array(dn1 => pykotaBillingCode1, dn2 => pykotaBillingCode2)) */ - private $codeCache = null; + private $codeCache; /** * Returns true if this module can manage accounts of the current type, otherwise false. diff --git a/lam/lib/modules/pykotaGroup.inc b/lam/lib/modules/pykotaGroup.inc index aca48ef63..400033b52 100644 --- a/lam/lib/modules/pykotaGroup.inc +++ b/lam/lib/modules/pykotaGroup.inc @@ -5,7 +5,7 @@ use \LAM\TYPES\TypeManager; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2013 - 2022 Roland Gruber + Copyright (C) 2013 - 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 @@ -42,9 +42,9 @@ class pykotaGroup extends baseModule { const ATTRIBUTES_TO_IGNORE_ON_COPY = array('pykotaGroupName'); /** cache for cn attribute */ - private $cnCache = null; + private $cnCache; /** cache for pykotaGroupName attribute */ - private $pykotaGroupNameCache = null; + private $pykotaGroupNameCache; /** list of limit options label => value */ private $limitOptions; diff --git a/lam/lib/modules/pykotaPrinter.inc b/lam/lib/modules/pykotaPrinter.inc index 2a373e00f..85f29d36b 100644 --- a/lam/lib/modules/pykotaPrinter.inc +++ b/lam/lib/modules/pykotaPrinter.inc @@ -2,7 +2,7 @@ /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2013 - 2022 Roland Gruber + Copyright (C) 2013 - 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 @@ -41,9 +41,9 @@ class pykotaPrinter extends baseModule { const ATTRIBUTES_TO_IGNORE_ON_COPY = array('pykotaPrinterName'); /** cache for existing printers (array(dn => array(cn => ..., description => ...))) */ - private $printerCache = null; + private $printerCache; /** printer group cache */ - private $groupCache = null; + private $groupCache; /** list of pass through options: label => value */ private $passThroughOptions; diff --git a/lam/lib/modules/pykotaUser.inc b/lam/lib/modules/pykotaUser.inc index a67864eca..0a01c47df 100644 --- a/lam/lib/modules/pykotaUser.inc +++ b/lam/lib/modules/pykotaUser.inc @@ -7,7 +7,7 @@ use \LAM\TYPES\TypeManager; /* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2013 - 2022 Roland Gruber + Copyright (C) 2013 - 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 @@ -45,9 +45,9 @@ class pykotaUser extends baseModule { 'pykotaPayments'); /** cache for uid attribute */ - private $uidCache = null; + private $uidCache; /** cache for pykotaUserName attribute */ - private $pykotaUserNameCache = null; + private $pykotaUserNameCache; /** list of limit options label => value */ private $limitOptions; diff --git a/lam/lib/modules/sambaGroupMapping.inc b/lam/lib/modules/sambaGroupMapping.inc index 826a36115..034f8c4cd 100644 --- a/lam/lib/modules/sambaGroupMapping.inc +++ b/lam/lib/modules/sambaGroupMapping.inc @@ -6,7 +6,7 @@ use \LAM\TYPES\TypeManager; This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - 2007 - 2022 Roland Gruber + 2007 - 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 @@ -52,9 +52,9 @@ class sambaGroupMapping extends baseModule { /** Array of sambaGroupTypes */ private $sambaGroupTypes; /** cache for domain list */ - private $cachedDomainList = null; + private $cachedDomainList; /** cache for existing Samba entries (array(dn => cn)) */ - private $sidCache = null; + private $sidCache; /** * Creates a new module for Samba 3 groups. diff --git a/lam/lib/modules/sambaSamAccount.inc b/lam/lib/modules/sambaSamAccount.inc index 93290212f..d09368fb1 100644 --- a/lam/lib/modules/sambaSamAccount.inc +++ b/lam/lib/modules/sambaSamAccount.inc @@ -79,11 +79,11 @@ class sambaSamAccount extends baseModule implements passwordService,AccountStatu /** specifies if the password should be expired */ private $expirePassword = false; /** host cache to reduce LDAP queries */ - private $cachedHostList = null; + private $cachedHostList; /** group cache to reduce LDAP queries */ - private $cachedGroupSIDList = null; + private $cachedGroupSIDList; /** cache for domain list */ - private $cachedDomainList = null; + private $cachedDomainList; /** delimiter for remote commands */ private static $SPLIT_DELIMITER = "###x##y##x###"; diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index 09eed6e27..021d923e7 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -77,32 +77,32 @@ class windowsUser extends baseModule implements passwordService,AccountStatusPro /** original group list */ private $groupList_orig = array(); /** cache for groups */ - private $groupCache = null; + private $groupCache; /** host cache to reduce LDAP queries */ - private $cachedHostList = null; + private $cachedHostList; /** option for forcing password change, used in postModifyActions */ - private $pwdLastSet = null; + private $pwdLastSet; /** clear text password */ private $clearTextPassword; /** cache for departments */ - private $departmentCache = null; + private $departmentCache; /** cache for department numbers */ - private $departmentNumberCache = null; + private $departmentNumberCache; /** 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; + private $businessCategoryCache; /** cache for user name */ - private $cachedUserNameList = null; + private $cachedUserNameList; /** cache for cn */ - private $cachedCnList = null; + private $cachedCnList; /** @@ -1638,11 +1638,9 @@ class windowsUser extends baseModule implements passwordService,AccountStatusPro switch ($mode) { case self::DISPLAY_GROUPS_CN: return $cn; - break; case self::DISPLAY_GROUPS_DN: default: return getAbstractDN($dn); - break; } } @@ -4945,7 +4943,7 @@ if (interface_exists('\LAM\JOB\Job', false)) { $now = new DateTime('now', getTimeZone()); $baseDate = $this->getBaseDate($now); $monthInterval = $this->getMonthInterval($options, $jobID); - if (!$this->shouldRun($pdo, $options, $jobID, $baseDate, $monthInterval)) { + if (!$this->shouldRun($pdo, $jobID, $baseDate, $monthInterval)) { $this->jobResultLog->logDebug('No run needed yet'); return; } @@ -4975,13 +4973,12 @@ if (interface_exists('\LAM\JOB\Job', false)) { * Returns if the job should run. * * @param $pdo PDO - * @param $options job options * @param $jobId job id * @param DateTime $baseDate base date * @param int $monthInterval month interval * @return bool should run */ - private function shouldRun(&$pdo, $options, $jobId, $baseDate, $monthInterval) { + private function shouldRun(&$pdo, $jobId, $baseDate, $monthInterval) { $dbLastChange = $this->getDBLastPwdChangeTime($jobId, $pdo, $jobId); if (empty($dbLastChange)) { return true;