From bc3152c03a4f2aa661744389366bff3d512ff225 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 28 Dec 2018 11:19:15 +0100 Subject: [PATCH] refactoring --- lam/lib/account.inc | 6 +++--- lam/lib/ldap.inc | 2 +- lam/lib/modules.inc | 2 +- lam/lib/modules/asteriskVoicemail.inc | 2 +- lam/lib/modules/posixAccount.inc | 2 +- lam/lib/modules/shadowAccount.inc | 4 ++-- lam/lib/types/user.inc | 3 +-- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lam/lib/account.inc b/lam/lib/account.inc index 2705a0bf..d70c6d65 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -240,7 +240,7 @@ function generateSalt($len) { */ function pwd_enable($hash) { // check if password is disabled (old wrong LAM method) - if ((substr($hash, 0, 2) == "!{") || ((substr($hash, 0, 2) == "*{"))) { + if ((substr($hash, 0, 2) == "!{") || (substr($hash, 0, 2) == "*{")) { return substr($hash, 1, strlen($hash)); } // check for "!" or "*" at beginning of password hash @@ -269,7 +269,7 @@ function pwd_enable($hash) { */ function pwd_disable($hash) { // check if password is disabled (old wrong LAM method) - if ((substr($hash, 0, 2) == "!{") || ((substr($hash, 0, 2) == "*{"))) { + if ((substr($hash, 0, 2) == "!{") || (substr($hash, 0, 2) == "*{")) { return $hash; } // check for "!" or "*" at beginning of password hash @@ -316,7 +316,7 @@ function pwd_is_lockable($password) { */ function pwd_is_enabled($hash) { // disabled passwords have a "!" or "*" at the beginning (old wrong LAM method) - if ((substr($hash, 0, 2) == "!{") || ((substr($hash, 0, 2) == "*{"))) { + if ((substr($hash, 0, 2) == "!{") || (substr($hash, 0, 2) == "*{")) { return false; } if (substr($hash, 0, 1) == "{") { diff --git a/lam/lib/ldap.inc b/lam/lib/ldap.inc index 9be9804f..a307477d 100644 --- a/lam/lib/ldap.inc +++ b/lam/lib/ldap.inc @@ -156,7 +156,7 @@ class Ldap{ $dir = @opendir($tmpDir); $file = @readdir($dir); while ($file) { - if ((substr($file, -4) == '.tmp')) { + if (substr($file, -4) == '.tmp') { $path = $tmpDir . $file; if ($time - filemtime($path) > (3600 * 24)) { @unlink($path); diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index a9c51ddc..88ca0bfe 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1141,7 +1141,7 @@ class accountContainer { $pwdMailCheckbox->setTableRowsToShow(array('lamPasswordChangeSendMailAddress')); $container->addElement($pwdMailCheckbox); $container->addElement(new htmlHelpLink('407'), true); - if (($_SESSION['config']->getLamProMailAllowAlternateAddress() != 'false')) { + if ($_SESSION['config']->getLamProMailAllowAlternateAddress() != 'false') { $alternateMail = ''; $pwdResetModule = $this->getAccountModule('passwordSelfReset'); if (!empty($pwdResetModule)) { diff --git a/lam/lib/modules/asteriskVoicemail.inc b/lam/lib/modules/asteriskVoicemail.inc index b1d59dfd..095d64e1 100644 --- a/lam/lib/modules/asteriskVoicemail.inc +++ b/lam/lib/modules/asteriskVoicemail.inc @@ -324,7 +324,7 @@ class asteriskVoicemail extends baseModule implements passwordService { $errors[] = $this->messages['AstVoicemailMailbox'][1]; } // check for duplicate Voicemail ID - else if (!isset($this->orig['AstVoicemailMailbox'][0]) || (($this->orig['AstVoicemailMailbox'][0] != $this->attributes['AstVoicemailMailbox'][0]))) { + else if (!isset($this->orig['AstVoicemailMailbox'][0]) || ($this->orig['AstVoicemailMailbox'][0] != $this->attributes['AstVoicemailMailbox'][0])) { $entries = searchLDAPByAttribute('AstVoicemailMailbox', $this->attributes['AstVoicemailMailbox'][0], 'AstVoicemailMailbox', array('dn'), array('user')); if (sizeof($entries) > 0) { $errors[] = $this->messages['AstVoicemailMailbox'][2]; diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index 36cb94ce..0df19eef 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -2030,7 +2030,7 @@ class posixAccount extends baseModule implements passwordService { // login shell $return->add(new htmlResponsiveSelect('posixAccount_loginShell', $shelllist, array("/bin/bash"), _('Login shell'), 'loginShell'), 12); // lamdaemon settings - if (($_SESSION['config']->get_scriptPath() != null)) { + if ($_SESSION['config']->get_scriptPath() != null) { $return->add(new htmlSubTitle(_('Create home directory')), 12); $lamdaemonServers = explode(";", $_SESSION['config']->get_scriptServers()); for ($i = 0; $i < sizeof($lamdaemonServers); $i++) { diff --git a/lam/lib/modules/shadowAccount.inc b/lam/lib/modules/shadowAccount.inc index 05eeb866..939012a7 100644 --- a/lam/lib/modules/shadowAccount.inc +++ b/lam/lib/modules/shadowAccount.inc @@ -592,8 +592,8 @@ class shadowAccount extends baseModule implements passwordService { 'digit', $this->messages['shadowMax'][1], $messages); // minAge <= maxAge if ((($rawAccounts[$i][$ids['shadowAccount_minAge']] != '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] != '')) && // if at least one is set - (($rawAccounts[$i][$ids['shadowAccount_minAge']] == '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] == '') || ( // and one is not set - ($rawAccounts[$i][$ids['shadowAccount_minAge']] > $rawAccounts[$i][$ids['shadowAccount_maxAge']])))) { // or minAge > maxAge + (($rawAccounts[$i][$ids['shadowAccount_minAge']] == '') || ($rawAccounts[$i][$ids['shadowAccount_maxAge']] == '') || // and one is not set + ($rawAccounts[$i][$ids['shadowAccount_minAge']] > $rawAccounts[$i][$ids['shadowAccount_maxAge']]))) { // or minAge > maxAge $errMsg = $this->messages['shadow_cmp'][1]; array_push($errMsg, array($i)); $messages[] = $errMsg; diff --git a/lam/lib/types/user.inc b/lam/lib/types/user.inc index f830bfc2..88e2d53e 100644 --- a/lam/lib/types/user.inc +++ b/lam/lib/types/user.inc @@ -1,5 +1,4 @@