YetiForceCompany/YetiForceCRM

View on GitHub
modules/Users/models/Module.php

Summary

Maintainability
A
1 hr
Test Coverage
F
40%

Function getSwitchUsers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getSwitchUsers($showRole = false): array
    {
        require ROOT_DIRECTORY . '/user_privileges/switchUsers.php';
        $baseUserId = \App\User::getCurrentUserRealId();
        $users = [];
Severity: Minor
Found in modules/Users/models/Module.php - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Reduce the number of returns of this function 4, down to the maximum allowed 3.
Open

    public static function checkUserName($userName, $userId = false)
Severity: Major
Found in modules/Users/models/Module.php by sonar-php

Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

Noncompliant Code Example

With the default threshold of 3:

function myFunction(){ // Noncompliant as there are 4 return statements
  if (condition1) {
    return true;
  } else {
    if (condition2) {
      return false;
    } else {
      return true;
    }
  }
  return false;
}

Avoid using undefined variables such as '$switchUsers' which will lead to PHP notices.
Open

        if (isset($switchUsers[$baseUserId])) {
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid using undefined variables such as '$switchUsers' which will lead to PHP notices.
Open

            foreach ($switchUsers[$baseUserId] as $userId) {
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

The class Users_Module_Model has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
Open

class Users_Module_Model extends Vtiger_Module_Model
{
    /**
     * Function to get list view query for popup window.
     *
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

Missing class import via use statement (line '176', column '17').
Open

        $query = (new \App\Db\Query())->from('vtiger_users')->where(['email1' => $email]);
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Duplicated array key user_name, first declared at line 195.
Open

        $query = (new \App\Db\Query())->from('vtiger_users')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]]);
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

DuplicatedArrayKey

Defining another value for the same key in an array literal overrides the previous key/value, which makes it effectively an unused code. If it's known from the beginning that the key will have different value, there is usually no point in defining first one.

Example

function createArray() {
    return [
        'non-associative 0element', // not applied
        0 => 'associative 0-element', // applied
        false => 'associative 0-element', // applied
        'foo' => 'bar', // not applied
        "foo" => 'baz', // applied
    ];
}

Source http://phpmd.org/rules/cleancode.html#duplicatedarraykey

Duplicated array key user_name, first declared at line 202.
Open

        if ($userId && App\Config::module('Users', 'CHECK_LAST_USERNAME') && (new \App\Db\Query())->from('l_#__username_history')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]])->exists(\App\Db::getInstance('log'))) {
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

DuplicatedArrayKey

Defining another value for the same key in an array literal overrides the previous key/value, which makes it effectively an unused code. If it's known from the beginning that the key will have different value, there is usually no point in defining first one.

Example

function createArray() {
    return [
        'non-associative 0element', // not applied
        0 => 'associative 0-element', // applied
        false => 'associative 0-element', // applied
        'foo' => 'bar', // not applied
        "foo" => 'baz', // applied
    ];
}

Source http://phpmd.org/rules/cleancode.html#duplicatedarraykey

Missing class import via use statement (line '195', column '17').
Open

        $query = (new \App\Db\Query())->from('vtiger_users')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]]);
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method checkMailExist has a boolean flag argument $userId, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function checkMailExist($email, $userId = false)
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

The method getSwitchUsers has a boolean flag argument $showRole, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function getSwitchUsers($showRole = false): array
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Missing class import via use statement (line '131', column '19').
Open

        $loginId = (new \App\Db\Query())
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '155', column '15').
Open

        return (new \App\Db\Query())->from('vtiger_loginhistory')
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

The method checkUserName has a boolean flag argument $userId, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function checkUserName($userName, $userId = false)
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Missing class import via use statement (line '53', column '25').
Open

        $queryGenerator = new \App\QueryGenerator($this->getName());
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '202', column '77').
Open

        if ($userId && App\Config::module('Users', 'CHECK_LAST_USERNAME') && (new \App\Db\Query())->from('l_#__username_history')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]])->exists(\App\Db::getInstance('log'))) {
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid using static access to class 'App\User' in method 'saveLogoutHistory'.
Open

            $userRecordModel = Users_Record_Model::getInstanceById(App\User::getCurrentUserRealId(), 'Users');
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Session' in method 'getLoginHistory'.
Open

            ->where(['or', ['user_name' => \App\Session::get('user_name')], ['userid' => \App\Session::get('authenticated_user_id')]])
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Db' in method 'checkUserName'.
Open

        if ($userId && App\Config::module('Users', 'CHECK_LAST_USERNAME') && (new \App\Db\Query())->from('l_#__username_history')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]])->exists(\App\Db::getInstance('log'))) {
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Language' in method 'checkUserName'.
Open

            return \App\Language::translate('LBL_USER_NAME_HAS_ALREADY_BEEN_USED', 'Users');
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

The method saveLogoutHistory uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $userRecordModel = Users_Record_Model::getCurrentUserModel();
        }
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\App\Language' in method 'checkUserName'.
Open

            return \App\Language::translate('LBL_USER_NAME_EXISTS', 'Users');
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\TextUtils' in method 'saveLoginHistory'.
Open

                'user_ip' => empty($userIPAddress) ? '-' : \App\TextUtils::textTruncate($userIPAddress, 252, true),
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\TextUtils' in method 'saveLoginHistory'.
Open

                'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'Users_Record_Model' in method 'saveLogoutHistory'.
Open

            $userRecordModel = Users_Record_Model::getCurrentUserModel();
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\RequestUtil' in method 'saveLogoutHistory'.
Open

            ->where(['user_name' => $userRecordModel->get('user_name'), 'user_ip' => \App\RequestUtil::getRemoteIP()])
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\User' in method 'getSwitchUsers'.
Open

                    $userModel = \App\User::getUserModel($userId);
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'App\Cache' in method 'checkMailExist'.
Open

            return App\Cache::staticGet('Users_Module_Model::checkMailExist', $cacheKey);
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\User' in method 'getSwitchUsers'.
Open

        $baseUserId = \App\User::getCurrentUserRealId();
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\User' in method 'saveLoginHistory'.
Open

                'userid' => \App\User::getUserIdByName($userName),
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Request' in method 'saveLoginHistory'.
Open

                'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'App\Config' in method 'getLoginHistory'.
Open

            ->limit($limit ?: App\Config::performance('LOGIN_HISTORY_VIEW_LIMIT'))
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'App\Cache' in method 'checkMailExist'.
Open

        if (App\Cache::staticHas('Users_Module_Model::checkMailExist', $cacheKey)) {
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'App\Cache' in method 'checkMailExist'.
Open

        App\Cache::staticSave('Users_Module_Model::checkMailExist', $cacheKey, $exists);
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\RequestUtil' in method 'saveLoginHistory'.
Open

        $browser = \App\RequestUtil::getBrowserInfo();
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'Users_Record_Model' in method 'saveLogoutHistory'.
Open

            $userRecordModel = Users_Record_Model::getInstanceById(App\User::getCurrentUserRealId(), 'Users');
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Session' in method 'getLoginHistory'.
Open

            ->where(['or', ['user_name' => \App\Session::get('user_name')], ['userid' => \App\Session::get('authenticated_user_id')]])
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\Language' in method 'checkUserName'.
Open

            return \App\Language::translate('LBL_FORBIDDEN_USERNAMES', 'Users');
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'App\Field' in method 'getFieldsForSave'.
Open

        foreach (App\Field::getFieldsPermissions($this->getId(), false) as $field) {
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\RequestUtil' in method 'saveLoginHistory'.
Open

        $userIPAddress = \App\RequestUtil::getRemoteIP();
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'App\User' in method 'saveLogoutHistory'.
Open

        if (!empty(App\User::getCurrentUserRealId())) {
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class 'App\Config' in method 'checkUserName'.
Open

        if ($userId && App\Config::module('Users', 'CHECK_LAST_USERNAME') && (new \App\Db\Query())->from('l_#__username_history')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]])->exists(\App\Db::getInstance('log'))) {
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\App\User' in method 'getSwitchUsers'.
Open

                $userModel = \App\User::getUserModel($userId);
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Define a constant instead of duplicating this literal "index.php?module=" 3 times.
Open

        return 'index.php?module=' . $this->get('name') . '&parent=Settings&view=' . $this->getEditViewName();
Severity: Critical
Found in modules/Users/models/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "user_name" 9 times.
Open

                'user_name' => $userName,
Severity: Critical
Found in modules/Users/models/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "Users" 6 times.
Open

        if ('Users' === $sourceModule && 'reports_to_id' === $field && !empty($record)) {
Severity: Critical
Found in modules/Users/models/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "status" 3 times.
Open

            ->addCondition('status', 'Active', 'e')
Severity: Critical
Found in modules/Users/models/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "Users_Module_Model::checkMailExist" 3 times.
Open

        if (App\Cache::staticHas('Users_Module_Model::checkMailExist', $cacheKey)) {
Severity: Critical
Found in modules/Users/models/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "login_id" 3 times.
Open

            ->select(['login_id'])
Severity: Critical
Found in modules/Users/models/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "vtiger_loginhistory" 4 times.
Open

            ->insert('vtiger_loginhistory', [
Severity: Critical
Found in modules/Users/models/Module.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Avoid unused parameters such as '$recordModel'.
Open

    public function getFieldsForSave(Vtiger_Record_Model $recordModel)
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Call to undeclared method \App\Db\Query::from
Open

        $query = (new \App\Db\Query())->from('vtiger_users')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]]);
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to undeclared method \App\Db\Query::select
Open

        $loginId = (new \App\Db\Query())
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to method getCurrentUserRealId from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

            $userRecordModel = Users_Record_Model::getInstanceById(App\User::getCurrentUserRealId(), 'Users');
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to undeclared method \App\Db\Query::from
Open

        return (new \App\Db\Query())->from('vtiger_loginhistory')
Severity: Critical
Found in modules/Users/models/Module.php by phan

Argument 2 (readOnly) is false but \App\Field::getFieldsPermissions() takes \App\type|true defined at /code/app/Field.php:72
Open

        foreach (App\Field::getFieldsPermissions($this->getId(), false) as $field) {
Severity: Minor
Found in modules/Users/models/Module.php by phan

Call to undeclared method \App\Db::createCommand
Open

            \App\Db::getInstance()->createCommand()
Severity: Critical
Found in modules/Users/models/Module.php by phan

Returning type string but checkUserName() is declared to return bool
Open

            return \App\Language::translate('LBL_USER_NAME_EXISTS', 'Users');
Severity: Minor
Found in modules/Users/models/Module.php by phan

Parameter $queryGenerator has undeclared type \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

    public function getQueryByModuleField($sourceModule, $field, $record, App\QueryGenerator $queryGenerator)
Severity: Minor
Found in modules/Users/models/Module.php by phan

Call to undeclared method \App\Db::createCommand
Open

        \App\Db::getInstance()->createCommand()
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to method getUserIdByName from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

                'userid' => \App\User::getUserIdByName($userName),
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to method getCurrentUserRealId from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

        if (!empty(App\User::getCurrentUserRealId())) {
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to undeclared method \App\Db\Query::from
Open

        if ($userId && App\Config::module('Users', 'CHECK_LAST_USERNAME') && (new \App\Db\Query())->from('l_#__username_history')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]])->exists(\App\Db::getInstance('log'))) {
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to undeclared method \App\Db\Query::from
Open

        $query = (new \App\Db\Query())->from('vtiger_users')->where(['email1' => $email]);
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to method getColumnName from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

            ->addJoin(['INNER JOIN', $searchTableName, "{$queryGenerator->getColumnName('id')} = {$searchTableName}.id"])
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to method getCurrentUserRealId from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

        $baseUserId = \App\User::getCurrentUserRealId();
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $queryGenerator = new \App\QueryGenerator($this->getName());
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to method addCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

            $queryGenerator->addCondition('id', $srcRecord, 'n');
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to method getUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

                $userModel = \App\User::getUserModel($userId);
Severity: Critical
Found in modules/Users/models/Module.php by phan

Call to method addNativeCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

            $queryGenerator->addNativeCondition(['<>', 'vtiger_users.id', $record]);
Severity: Critical
Found in modules/Users/models/Module.php by phan

Return type of getQueryForRecords() is undeclared type \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

    public function getQueryForRecords(string $searchValue, int $limit, int $srcRecord = null): App\QueryGenerator
Severity: Minor
Found in modules/Users/models/Module.php by phan

Returning type string but checkUserName() is declared to return bool
Open

            return \App\Language::translate('LBL_USER_NAME_HAS_ALREADY_BEEN_USED', 'Users');
Severity: Minor
Found in modules/Users/models/Module.php by phan

Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
Open

        $queryGenerator->setFields(['id'])
Severity: Critical
Found in modules/Users/models/Module.php by phan

Returning type string but checkUserName() is declared to return bool
Open

            return \App\Language::translate('LBL_FORBIDDEN_USERNAMES', 'Users');
Severity: Minor
Found in modules/Users/models/Module.php by phan

Call to method getUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
Open

                    $userModel = \App\User::getUserModel($userId);
Severity: Critical
Found in modules/Users/models/Module.php by phan

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Users_Module_Model extends Vtiger_Module_Model

The class Users_Module_Model is not named in CamelCase.
Open

class Users_Module_Model extends Vtiger_Module_Model
{
    /**
     * Function to get list view query for popup window.
     *
Severity: Minor
Found in modules/Users/models/Module.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        return false;

Spaces must be used to indent lines; tabs are not allowed
Open

            ->setCustomColumn(['search_label' => $searchColumnName])

Spaces must be used to indent lines; tabs are not allowed
Open

            ->addJoin(['INNER JOIN', $searchTableName, "{$queryGenerator->getColumnName('id')} = {$searchTableName}.id"])

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string              $field          parent fieldname

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getQueryForRecords(string $searchValue, int $limit, int $srcRecord = null): App\QueryGenerator

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    public function saveLoginHistory(string $userName, string $status): void

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to store the logout history.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        if ('Users' === $sourceModule && 'reports_to_id' === $field && !empty($record)) {

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        $userIPAddress = \App\RequestUtil::getRemoteIP();

Spaces must be used to indent lines; tabs are not allowed
Open

        return true;

Line exceeds 120 characters; contains 121 characters
Open

            ->addJoin(['INNER JOIN', $searchTableName, "{$queryGenerator->getColumnName('id')} = {$searchTableName}.id"])

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string - url

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $status

Spaces must be used to indent lines; tabs are not allowed
Open

        $browser = \App\RequestUtil::getBrowserInfo();

Spaces must be used to indent lines; tabs are not allowed
Open

            $userRecordModel = Users_Record_Model::getInstanceById(App\User::getCurrentUserRealId(), 'Users');

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getQueryByModuleField($sourceModule, $field, $record, App\QueryGenerator $queryGenerator)

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isWorkflowSupported()

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return void

Spaces must be used to indent lines; tabs are not allowed
Open

            ])->execute();

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        return true;

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function returns the default column for Alphabetic search.

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

            $userRecordModel = Users_Record_Model::getCurrentUserModel();

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

            $queryGenerator->addNativeCondition(['<>', 'vtiger_users.id', $record]);

Spaces must be used to indent lines; tabs are not allowed
Open

            ->setLimit($limit);

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getCreateRecordUrl()

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to store the login history.

Spaces must be used to indent lines; tabs are not allowed
Open

            ->insert('vtiger_loginhistory', [

Spaces must be used to indent lines; tabs are not allowed
Open

                'user_name' => $userName,

Spaces must be used to indent lines; tabs are not allowed
Open

                'logout_time' => null,

Spaces must be used to indent lines; tabs are not allowed
Open

                'browser' => $browser->name . ' ' . $browser->ver,

Spaces must be used to indent lines; tabs are not allowed
Open

                'userid' => \App\User::getUserIdByName($userName),

Spaces must be used to indent lines; tabs are not allowed
Open

                'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        $searchColumnName = "{$searchTableName}.label";

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getAlphabetSearchField()

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            ->from('vtiger_loginhistory')

Spaces must be used to indent lines; tabs are not allowed
Open

            ->where(['user_name' => $userRecordModel->get('user_name'), 'user_ip' => \App\RequestUtil::getRemoteIP()])

Spaces must be used to indent lines; tabs are not allowed
Open

                    'logout_time' => date('Y-m-d H:i:s'),

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        $searchTableName = 'u_#__users_labels';

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string - url

Spaces must be used to indent lines; tabs are not allowed
Open

            ->select(['login_id'])

Spaces must be used to indent lines; tabs are not allowed
Open

            ->limit(1)->orderBy('login_id DESC')->scalar();

Spaces must be used to indent lines; tabs are not allowed
Open

        if (false !== $loginId) {

Spaces must be used to indent lines; tabs are not allowed
Open

                    'status' => 'Signed off',

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get list view query for popup window.

Spaces must be used to indent lines; tabs are not allowed
Open

        $queryGenerator = new \App\QueryGenerator($this->getName());

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($srcRecord) {

Spaces must be used to indent lines; tabs are not allowed
Open

        return 'last_name';

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        $loginId = (new \App\Db\Query())

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isUtilityActionEnabled()

Spaces must be used to indent lines; tabs are not allowed
Open

            $queryGenerator->addCondition('id', $srcRecord, 'n');

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!empty(App\User::getCurrentUserRealId())) {

Spaces must be used to indent lines; tabs are not allowed
Open

        } else {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

            \App\Db::getInstance()->createCommand()

Spaces must be used to indent lines; tabs are not allowed
Open

                ->update('vtiger_loginhistory', [

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string              $record         parent id

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            ->addCondition('status', 'Active', 'e')

Spaces must be used to indent lines; tabs are not allowed
Open

        return $queryGenerator;

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string columnname

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get the url for list view of the module.

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getListViewUrl()

Spaces must be used to indent lines; tabs are not allowed
Open

    public function saveLogoutHistory()

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

            ->addNativeCondition(['like', $searchColumnName, $searchValue])

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function to get the url for the Create Record view of the module.

Spaces must be used to indent lines; tabs are not allowed
Open

        return 'index.php?module=' . $this->get('name') . '&parent=Settings&view=' . $this->getListViewName();

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Db::getInstance()->createCommand()

Spaces must be used to indent lines; tabs are not allowed
Open

                'login_time' => date('Y-m-d H:i:s'),

Spaces must be used to indent lines; tabs are not allowed
Open

                'status' => $status,

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public function isCustomViewAdvCondEnabled(): bool

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        $queryGenerator->setFields(['id'])

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        return 'index.php?module=' . $this->get('name') . '&parent=Settings&view=' . $this->getEditViewName();

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                'user_ip' => empty($userIPAddress) ? '-' : \App\TextUtils::textTruncate($userIPAddress, 252, true),

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string              $sourceModule   Parent module

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param \App\QueryGenerator $queryGenerator

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $userName

Spaces must be used to indent lines; tabs are not allowed
Open

        return (new \App\Db\Query())->from('vtiger_loginhistory')

Spaces must be used to indent lines; tabs are not allowed
Open

            ->all();

Spaces must be used to indent lines; tabs are not allowed
Open

        if (App\Cache::staticHas('Users_Module_Model::checkMailExist', $cacheKey)) {

Spaces must be used to indent lines; tabs are not allowed
Open

        $query = (new \App\Db\Query())->from('vtiger_users')->where(['email1' => $email]);

Spaces must be used to indent lines; tabs are not allowed
Open

            $query->andWhere(['<>', 'id', $userId]);

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Line exceeds 120 characters; contains 134 characters
Open

            ->where(['or', ['user_name' => \App\Session::get('user_name')], ['userid' => \App\Session::get('authenticated_user_id')]])

Spaces must be used to indent lines; tabs are not allowed
Open

            ->orderBy(['login_id' => SORT_DESC])

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        if (isset($switchUsers[$baseUserId])) {

Spaces must be used to indent lines; tabs are not allowed
Open

                        'userName' => $userModel->getName(),

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string[]

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        $query = (new \App\Db\Query())->from('vtiger_users')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]]);

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($userId) {

Spaces must be used to indent lines; tabs are not allowed
Open

            return \App\Language::translate('LBL_USER_NAME_EXISTS', 'Users');

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($userId && App\Config::module('Users', 'CHECK_LAST_USERNAME') && (new \App\Db\Query())->from('l_#__username_history')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]])->exists(\App\Db::getInstance('log'))) {

Spaces must be used to indent lines; tabs are not allowed
Open

        if (\in_array(strtolower($userName), $blacklist)) {

Spaces must be used to indent lines; tabs are not allowed
Open

                    continue;

Spaces must be used to indent lines; tabs are not allowed
Open

                }

Spaces must be used to indent lines; tabs are not allowed
Open

                    $userModel = \App\User::getUserModel($userId);

Spaces must be used to indent lines; tabs are not allowed
Open

                        'roleName' => $userModel->getRoleName(),

Spaces must be used to indent lines; tabs are not allowed
Open

        return $editFields;

Spaces must be used to indent lines; tabs are not allowed
Open

        $cacheKey = "$email|$userId";

Spaces must be used to indent lines; tabs are not allowed
Open

            if ($showRole) {

Spaces must be used to indent lines; tabs are not allowed
Open

                ->execute();

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        App\Cache::staticSave('Users_Module_Model::checkMailExist', $cacheKey, $exists);

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get switch users.

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

        return $users;

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getFieldsForSave(Vtiger_Record_Model $recordModel)

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        $baseUserId = \App\User::getCurrentUserRealId();

Spaces must be used to indent lines; tabs are not allowed
Open

                if (empty($userModel->getId()) || !$userModel->isActive()) {

Spaces must be used to indent lines; tabs are not allowed
Open

                }

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return array

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function checkUserName($userName, $userId = false)

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($query->exists()) {

Line exceeds 120 characters; contains 250 characters
Open

        if ($userId && App\Config::module('Users', 'CHECK_LAST_USERNAME') && (new \App\Db\Query())->from('l_#__username_history')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]])->exists(\App\Db::getInstance('log'))) {

Spaces must be used to indent lines; tabs are not allowed
Open

                    ];

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getLoginHistory($limit = null): array

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

                $users[$userId] = $userId;

Spaces must be used to indent lines; tabs are not allowed
Open

     * Function gives list fields for save.

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param false|int $userId

Spaces must be used to indent lines; tabs are not allowed
Open

            return \App\Language::translate('LBL_FORBIDDEN_USERNAMES', 'Users');

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

            foreach ($switchUsers[$baseUserId] as $userId) {

Spaces must be used to indent lines; tabs are not allowed
Open

                $userModel = \App\User::getUserModel($userId);

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

                ], ['login_id' => $loginId])

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string    $email

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

        $exists = $query->exists();

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        $users = [];

Spaces must be used to indent lines; tabs are not allowed
Open

                    $row = [

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param false|int $userId

Spaces must be used to indent lines; tabs are not allowed
Open

        return $exists;

Line exceeds 120 characters; contains 142 characters
Open

        $query = (new \App\Db\Query())->from('vtiger_users')->where(['or', ['user_name' => $userName, 'user_name' => strtolower($userName)]]);

Spaces must be used to indent lines; tabs are not allowed
Open

            return \App\Language::translate('LBL_USER_NAME_HAS_ALREADY_BEEN_USED', 'Users');

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function getSwitchUsers($showRole = false): array

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param Vtiger_Record_Model $recordModel

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param int|null $limit

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string    $userName

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param bool $showRole

Spaces must be used to indent lines; tabs are not allowed
Open

        require ROOT_DIRECTORY . '/user_privileges/switchUsers.php';

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

     * Check mail exist.

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($userId) {

Spaces must be used to indent lines; tabs are not allowed
Open

     * Validation of user name.

Spaces must be used to indent lines; tabs are not allowed
Open

                foreach ($users as $userId => &$row) {

Spaces must be used to indent lines; tabs are not allowed
Open

        return 'index.php?module=' . $this->get('name') . '&view=' . $this->getListViewName() . '&parent=Settings';

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /**

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return bool

Spaces must be used to indent lines; tabs are not allowed
Open

        return false;

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            ->where(['or', ['user_name' => \App\Session::get('user_name')], ['userid' => \App\Session::get('authenticated_user_id')]])

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function checkMailExist($email, $userId = false)

Spaces must be used to indent lines; tabs are not allowed
Open

            return App\Cache::staticGet('Users_Module_Model::checkMailExist', $cacheKey);

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            $query->andWhere(['<>', 'id', $userId]);

Spaces must be used to indent lines; tabs are not allowed
Open

     *

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

                        'isAdmin' => $userModel->isAdmin(),

Spaces must be used to indent lines; tabs are not allowed
Open

    public function getDefaultUrl()

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

     */

Spaces must be used to indent lines; tabs are not allowed
Open

        $editFields = [];

Spaces must be used to indent lines; tabs are not allowed
Open

            $editFields[] = $field['fieldname'];

Spaces must be used to indent lines; tabs are not allowed
Open

     * Get user login history.

Spaces must be used to indent lines; tabs are not allowed
Open

            ->limit($limit ?: App\Config::performance('LOGIN_HISTORY_VIEW_LIMIT'))

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

        $blacklist = require 'config/username_blacklist.php';

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach (App\Field::getFieldsPermissions($this->getId(), false) as $field) {

Class name "Users_Module_Model" is not in camel caps format
Open

class Users_Module_Model extends Vtiger_Module_Model

There are no issues that match your filters.

Category
Status