YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/views/DashBoard.php

Summary

Maintainability
A
2 hrs
Test Coverage
D
61%

process accesses the super-global variable $_SESSION.
Open

    public function process(App\Request $request)
    {
        $viewer = $this->getViewer($request);
        $moduleName = $request->getModule();
        $currentDashboard = Vtiger_Widget_Model::getDashboardId($request);
Severity: Minor
Found in modules/Vtiger/views/DashBoard.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Method preProcessAjax has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function preProcessAjax(App\Request $request)
    {
        $viewer = $this->getViewer($request);
        $moduleName = $request->getModule();
        $sourceModule = $request->getByType('sourceModule', 2);
Severity: Minor
Found in modules/Vtiger/views/DashBoard.php - About 1 hr to fix

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

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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 '23', column '14').
    Open

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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 postProcess has a boolean flag argument $display, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function postProcess(App\Request $request, $display = true)
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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 preProcess has a boolean flag argument $display, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function preProcess(App\Request $request, $display = true)
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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

    Avoid using static access to class 'Vtiger_DashBoard_Model' in method 'preProcessAjax'.
    Open

            $dashBoardModel = Vtiger_DashBoard_Model::getInstance($moduleName);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_Widget_Model' in method 'preProcessAjax'.
    Open

            $currentDashboard = Vtiger_Widget_Model::getDashboardId($request);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_Privileges_Model' in method 'checkPermission'.
    Open

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_Privileges_Model' in method 'process'.
    Open

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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 preProcessAjax uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $widgets = [];
            }
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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

    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 {
                return;
            }
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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 'Vtiger_Module_Model' in method 'preProcessAjax'.
    Open

            $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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 preProcess uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $widgets = [];
            }
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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 'Settings_WidgetsManagement_Module_Model' in method 'preProcess'.
    Open

            $viewer->assign('DASHBOARD_TYPES', Settings_WidgetsManagement_Module_Model::getDashboardTypes());
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_DashBoard_Model' in method 'process'.
    Open

            $dashBoardModel = Vtiger_DashBoard_Model::getInstance($moduleName);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_Widget_Model' in method 'preProcess'.
    Open

            $currentDashboard = Vtiger_Widget_Model::getDashboardId($request);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_Module_Model' in method 'preProcess'.
    Open

            $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_Privileges_Model' in method 'preProcess'.
    Open

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_Privileges_Model' in method 'preProcessAjax'.
    Open

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_DashBoard_Model' in method 'preProcessAjax'.
    Open

            $viewer->assign('MODULES_WITH_WIDGET', 'Home' === $sourceModule ? Vtiger_DashBoard_Model::getModulesWithWidgets($sourceModule, $currentDashboard) : []);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_DashBoard_Model' in method 'preProcess'.
    Open

            $dashBoardModel = Vtiger_DashBoard_Model::getInstance($moduleName);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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 'Settings_WidgetsManagement_Module_Model' in method 'preProcessAjax'.
    Open

            $viewer->assign('DASHBOARD_TYPES', Settings_WidgetsManagement_Module_Model::getDashboardTypes());
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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_Widget_Model' in method 'process'.
    Open

            $currentDashboard = Vtiger_Widget_Model::getDashboardId($request);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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 "WIDGETS" 3 times.
    Open

            $viewer->assign('WIDGETS', $widgets);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.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 "dashboardId" 3 times.
    Open

            $dashBoardModel->set('dashboardId', $currentDashboard);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.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 getDashboardId from undeclared class \Vtiger_Widget_Model
    Open

            $currentDashboard = Vtiger_Widget_Model::getDashboardId($request);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Argument 1 (mixed) is 'Home' but \Users_Privileges_Model::hasModulePermission() takes int defined at /code/modules/Users/models/Privileges.php:101
    Open

            if ('Home' === $moduleName && !$userPrivilegesModel->hasModulePermission($moduleName)) {
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGETS', $widgets);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGETS', $widgets);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE_NAME', $moduleName);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('USER_PRIVILEGES_MODEL', $userPrivilegesModel);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE_MODEL', $moduleModel);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('WIDGETS', $widgets);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to method getDashboardId from undeclared class \Vtiger_Widget_Model
    Open

            $currentDashboard = Vtiger_Widget_Model::getDashboardId($request);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('CURRENT_DASHBOARD', $currentDashboard);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE_NAME', $moduleName);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to method getDashboardId from undeclared class \Vtiger_Widget_Model
    Open

            $currentDashboard = Vtiger_Widget_Model::getDashboardId($request);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULES_WITH_WIDGET', 'Home' === $sourceModule ? Vtiger_DashBoard_Model::getModulesWithWidgets($sourceModule, $currentDashboard) : []);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE_PERMISSION', $permission);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('DASHBOARD_TYPES', Settings_WidgetsManagement_Module_Model::getDashboardTypes());
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('SRC_MODULE_NAME', $sourceModule);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE_PERMISSION', $permission);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Returning type \App\Controller\View\Vtiger_CssScript_Model[] but getHeaderCss() is declared to return \Vtiger_CssScript_Model[]
    Open

            return array_merge(parent::getHeaderCss($request), $this->checkAndConvertCssStyles($headerCss));
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.php by phan

    Argument 1 (mixed) is string but \Users_Privileges_Model::hasModulePermission() takes int defined at /code/modules/Users/models/Privileges.php:101
    Open

            $permission = $userPrivilegesModel->hasModulePermission($moduleName);
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE_MODEL', $moduleModel);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('DASHBOARD_TYPES', Settings_WidgetsManagement_Module_Model::getDashboardTypes());
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('USER_PRIVILEGES_MODEL', $userPrivilegesModel);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('CURRENT_DASHBOARD', $currentDashboard);
    Severity: Critical
    Found in modules/Vtiger/views/DashBoard.php by phan

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        public function checkPermission(App\Request $request)
        {
            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
            $moduleName = $request->getModule();
            if ('Home' === $moduleName && !$userPrivilegesModel->hasModulePermission($moduleName)) {
    Severity: Major
    Found in modules/Vtiger/views/DashBoard.php and 1 other location - About 1 hr to fix
    modules/Vtiger/views/ShowWidget.php on lines 15..25

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 103.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    class Vtiger_DashBoard_View extends Vtiger_Index_View

    The class Vtiger_DashBoard_View is not named in CamelCase.
    Open

    class Vtiger_DashBoard_View extends Vtiger_Index_View
    {
        /** {@inheritdoc} */
        public function checkPermission(App\Request $request)
        {
    Severity: Minor
    Found in modules/Vtiger/views/DashBoard.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

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

            $viewer->assign('MODULE_NAME', $moduleName);

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

            parent::preProcess($request, false);

    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

            $viewer = $this->getViewer($request);

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

            if ('Home' === $moduleName && !$userPrivilegesModel->hasModulePermission($moduleName)) {

    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

        }

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

            if ($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

            $moduleModel = Vtiger_Module_Model::getInstance($moduleName);

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

            }

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

                $dashBoardModel->verifyDashboard($moduleName);

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

                $widgets = [];

    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

        public function checkPermission(App\Request $request)

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

                $sourceModule = $moduleName;

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

            $moduleModel = Vtiger_Module_Model::getInstance($moduleName);

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

            $viewer->assign('DASHBOARD_TYPES', Settings_WidgetsManagement_Module_Model::getDashboardTypes());

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

            if ('Home' !== $moduleName && !$userPrivilegesModel->hasModuleActionPermission($moduleName, 'Dashboard')) {

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

            $viewer->assign('USER_PRIVILEGES_MODEL', $userPrivilegesModel);

    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 profile permissions for Dashboards

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

            $dashBoardModel->set('dashboardId', $currentDashboard);

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

            }

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

            $viewer->assign('MODULES_WITH_WIDGET', 'Home' === $sourceModule ? Vtiger_DashBoard_Model::getModulesWithWidgets($sourceModule, $currentDashboard) : []);

    Line exceeds 120 characters; contains 160 characters
    Open

            $viewer->assign('MODULES_WITH_WIDGET', 'Home' === $sourceModule ? Vtiger_DashBoard_Model::getModulesWithWidgets($sourceModule, $currentDashboard) : []);

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

            $viewer->assign('WIDGETS', $widgets);

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

        {

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

            $viewer = $this->getViewer($request);

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

            if ($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

            $moduleName = $request->getModule();

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

                $dashBoardModel->verifyDashboard($moduleName);

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

            $viewer->assign('MODULE_MODEL', $moduleModel);

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

                $this->preProcessDisplay($request);

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

            $_SESSION['DashBoard'][$moduleName]['LastDashBoardId'] = $currentDashboard;

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

            $dashBoardModel = Vtiger_DashBoard_Model::getInstance($moduleName);

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

            $moduleName = $request->getModule();

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

            $sourceModule = $request->getByType('sourceModule', 2);

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

            $currentDashboard = Vtiger_Widget_Model::getDashboardId($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

        /** {@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

        public function process(App\Request $request)

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

            $viewer->assign('SRC_MODULE_NAME', $sourceModule);

    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

            if (empty($sourceModule)) {

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

        public function preProcess(App\Request $request, $display = true)

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

            $viewer->assign('MODULE_NAME', $moduleName);

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

        {

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

                $widgets = $dashBoardModel->getDashboards(0);

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

            $viewer->view('dashboards/DashBoardPreProcessAjax.tpl', $moduleName);

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

            $viewer->assign('CURRENT_DASHBOARD', $currentDashboard);

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

            $viewer->assign('USER_PRIVILEGES_MODEL', $userPrivilegesModel);

    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

            $dashBoardModel = Vtiger_DashBoard_Model::getInstance($moduleName);

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

            $moduleName = $request->getModule();

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

            $dashBoardModel = Vtiger_DashBoard_Model::getInstance($moduleName);

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

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

                $widgets = $dashBoardModel->getDashboards(0);

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

            $moduleName = $request->getModule();

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

            $permission = $userPrivilegesModel->hasModulePermission($moduleModel->getId());

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

            $viewer->assign('MODULE_PERMISSION', $permission);

    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

            }

    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

            $viewer = $this->getViewer($request);

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

            $currentDashboard = Vtiger_Widget_Model::getDashboardId($request);

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

            $currentDashboard = Vtiger_Widget_Model::getDashboardId($request);

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

            $viewer->assign('CURRENT_DASHBOARD', $currentDashboard);

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

            $viewer->assign('DASHBOARD_TYPES', Settings_WidgetsManagement_Module_Model::getDashboardTypes());

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

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

            return 'dashboards/DashBoardPreProcess.tpl';

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

            //check profile permissions for Dashboards

    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

                $widgets = [];

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

            $viewer->assign('MODULE_MODEL', $moduleModel);

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

            $permission = $userPrivilegesModel->hasModulePermission($moduleModel->getId());

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

        public function preProcessAjax(App\Request $request)

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

            $dashBoardModel->set('dashboardId', $currentDashboard);

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

            $viewer->assign('MODULE_PERMISSION', $permission);

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

            $viewer->assign('WIDGETS', $widgets);

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

            if ($display) {

    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

         * Function to get the list of Css models to be included.

    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 postProcess(App\Request $request, $display = 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

                '~libraries/gridstack/dist/gridstack-h5.js',

    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

            $moduleName = $request->getModule();

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

                '~layouts/resources/Calendar.js',

    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

         * Function to get the list of Script models to be included.

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

                '~libraries/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.js',

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

            $permission = $userPrivilegesModel->hasModulePermission($moduleName);

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

            $viewer->assign('WIDGETS', $widgets);

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

            parent::postProcess($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

            return array_merge(parent::getFooterScripts($request), $this->checkAndConvertJsScripts($jsFileNames));

    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

            $headerCss = [

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

                '~libraries/lodash/lodash.js',

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

         *

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

                '~libraries/gridstack/dist/gridstack.css',

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

            $viewer->view('dashboards/DashBoardContents.tpl', $moduleName);

    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 ($permission) {

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

                return;

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

            $jsFileNames = [

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

                'modules.Vtiger.resources.dashboards.Widget',

    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 function getHeaderCss(App\Request $request)

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

                $widgets = $dashBoardModel->getDashboards();

    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

                '~libraries/chart.js/dist/Chart.js',

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

                '~libraries/chartjs-plugin-funnel/dist/chart.funnel.js',

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

                'modules.Vtiger.resources.DashBoard',

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

                '~libraries/fullcalendar/main.js',

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

            $dashBoardModel->set('dashboardId', $currentDashboard);

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

        public function getFooterScripts(App\Request $request)

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

                '~libraries/css-element-queries/src/ResizeSensor.js',

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

         * @return Vtiger_CssScript_Model[]

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

            return array_merge(parent::getHeaderCss($request), $this->checkAndConvertCssStyles($headerCss));

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

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

    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 Vtiger_JsScript_Model[]

    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

                '~libraries/fullcalendar/main.css',

    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

                '~libraries/css-element-queries/src/ElementQueries.js',

    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 profile permissions for Dashboards

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

        }

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

                '~libraries/jquery-lazy/jquery.lazy.js',

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

                'modules.' . $moduleName . '.resources.DashBoard',

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

    class Vtiger_DashBoard_View extends Vtiger_Index_View

    There are no issues that match your filters.

    Category
    Status