YetiForceCompany/YetiForceCRM

View on GitHub
modules/Users/actions/SwitchUsers.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

Method process has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process(App\Request $request)
    {
        $db = \App\Db::getInstance('log');
        $currentUser = \App\User::getCurrentUserModel();
        $baseUserId = $currentUser->getId();
Severity: Minor
Found in modules/Users/actions/SwitchUsers.php - About 1 hr to fix

    Missing class import via use statement (line '37', column '14').
    Open

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'checkPermission'.
    Open

            $baseUserId = \App\User::getCurrentUserRealId();
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'checkPermission'.
    Open

                    'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

            App\Session::set('authenticated_user_id', $userId);
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

            if (empty(App\Session::get('baseUserId'))) {
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

                'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

            $newUser = \App\User::getUserModel($userId);
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

                $baseUserId = App\Session::get('baseUserId');
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'checkPermission'.
    Open

                $db = \App\Db::getInstance('log');
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'checkPermission'.
    Open

                    'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

            $currentUser = \App\User::getCurrentUserModel();
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'checkPermission'.
    Open

                    'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $baseUserId = App\Session::get('baseUserId');
            }
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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\TextUtils' in method 'process'.
    Open

                'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

                'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

            } elseif ($userId === App\Session::get('baseUserId')) {
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

                'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

            if ($request->has('visitPurpose') && \App\Config::security('askAdminAboutVisitSwitchUsers', true)) {
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

                    'baseid' => \App\User::getCurrentUserRealId()
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'checkPermission'.
    Open

                    'agent' => \App\TextUtils::textTruncate(\App\Request::_getServer('HTTP_USER_AGENT', '-'), 500, false),
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

            $db = \App\Db::getInstance('log');
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

            App\Session::set('full_user_name', $name);
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

                App\Session::set('baseUserId', '');
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

            App\Session::set('user_name', $newUser->getDetail('user_name'));
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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\CustomView' in method 'process'.
    Open

            \App\CustomView::resetCurrentView();
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'process'.
    Open

                App\Session::set('baseUserId', $baseUserId);
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 'OSSMail_Logout_Model' in method 'process'.
    Open

            OSSMail_Logout_Model::logoutCurrentUser();
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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_Module_Model' in method 'checkPermission'.
    Open

            $switchUsers = \Users_Module_Model::getSwitchUsers();
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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 "baseUserId" 5 times.
    Open

            if (empty(App\Session::get('baseUserId'))) {
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.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 "baseid" 3 times.
    Open

                    'baseid' => $baseUserId,
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.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 "Y-m-d H:i:s" 3 times.
    Open

                    'date' => date('Y-m-d H:i:s'),
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.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.

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

            $newUser = \App\User::getUserModel($userId);
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.php by phan

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

            $db->createCommand()->insert('l_#__switch_users', [
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.php by phan

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

                $db->createCommand()->insert('l_#__users_login_purpose', [
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.php by phan

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

                $db->createCommand()->insert('l_#__switch_users', [
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.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/actions/SwitchUsers.php by phan

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

            $currentUser = \App\User::getCurrentUserModel();
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.php by phan

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

                    'busername' => \App\User::getUserModel($baseUserId)->getName(),
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.php by phan

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

                    'baseid' => \App\User::getCurrentUserRealId()
    Severity: Critical
    Found in modules/Users/actions/SwitchUsers.php by phan

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

    class Users_SwitchUsers_Action extends \App\Controller\Action

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

                $db = \App\Db::getInstance('log');
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    The class Users_SwitchUsers_Action is not named in CamelCase.
    Open

    class Users_SwitchUsers_Action extends \App\Controller\Action
    {
        /**
         * Function checks permissions.
         *
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.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

    Avoid variables with short names like $db. Configured minimum length is 3.
    Open

            $db = \App\Db::getInstance('log');
    Severity: Minor
    Found in modules/Users/actions/SwitchUsers.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    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 checks permissions.

    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 \App\Request $request

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

        /**

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

            $userId = $request->getInteger('id');

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

                    'userid' => $userId,

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

                App\Session::set('baseUserId', '');

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

            header('location: index.php');

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

            $switchUsers = \Users_Module_Model::getSwitchUsers();

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

                    'baseid' => $baseUserId,

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

                    'busername' => \App\User::getUserModel($baseUserId)->getName(),

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

                    'dusername' => '',

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

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

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

            $db = \App\Db::getInstance('log');

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

                'dusername' => $name,

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

            $userId = $request->getInteger('id');

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

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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

        public function process(App\Request $request)

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

            $status = 'Switched';

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

                App\Session::set('baseUserId', $baseUserId);

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

                $baseUserId = $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

                    'baseid' => \App\User::getCurrentUserRealId()

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

            if ($userId != $baseUserId && (empty($switchUsers) || !\array_key_exists($userId, $switchUsers))) {

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

         * @throws \App\Exceptions\NoPermitted

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

         */

    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

                $status = 'Signed in';

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

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

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

        public function checkPermission(App\Request $request)

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

         * Function process.

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

                $status = 'Signed out';

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

            }

    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

                    'status' => 'Failed login - No permission',

    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\Session::set('user_name', $newUser->getDetail('user_name'));

    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

            if ($request->has('visitPurpose') && \App\Config::security('askAdminAboutVisitSwitchUsers', true)) {

    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

                'baseid' => $baseUserId,

    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

            OSSMail_Logout_Model::logoutCurrentUser();

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

                $db->createCommand()->insert('l_#__switch_users', [

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

                    'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),

    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

                    'destid' => $userId,

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

                $db->createCommand()->insert('l_#__users_login_purpose', [

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

                    'purpose' => $request->getByType('visitPurpose', \App\Purifier::TEXT),

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

            }

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

            $name = $newUser->getName();

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

            \App\CustomView::resetCurrentView();

    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 = $currentUser->getId();

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

                'ip' => \App\TextUtils::textTruncate(\App\RequestUtil::getRemoteIP(), 100, false),

    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

        }

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

         * @param \App\Request $request

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

                'destid' => $userId,

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

                'busername' => $currentUser->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

                $db = \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

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

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

            App\Session::set('authenticated_user_id', $userId);

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

            App\Session::set('full_user_name', $name);

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

            if (empty(App\Session::get('baseUserId'))) {

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

            } elseif ($userId === App\Session::get('baseUserId')) {

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

                $baseUserId = App\Session::get('baseUserId');

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

            $currentUser = \App\User::getCurrentUserModel();

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

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

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

            $db->createCommand()->insert('l_#__switch_users', [

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

                'status' => $status,

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

    class Users_SwitchUsers_Action extends \App\Controller\Action

    There are no issues that match your filters.

    Category
    Status