YetiForceCompany/YetiForceCRM

View on GitHub
app/PrivilegeFile.php

Summary

Maintainability
A
1 hr
Test Coverage
D
63%

Method createUserPrivilegesFile has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function createUserPrivilegesFile($userId)
    {
        $file = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'user_privileges' . \DIRECTORY_SEPARATOR . "user_privileges_$userId.php";
        $user = [];
        $userInstance = \CRMEntity::getInstance('Users');
Severity: Minor
Found in app/PrivilegeFile.php - About 1 hr to fix

    Function createUserPrivilegesFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function createUserPrivilegesFile($userId)
        {
            $file = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'user_privileges' . \DIRECTORY_SEPARATOR . "user_privileges_$userId.php";
            $user = [];
            $userInstance = \CRMEntity::getInstance('Users');
    Severity: Minor
    Found in app/PrivilegeFile.php - About 25 mins 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

    Missing class import via use statement (line '28', column '22').
    Open

            $dataReader = (new \App\Db\Query())->select(['id', 'first_name', 'last_name', 'is_admin', 'cal_color', 'status', 'email1', 'user_name', 'deleted'])->from('vtiger_users')->createCommand()->query();
    Severity: Minor
    Found in app/PrivilegeFile.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\Json' in method 'createUserPrivilegesFile'.
    Open

                $logo = Json::isEmpty($multiCompany->get('logo')) ? [] : current(Json::decode($multiCompany->get('logo')));
    Severity: Minor
    Found in app/PrivilegeFile.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 '\CRMEntity' in method 'createUserPrivilegesFile'.
    Open

            $userInstance = \CRMEntity::getInstance('Users');
    Severity: Minor
    Found in app/PrivilegeFile.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\Utils' in method 'createUserPrivilegesFile'.
    Open

            file_put_contents($file, 'return ' . Utils::varExport($user) . ';' . PHP_EOL, FILE_APPEND);
    Severity: Minor
    Found in app/PrivilegeFile.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\PrivilegeUtil' in method 'createUserPrivilegesFile'.
    Open

            $user['groups'] = PrivilegeUtil::getAllGroupsByUser($userId);
    Severity: Minor
    Found in app/PrivilegeFile.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\Purifier' in method 'createUserPrivilegesFile'.
    Open

                    $userInstance->column_fields[$field] = is_numeric($value) ? $value : \App\Purifier::encodeHtml($value);
    Severity: Minor
    Found in app/PrivilegeFile.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\PrivilegeUtil' in method 'createUserPrivilegesFile'.
    Open

            $userRoleInfo = PrivilegeUtil::getRoleDetail($userInstance->column_fields['roleid']);
    Severity: Minor
    Found in app/PrivilegeFile.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\Record' in method 'createUserPrivilegesFile'.
    Open

            if (Record::isExists($userRoleInfo['company'], 'MultiCompany')) {
    Severity: Minor
    Found in app/PrivilegeFile.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 '\Vtiger_Record_Model' in method 'createUserPrivilegesFile'.
    Open

                $multiCompany = \Vtiger_Record_Model::getInstanceById($userRoleInfo['company'], 'MultiCompany');
    Severity: Minor
    Found in app/PrivilegeFile.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\Utils' in method 'createUsersFile'.
    Open

            Utils::saveToFile(static::$usersFile, $users, '', 0, true);
    Severity: Minor
    Found in app/PrivilegeFile.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\PrivilegeUtil' in method 'createUserPrivilegesFile'.
    Open

            $user['leader'] = PrivilegeUtil::getGroupsWhereUserIsLeader($userId);
    Severity: Minor
    Found in app/PrivilegeFile.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\Module' in method 'createUserPrivilegesFile'.
    Open

    }
    Severity: Minor
    Found in app/PrivilegeFile.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\PrivilegeUtil' in method 'createUserPrivilegesFile'.
    Open

            $user['leadersByGroup'] = PrivilegeUtil::getLeadersGroupByUserId($userId);
    Severity: Minor
    Found in app/PrivilegeFile.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\Module' in method 'createUsersFile'.
    Open

            $entityData = Module::getEntityInfo('Users');
    Severity: Minor
    Found in app/PrivilegeFile.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\PrivilegeUtil' in method 'createUserPrivilegesFile'.
    Open

            $user['profiles'] = PrivilegeUtil::getProfilesByRole($userInstance->column_fields['roleid']);
    Severity: Minor
    Found in app/PrivilegeFile.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 createUserPrivilegesFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $user['multiCompanyId'] = null;
            }
    Severity: Minor
    Found in app/PrivilegeFile.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\Json' in method 'createUserPrivilegesFile'.
    Open

                $logo = Json::isEmpty($multiCompany->get('logo')) ? [] : current(Json::decode($multiCompany->get('logo')));
    Severity: Minor
    Found in app/PrivilegeFile.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 "Users" 4 times.
    Open

            $entityData = Module::getEntityInfo('Users');
    Severity: Critical
    Found in app/PrivilegeFile.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.

    Reference to undeclared property \CRMEntity->column_fields
    Open

            $user['profiles'] = PrivilegeUtil::getProfilesByRole($userInstance->column_fields['roleid']);
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

    Reference to undeclared property \CRMEntity->column_fields
    Open

                    $userInstance->column_fields[$field] = is_numeric($value) ? $value : \App\Purifier::encodeHtml($value);
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

    Reference to undeclared property \CRMEntity->column_fields
    Open

            $user['details'] = $userInstance->column_fields;
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

    Reference to undeclared property \CRMEntity->column_fields
    Open

                $displayName .= ' ' . $userInstance->column_fields[$field];
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

    Reference to undeclared property \CRMEntity->column_fields
    Open

            $userRoleInfo = PrivilegeUtil::getRoleDetail($userInstance->column_fields['roleid']);
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

    Reference to undeclared property \CRMEntity->column_fields
    Open

            foreach ($userInstance->column_fields as $field => $value) {
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

    Returning type false but getUser() is declared to return array
    Open

            return static::$usersFileCache[$type] ?? false;
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

    Reference to undeclared property \CRMEntity->is_admin
    Open

            $userInstance->column_fields['is_admin'] = 'on' === $userInstance->is_admin;
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

    Suspicious array access to false
    Open

            return static::$usersFileCache[$type] ?? false;
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

    Reference to undeclared property \CRMEntity->column_fields
    Open

            $userInstance->column_fields['is_admin'] = 'on' === $userInstance->is_admin;
    Severity: Minor
    Found in app/PrivilegeFile.php by phan

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

            $dataReader = (new \App\Db\Query())->select(['id', 'first_name', 'last_name', 'is_admin', 'cal_color', 'status', 'email1', 'user_name', 'deleted'])->from('vtiger_users')->createCommand()->query();
    Severity: Critical
    Found in app/PrivilegeFile.php by phan

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

        {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            foreach ($userInstance->column_fields as $field => $value) {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $dataReader = (new \App\Db\Query())->select(['id', 'first_name', 'last_name', 'is_admin', 'cal_color', 'status', 'email1', 'user_name', 'deleted'])->from('vtiger_users')->createCommand()->query();
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            // Get the id and the name.
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $userInstance->column_fields['is_admin'] = 'on' === $userInstance->is_admin;
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['parent_role_seq'] = $userRoleInfo['parentrole'];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['multiCompanyLogoUrl'] = $logo ? "file.php?module=MultiCompany&action=Logo&record={$userId}&key={$logo['key']}" : '';
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        /**
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

    Line exceeds 120 characters; contains 129 characters
    Open

            $file = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'user_privileges' . \DIRECTORY_SEPARATOR . "user_privileges_$userId.php";
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['displayName'] = trim($displayName);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                $multiCompany = \Vtiger_Record_Model::getInstanceById($userRoleInfo['company'], 'MultiCompany');
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                $user['multiCompanyId'] = null;
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['details'] = $userInstance->column_fields;
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

    Line exceeds 120 characters; contains 131 characters
    Open

            $user['multiCompanyLogoUrl'] = $logo ? "file.php?module=MultiCompany&action=Logo&record={$userId}&key={$logo['key']}" : '';
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        protected static $usersFile = 'user_privileges/users.php';
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        public static function createUsersFile()
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['leader'] = PrivilegeUtil::getGroupsWhereUserIsLeader($userId);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            } else {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $entityData = Module::getEntityInfo('Users');
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                $row['fullName'] = trim($fullName);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        public static function createUserPrivilegesFile($userId)
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $exclusionEncodeHtml = ['currency_symbol', 'date_format', 'currency_id', 'currency_decimal_separator', 'currency_grouping_separator', 'othereventduration', 'imagename'];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        protected static $usersFileCache = false;
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                $users['id'][$row['id']] = array_map('\App\Purifier::encodeHtml', $row);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         * @return array
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $userInstance->retrieveEntityInfo($userId, 'Users');
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $displayName = '';
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['profiles'] = PrivilegeUtil::getProfilesByRole($userInstance->column_fields['roleid']);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['multiCompanyLogo'] = $logo;
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $users = [];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            if (false === static::$usersFileCache) {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

    Line exceeds 120 characters; contains 177 characters
    Open

            $exclusionEncodeHtml = ['currency_symbol', 'date_format', 'currency_id', 'currency_decimal_separator', 'currency_grouping_separator', 'othereventduration', 'imagename'];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['leadersByGroup'] = PrivilegeUtil::getLeadersGroupByUserId($userId);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['roleName'] = $userRoleInfo['rolename'];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        /**
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            while ($row = $dataReader->read()) {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user = [];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                static::$usersFileCache = require static::$usersFile;
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                $displayName .= ' ' . $userInstance->column_fields[$field];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['groups'] = PrivilegeUtil::getAllGroupsByUser($userId);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $logo = null;
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

    Line exceeds 120 characters; contains 204 characters
    Open

            $dataReader = (new \App\Db\Query())->select(['id', 'first_name', 'last_name', 'is_admin', 'cal_color', 'status', 'email1', 'user_name', 'deleted'])->from('vtiger_users')->createCommand()->query();
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                    $fullName .= ' ' . $row[$field];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         * @param string $type
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        public static function getUser($type)
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            return static::$usersFileCache[$type] ?? false;
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $userRoleInfo = PrivilegeUtil::getRoleDetail($userInstance->column_fields['roleid']);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         * Create users privileges file.
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         */
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         *
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         * @param int $userId
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            foreach (Module::getEntityInfo('Users')['fieldnameArr'] as $field) {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $user['parent_roles'] = $userRoleInfo['parentRoles'];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                $fullName = '';
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            Utils::saveToFile(static::$usersFile, $users, '', 0, true);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        /**
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         * Creates a file with all the user, user-role,user-profile, user-groups informations.
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $userInstance = \CRMEntity::getInstance('Users');
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                    $userInstance->column_fields[$field] = is_numeric($value) ? $value : \App\Purifier::encodeHtml($value);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            file_put_contents($file, 'return ' . Utils::varExport($user) . ';' . PHP_EOL, FILE_APPEND);
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            $file = ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'user_privileges' . \DIRECTORY_SEPARATOR . "user_privileges_$userId.php";
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                $user['multiCompanyId'] = $multiCompany->getId();
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

        }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                foreach ($entityData['fieldnameArr'] as $field) {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                $users['userName'][$row['user_name']] = $row['id'];
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

         * get general users privileges file.
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                if (!\in_array($field, $exclusionEncodeHtml)) {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            }
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

            if (Record::isExists($userRoleInfo['company'], 'MultiCompany')) {
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

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

                $logo = Json::isEmpty($multiCompany->get('logo')) ? [] : current(Json::decode($multiCompany->get('logo')));
    Severity: Minor
    Found in app/PrivilegeFile.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status