YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/Menu/models/Record.php

Summary

Maintainability
D
2 days
Test Coverage
F
40%

Function save has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

    public function save()
    {
        $db = \App\Db::getInstance();
        $settingsModel = Settings_Menu_Module_Model::getInstance();
        $edit = $this->get('edit');
Severity: Minor
Found in modules/Settings/Menu/models/Record.php - About 5 hrs 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

File Record.php has 347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Settings menu record model class.
 *
Severity: Minor
Found in modules/Settings/Menu/models/Record.php - About 4 hrs to fix

    The class Settings_Menu_Record_Model has 11 public methods. Consider refactoring Settings_Menu_Record_Model to keep number of public methods under 10.
    Open

    class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model
    {
        /**
         * Menu for Roles.
         */

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    The class Settings_Menu_Record_Model has an overall complexity of 85 which is very high. The configured complexity threshold is 50.
    Open

    class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model
    {
        /**
         * Menu for Roles.
         */

    Function parseToDisplay has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function parseToDisplay(array $menus): array
        {
            $userPrivilegesModel = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
            $data = [];
            foreach ($menus as $key => $item) {
    Severity: Minor
    Found in modules/Settings/Menu/models/Record.php - About 3 hrs 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

    Method save has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function save()
        {
            $db = \App\Db::getInstance();
            $settingsModel = Settings_Menu_Module_Model::getInstance();
            $edit = $this->get('edit');
    Severity: Major
    Found in modules/Settings/Menu/models/Record.php - About 2 hrs to fix

      Function createContentMenu has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function createContentMenu($menu)
          {
              unset($menu['filters']);
              $content = $menu['id'] . '=>[';
              foreach ($menu as $key => $item) {
      Severity: Minor
      Found in modules/Settings/Menu/models/Record.php - About 1 hr to fix

      Cognitive Complexity

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

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

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

      Further reading

      Method getChildMenu has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getChildMenu($roleId, $parent, int $source = 0)
          {
              $settingsModel = Settings_Menu_Module_Model::getInstance();
              $menu = [];
              $query = (new \App\Db\Query())->select(('yetiforce_menu.*, vtiger_tab.name'))
      Severity: Minor
      Found in modules/Settings/Menu/models/Record.php - About 1 hr to fix

        Function copyMenu has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function copyMenu($fromRole, $toRole, $roleId)
            {
                $db = \App\Db::getInstance();
                $menuData = (new \App\Db\Query())->from('yetiforce_menu')
                    ->where(['role' => $fromRole])
        Severity: Minor
        Found in modules/Settings/Menu/models/Record.php - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function removeMenu has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function removeMenu($ids)
            {
                $db = \App\Db::getInstance();
                if (!\is_array($ids)) {
                    $ids = [$ids];
        Severity: Minor
        Found in modules/Settings/Menu/models/Record.php - About 55 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

        The method save() has an NPath complexity of 260. The configured NPath complexity threshold is 200.
        Open

            public function save()
            {
                $db = \App\Db::getInstance();
                $settingsModel = Settings_Menu_Module_Model::getInstance();
                $edit = $this->get('edit');

        NPathComplexity

        Since: 0.1

        The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

        Example

        class Foo {
            function bar() {
                // lots of complicated code
            }
        }

        Source https://phpmd.org/rules/codesize.html#npathcomplexity

        The method save() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
        Open

            public function save()
            {
                $db = \App\Db::getInstance();
                $settingsModel = Settings_Menu_Module_Model::getInstance();
                $edit = $this->get('edit');

        CyclomaticComplexity

        Since: 0.1

        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

        Example

        // Cyclomatic Complexity = 11
        class Foo {
        1   public function example() {
        2       if ($a == $b) {
        3           if ($a1 == $b1) {
                        fiddle();
        4           } elseif ($a2 == $b2) {
                        fiddle();
                    } else {
                        fiddle();
                    }
        5       } elseif ($c == $d) {
        6           while ($c == $d) {
                        fiddle();
                    }
        7        } elseif ($e == $f) {
        8           for ($n = 0; $n < $h; $n++) {
                        fiddle();
                    }
                } else {
                    switch ($z) {
        9               case 1:
                            fiddle();
                            break;
        10              case 2:
                            fiddle();
                            break;
        11              case 3:
                            fiddle();
                            break;
                        default:
                            fiddle();
                            break;
                    }
                }
            }
        }

        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

        The method parseToDisplay() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
        Open

            public static function parseToDisplay(array $menus): array
            {
                $userPrivilegesModel = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
                $data = [];
                foreach ($menus as $key => $item) {

        CyclomaticComplexity

        Since: 0.1

        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

        Example

        // Cyclomatic Complexity = 11
        class Foo {
        1   public function example() {
        2       if ($a == $b) {
        3           if ($a1 == $b1) {
                        fiddle();
        4           } elseif ($a2 == $b2) {
                        fiddle();
                    } else {
                        fiddle();
                    }
        5       } elseif ($c == $d) {
        6           while ($c == $d) {
                        fiddle();
                    }
        7        } elseif ($e == $f) {
        8           for ($n = 0; $n < $h; $n++) {
                        fiddle();
                    }
                } else {
                    switch ($z) {
        9               case 1:
                            fiddle();
                            break;
        10              case 2:
                            fiddle();
                            break;
        11              case 3:
                            fiddle();
                            break;
                        default:
                            fiddle();
                            break;
                    }
                }
            }
        }

        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

        Refactor this function to reduce its Cognitive Complexity from 34 to the 15 allowed.
        Open

            public function save()

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed.
        Open

            public static function parseToDisplay(array $menus): array

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

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

                        $insertParams[$value] = $params[$key];

        UndefinedVariable

        Since: 2.8.0

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

        Example

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

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

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

                    $db->createCommand()->insert('yetiforce_menu', $insertParams)->execute();

        UndefinedVariable

        Since: 2.8.0

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

        Example

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

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

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

                $menuData = (new \App\Db\Query())->from('yetiforce_menu')

        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 '145', column '24').
        Open

                    $maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');

        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 '192', column '18').
        Open

                    $query = (new \App\Db\Query())->select(['id'])->from('yetiforce_menu')->where(['parentid' => $id]);

        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 saveSequence has a boolean flag argument $generate, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function saveSequence($data, $generate = false)

        BooleanArgumentFlag

        Since: 1.4.0

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

        Example

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

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

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

                $query = (new \App\Db\Query())->from('yetiforce_menu')->where(['id' => $id]);

        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 '105', column '16').
        Open

                            throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);

        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 '51', column '17').
        Open

                $query = (new \App\Db\Query())->select(['yetiforce_menu.*', 'vtiger_tab.name'])->from('yetiforce_menu')

        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 '127', column '16').
        Open

                            throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);

        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 '209', column '17').
        Open

                $query = (new \App\Db\Query())->select(('yetiforce_menu.*, vtiger_tab.name'))

        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\Db' in method 'save'.
        Open

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

        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_Menu_Module_Model' in method 'getChildMenu'.
        Open

                $settingsModel = Settings_Menu_Module_Model::getInstance();

        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 'generateFileMenu'.
        Open

                \App\Utils::saveToFile($file, $content);

        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_Menu_Module_Model' in method 'save'.
        Open

                $settingsModel = Settings_Menu_Module_Model::getInstance();

        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 assigning values to variables in if clauses and the like (line '254', column '48').
        Open

            public static function parseToDisplay(array $menus): array
            {
                $userPrivilegesModel = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
                $data = [];
                foreach ($menus as $key => $item) {

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

        Avoid using static access to class '\App\Module' in method 'parseToDisplay'.
        Open

                        if (!\App\Module::isModuleActive($item['mod']) || (!$userPrivilegesModel->isAdminUser() && !$userPrivilegesModel->hasGlobalReadPermission() && !$userPrivilegesModel->hasModulePermission($item['tabid']))) {

        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 'parseToDisplay'.
        Open

                $userPrivilegesModel = \Users_Privileges_Model::getCurrentUserPrivilegesModel();

        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_Menu_Module_Model' in method 'getAll'.
        Open

                $settingsModel = Settings_Menu_Module_Model::getInstance();

        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_Menu_Model' in method 'parseToDisplay'.
        Open

                    $item['name'] = Vtiger_Menu_Model::getLabelToDisplay($item);

        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 save uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                } else {
                    foreach ($this->getData() as $key => $item) {
                        if (!\in_array($key, $editFields)) {
                            throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);
                        }

        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_Menu_Model' in method 'getAll'.
        Open

                        'text' => Vtiger_Menu_Model::getLabelToDisplay($row),

        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 'parseToDisplay'.
        Open

                        if ('CustomFilter' === $item['type'] && (!($cvId = vtlib\Functions::getQueryParams($item['dataurl'])['viewname'] ?? '') || !\App\CustomView::isPermitted($cvId, $item['mod']))) {

        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 createContentMenu uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
        Open

                    } else {
                        $content .= var_export($key, true) . '=>' . \App\Utils::varExport($item) . ',';
                    }

        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\Db' in method 'saveSequence'.
        Open

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

        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 'removeMenu'.
        Open

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

        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 'createContentMenu'.
        Open

                        $content .= var_export($key, true) . '=>' . \App\Utils::varExport($item) . ',';

        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 '\vtlib\Functions' in method 'createFilterList'.
        Open

                    $params = \vtlib\Functions::getQueryParams($menu['dataurl']);

        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 'copyMenu'.
        Open

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

        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_Roles_Record_Model' in method 'refreshMenuFiles'.
        Open

                $allRoles = Settings_Roles_Record_Model::getAll();

        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 'vtlib\Functions' in method 'parseToDisplay'.
        Open

        }

        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_Roles_Record_Model' in method 'getRolesContainMenu'.
        Open

                $allRoles = Settings_Roles_Record_Model::getAll();

        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 "parentid" 14 times.
        Open

                        'parent' => 0 == $row['parentid'] ? '#' : $row['parentid'],

        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 "yetiforce_menu" 11 times.
        Open

                $query = (new \App\Db\Query())->select(['yetiforce_menu.*', 'vtiger_tab.name'])->from('yetiforce_menu')

        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 "filters" 7 times.
        Open

                    if (!isset($data['filters'])) {

        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 "childs" 9 times.
        Open

                        'childs' => $this->getChildMenu($roleId, $row['id'], $source),

        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 "countentries" 4 times.
        Open

                    if (!isset($data['countentries'])) {

        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 "sequence" 6 times.
        Open

                    $maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');

        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 "tabid" 4 times.
        Open

                        'tabid' => $row['module'],

        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 "parent" 3 times.
        Open

                        'parent' => 0 == $row['parentid'] ? '#' : $row['parentid'],

        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 "newwindow" 4 times.
        Open

                    if (!isset($data['newwindow'])) {

        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 "CustomFilter" 3 times.
        Open

                    if (\in_array($item['type'], ['QuickCreate', 'Module', 'HomeIcon', 'CustomFilter', 'RecycleBin'])) {

        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 "source" 5 times.
        Open

                    ->leftJoin('vtiger_tab', 'vtiger_tab.tabid = yetiforce_menu.module')->where(['role' => $roleId, 'source' => $source])->orderBy('yetiforce_menu.sequence, yetiforce_menu.parentid');

        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 "dataurl" 4 times.
        Open

                        'dataurl' => $settingsModel->getMenuUrl($row),

        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 "label" 3 times.
        Open

                        'label' => $row['label'],

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

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

        Noncompliant Code Example

        With the default threshold of 3:

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

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

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

        Avoid unused local variables such as '$value'.
        Open

                foreach ($allRoles as $roleId => $value) {

        UnusedLocalVariable

        Since: 0.2

        Detects when a local variable is declared and/or assigned, but not used.

        Example

        class Foo {
            public function doSomething()
            {
                $i = 5; // Unused
            }
        }

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

        Saw unextractable annotation for comment '* @return <integer> Id'</integer>
        Open

             * @return <Integer> Id

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

                    $db->createCommand()->update('yetiforce_menu', ['sequence' => $item['s'], 'parentid' => $item['p']], ['id' => $item['i']])->execute();
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

                    $maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

                $query = (new \App\Db\Query())->select(['yetiforce_menu.*', 'vtiger_tab.name'])->from('yetiforce_menu')
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

                    $db->createCommand()->insert('yetiforce_menu', $insertParams)->execute();
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

                    $db->createCommand()->delete('yetiforce_menu', ['id' => $id])->execute();
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

                    $db->createCommand()->update('yetiforce_menu', $params, ['id' => $this->getId()])->execute();
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

                        $db->createCommand()->insert('yetiforce_menu', $menuItem)->execute();
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

        Variable $insertParams was undeclared, but array fields are being added to it.
        Open

                        $insertParams[$value] = $params[$key];

        Suspicious array access to ?mixed
        Open

                    $role = $item['r'];

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

                $query = (new \App\Db\Query())->select(('yetiforce_menu.*, vtiger_tab.name'))
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

                $menuData = (new \App\Db\Query())->from('yetiforce_menu')
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

                    $query = (new \App\Db\Query())->select(['id'])->from('yetiforce_menu')->where(['parentid' => $id]);
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

                $query = (new \App\Db\Query())->from('yetiforce_menu')->where(['id' => $id]);
        Severity: Critical
        Found in modules/Settings/Menu/models/Record.php by phan

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

        class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model

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

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

        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

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

            public static function getInstanceById($id)

        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 Settings_Menu_Record_Model is not named in CamelCase.
        Open

        class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model
        {
            /**
             * Menu for Roles.
             */

        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();

        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

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

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

        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

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

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

        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

             * @param int $source

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

            }

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

                $query = (new \App\Db\Query())->from('yetiforce_menu')->where(['id' => $id]);

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

                $instance->setData($row);

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

             * Menu for Roles.

        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 getAll(int $roleId, int $source): array

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

                }

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

                $settingsModel = Settings_Menu_Module_Model::getInstance();

        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 const SRC_ROLE = 0;

        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

                $dataReader->close();

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

            public static function getCleanInstance()

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

            public function save()

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

            {

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

            public function getId()

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

             */

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

                $menu = [];

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

                    $row['type'] = (int) $row['type'];

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

                return $instance;

        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 $this->get('name');

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

             * @param int $roleId

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

            {

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

                    $menu[] = [

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

             * Menu for Api.

        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

                        'parent' => 0 == $row['parentid'] ? '#' : $row['parentid'],

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

                        'text' => Vtiger_Menu_Model::getLabelToDisplay($row),

        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 <Integer> Id

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

                    ->leftJoin('vtiger_tab', 'vtiger_tab.tabid = yetiforce_menu.module')->where(['role' => $roleId, 'source' => $source])->orderBy('yetiforce_menu.sequence, yetiforce_menu.parentid');

        Line exceeds 120 characters; contains 191 characters
        Open

                    ->leftJoin('vtiger_tab', 'vtiger_tab.tabid = yetiforce_menu.module')->where(['role' => $roleId, 'source' => $source])->orderBy('yetiforce_menu.sequence, yetiforce_menu.parentid');

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

                if ($edit) {

        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

                            case 'role':

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

                                break;

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

                    $maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');

        Line exceeds 120 characters; contains 133 characters
        Open

                    $maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');

        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

                    $db->createCommand()->delete('yetiforce_menu', ['id' => $id])->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

                        if (!\in_array($key, $editFields)) {

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

                    }

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

                    $this->generateFileMenu($role);

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

                    $dataReader->close();

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

                }

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

                        'sequence' => $row['sequence'],

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

                        'hotkey' => $row['hotkey'],

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

            {

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

                    foreach ($data as $key => $item) {

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

                        if (\is_array($item)) {

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

                    $db->createCommand()->update('yetiforce_menu', $params, ['id' => $this->getId()])->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

                        switch ($key) {

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

                    $max = (int) $maxSequence;

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

                    $sqlCol = explode(',', $sqlCol);

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

                }

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

                        $this->saveSequence($item['c'], false);

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

            /**

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

             * Function removes menu items.

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

                    while ($childId = $dataReader->readColumn(0)) {

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

            public function getChildMenu($roleId, $parent, int $source = 0)

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

                $query = (new \App\Db\Query())->select(('yetiforce_menu.*, vtiger_tab.name'))

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

            }

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

             *

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

             * @param int[] $ids

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

                    if (empty($id)) {

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

                    $row = [

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

                    $menu[] = $row;

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

            /**

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

             *

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

             * @return string Name

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

            public function getName()

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

             *

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

             * @return array

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

            }

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

                $instance = new self();

        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();

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

                        $params['newwindow'] = 0;

        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

                    foreach ($this->getData() as $key => $item) {

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

                            throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 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 (self::SRC_ROLE === $this->get('source')) {

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

             */

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

                }

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

                foreach ($ids as $id) {

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

                    $recordModel = self::getInstanceById($id);

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

                        $this->removeMenu($childId);

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

                        'mod' => $row['name'],

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

                        'parent' => $row['parentid'],

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

                        'countentries' => $row['countentries'],

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

             * Check permissions for display.

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

             * Function to get Id of this record instance.

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

             * Function to get Name of this record instance.

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

            {

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

                            $item = implode(',', $item);

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

                    $role = $item['r'];

        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();

        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 removeMenu($ids)

        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 (!\is_array($ids)) {

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

                        'id' => $row['id'],

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

                        continue;

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

                        'tabid' => $row['module'],

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

                        'childs' => $this->getChildMenu($roleId, $row['id'], $source),

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

                $dataReader = $query->createCommand()->query();

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

             *

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

            /**

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

            public static function parseToDisplay(array $menus): array

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

                foreach ($menus as $key => $item) {

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

                        if (!\App\Module::isModuleActive($item['mod']) || (!$userPrivilegesModel->isAdminUser() && !$userPrivilegesModel->hasGlobalReadPermission() && !$userPrivilegesModel->hasModulePermission($item['tabid']))) {

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

                            continue;

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

            /**

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

             */

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

                return $this->get('id');

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

            /**

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

             *

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

                return new self();

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

                $settingsModel = Settings_Menu_Module_Model::getInstance();

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

                $this->setData($data);

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

                $params = [];

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

                $query = (new \App\Db\Query())->select(['yetiforce_menu.*', 'vtiger_tab.name'])->from('yetiforce_menu')

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

                    if (!isset($data['filters'])) {

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

                        'id' => $row['id'],

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

                        $params['filters'] = '';

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

            public static function getInstanceById($id)

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

                        }

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

                        }

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

                                break;

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

             * Returns all items for menus.

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

                                $item = $settingsModel->getMenuTypeKey($item);

        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 (false === $row) {

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

                        $params[] = $item;

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

                    $db->createCommand()->update('yetiforce_menu', ['sequence' => $item['s'], 'parentid' => $item['p']], ['id' => $item['i']])->execute();

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

                $editFields = $settingsModel->getEditFields();

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

                    if (self::SRC_ROLE === $recordModel->get('source')) {

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

                if ($generate) {

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

                            $item = implode(',', $item);

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

            {

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

                $settingsModel = Settings_Menu_Module_Model::getInstance();

        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 ('id' != $key && 'edit' != $key) {

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

                    ->from('yetiforce_menu')

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

                        'type' => $settingsModel->getMenuTypes($row['type']),

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

            public function saveSequence($data, $generate = false)

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

            {

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

                    $query = (new \App\Db\Query())->select(['id'])->from('yetiforce_menu')->where(['parentid' => $id]);

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

                    $dataReader = $query->createCommand()->query();

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

                        'label' => $row['label'],

        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

            public const SRC_API = 1;

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

            }

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

                while ($row = $dataReader->read()) {

        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

                $row = $query->one();

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

                $sqlCol = '';

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

                            throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 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

                    $this->generateFileMenu($this->get('role'));

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

                foreach ($data as $item) {

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

                    ->orderBy(' yetiforce_menu.sequence', 'yetiforce_menu.parentid');

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

                while ($row = $dataReader->read()) {

        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

                        'icon' => 'menu-icon-' . $settingsModel->getMenuTypes($row['type']),

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

            public function initialize($data)

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

                $role = 0;

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

                    if (!isset($data['countentries'])) {

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

                        $sqlCol .= $key . ',';

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

                                break;

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

                    $sqlCol .= 'sequence';

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

                    foreach ($sqlCol as $key => $value) {

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

                $menu = [];

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

                $dataReader->close();

        Line exceeds 120 characters; contains 221 characters
        Open

                        if (!\App\Module::isModuleActive($item['mod']) || (!$userPrivilegesModel->isAdminUser() && !$userPrivilegesModel->hasGlobalReadPermission() && !$userPrivilegesModel->hasModulePermission($item['tabid']))) {

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

                $edit = $this->get('edit');

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

                        }

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

                    if (!isset($data['newwindow'])) {

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

                        if (!\in_array($key, $editFields)) {

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

                        if (\is_array($item)) {

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

                    $params[] = $max + 1;

        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();

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

                    ->where(['role' => $roleId, 'parentid' => $parent, 'source' => $source])

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

                        'newwindow' => $row['newwindow'],

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

                        'filters' => $row['filters'],

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

                return $menu;

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

             */

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

                            $params[$key] = $item;

        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->createCommand()->insert('yetiforce_menu', $insertParams)->execute();

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

                $role = 0;

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

                    }

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

                        'dataurl' => $settingsModel->getMenuUrl($row),

        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 (\in_array($item['type'], ['QuickCreate', 'Module', 'HomeIcon', 'CustomFilter', 'RecycleBin'])) {

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

                    $data = $this->getData();

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

                        $params['countentries'] = 0;

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

                            case 'type':

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

                }

        Line exceeds 120 characters; contains 146 characters
        Open

                    $db->createCommand()->update('yetiforce_menu', ['sequence' => $item['s'], 'parentid' => $item['p']], ['id' => $item['i']])->execute();

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

                    ->leftJoin('vtiger_tab', 'vtiger_tab.tabid = yetiforce_menu.module')

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

                        'icon' => $row['icon'],

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

             * @return array

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

                $data = [];

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

             *

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

                $dataReader = $query->createCommand()->query();

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

                }

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

                return $menu;

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

                    return false;

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

                                $role = $item = filter_var($item, FILTER_SANITIZE_NUMBER_INT);

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

                            default:

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

                        $insertParams[$value] = $params[$key];

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

                    if (isset($item['c'])) {

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

                }

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

                    $ids = [$ids];

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

                        $this->generateFileMenu($recordModel->get('role'));

        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 array $menus

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

                $content .= '];' . PHP_EOL . '$filterList = [';

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

                foreach ($menu as $key => $item) {

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

                        $menu[$counter]['roleName'] = $allRoles[$roleId]->get('rolename');

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

             * @param mixed $roleId

        Line exceeds 120 characters; contains 193 characters
        Open

                        if ('CustomFilter' === $item['type'] && (!($cvId = vtlib\Functions::getQueryParams($item['dataurl'])['viewname'] ?? '') || !\App\CustomView::isPermitted($cvId, $item['mod']))) {

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

                        $item['childs'] = self::parseToDisplay($item['childs']);

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

                    $data[$key] = $item;

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

            public function generateFileMenu($roleId)

        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

                        $menu[$counter]['roleId'] = $roleId;

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

             *

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

                    $related = [];

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

                    if ($item['childs']) {

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

                foreach ($menu as $item) {

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

                $content .= '];' . PHP_EOL . '$parentList = [';

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

                            $childs = var_export($key, true) . '=>[';

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

                            $content .= trim($childs, ',');

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

            public function createParentList($menu)

        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

                if (\count($menu['childs']) > 0) {

        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 $content;

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

             * A function used to refresh menu files.

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

                $counter = 0;

        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

                $menu = $this->getChildMenu($roleId, 0);

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

                foreach ($menu as $item) {

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

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

                        $menuItem['parentid'] = $related[$menuItem['parentid']] ?? $menuItem['parentid'];

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

                        $related[$menuId] = $db->getLastInsertID('yetiforce_menu_id_seq');

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

                    }

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

                    $this->generateFileMenu($toRole);

        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 ('CustomFilter' === $item['type'] && (!($cvId = vtlib\Functions::getQueryParams($item['dataurl'])['viewname'] ?? '') || !\App\CustomView::isPermitted($cvId, $item['mod']))) {

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

                }

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

                $roleId = filter_var($roleId, FILTER_SANITIZE_NUMBER_INT);

        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

                $content .= "'parent'=>" . var_export($menu['parent'], true) . ',';

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

                $content = '';

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

                    foreach ($menu['childs'] as $child) {

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

            {

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

                        $this->generateFileMenu($roleId);

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

                $menu = [];

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

                    }

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

                    ->where(['role' => $fromRole])

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

                            $menuId = key($diff);

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

                        }

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

                    $item['name'] = Vtiger_Menu_Model::getLabelToDisplay($item);

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

            public function createContentMenu($menu)

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

                    if ('childs' == $key && $item) {

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

                                $childs .= $this->createContentMenu($child);

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

                    $hasMenu = $this->getAll(filter_var($roleId, FILTER_SANITIZE_NUMBER_INT), static::SRC_ROLE);

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

             * @param int   $fromRole - Copy from role

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

                        if (isset($related[$menuId])) {

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

                        }

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

                    $content .= $this->createContentMenu($item);

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

                foreach ($allRoles as $role) {

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

            public static function getIcons()

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

            }

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

                            continue;

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

                }

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

                if (!empty($menu['filters'])) {

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

                    $params = \vtlib\Functions::getQueryParams($menu['dataurl']);

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

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

            public function copyMenu($fromRole, $toRole, $roleId)

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

                    foreach ($menuData as $menuId => $menuItem) {

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

                        $menuItem['source'] = ($roleId && false === strpos($roleId, 'H')) ? self::SRC_API : self::SRC_ROLE;

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

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

                            foreach ($item as $child) {

        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

                $content .= "'dataurl'=>" . var_export($menu['dataurl'], 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

                    $content .= "'module'=>" . var_export($menu['mod'], true) . ',';

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

                    if (file_exists('user_privileges/menu_' . $roleId . '.php')) {

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

                            continue;

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

                    }

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

            public function getRolesContainMenu()

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

            {

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

                        ++$counter;

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

            }

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

             * @param int   $toRole   - Copy to role

        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

                foreach ($allRoles as $roleId => $value) {

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

            /**

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

                        $menuItem['role'] = $toRole;

        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

                \App\Utils::saveToFile($file, $content);

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

                return trim($content, ',') . '],';

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

                $content .= "'label'=>" . var_export($menu['label'], true) . ',';

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

                if ('CustomFilter' === $menu['type']) {

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

            public function refreshMenuFiles()

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

             */

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

                $menuData = (new \App\Db\Query())->from('yetiforce_menu')

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

                            $diff = array_diff_key($menuData, $related);

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

                        $db->createCommand()->insert('yetiforce_menu', $menuItem)->execute();

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

                        if ('QuickCreate' === $item['type'] && (!Vtiger_Module_Model::getInstance($item['tabid'])->isQuickCreateSupported() || !$userPrivilegesModel->hasModuleActionPermission($item['tabid'], 'CreateView'))) {

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

                return $data;

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

                $content = '$menus = [';

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

            }

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

                $content = $menu['id'] . '=>[';

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

                    foreach ($menu['childs'] as $child) {

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

                    $content .= "'module'=>" . var_export($menu['mod'], true) . ',';

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

                    $roleId = str_replace('H', '', $role->getId());

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

                return ['yfm-VirtualDesk', 'fas fa-home', 'yfm-CompaniesAndContact', 'yfm-Campaigns', 'yfm-Support', 'yfm-Project', 'yfm-Bookkeeping', 'yfm-HumanResources', 'yfm-Secretary', 'yfm-Database', 'yfm-Sales', 'yfm-VendorsAccounts'];

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

            {

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

                }

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

                return $menu;

        Line exceeds 120 characters; contains 217 characters
        Open

                        if ('QuickCreate' === $item['type'] && (!Vtiger_Module_Model::getInstance($item['tabid'])->isQuickCreateSupported() || !$userPrivilegesModel->hasModuleActionPermission($item['tabid'], 'CreateView'))) {

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

                    }

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

                        $content .= var_export($key, true) . '=>' . \App\Utils::varExport($item) . ',';

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

                $content .= '],';

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

                        $content .= $this->createParentList($child);

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

                return $content;

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

            }

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

                    $content = $menu['id'] . '=>[';

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

                    $content .= "'filters'=>" . $params['viewname'] . '],';

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

                        $content .= $this->createFilterList($child);

        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

                $allRoles = Settings_Roles_Record_Model::getAll();

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

             * Function adds records to task queue that updates reviewing changes in records.

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

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

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

                    $content .= $this->createFilterList($item);

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

                $content .= '];' . PHP_EOL;

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

            {

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

                            $childs .= '],';

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

                $content .= "'type'=>" . var_export($menu['type'], true) . ',';

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

                            $menuItem = current($diff);

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

                            $menuId = $menuItem['parentid'];

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

                            $menuItem = $menuData[$menuId];

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

                $file = ROOT_DIRECTORY . '/user_privileges/menu_' . $roleId . '.php';

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

                $content = $menu['id'] . '=>[';

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

                }

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

            public function createFilterList($menu)

        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

                    $content .= $this->createParentList($item);

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

                foreach ($menu as $item) {

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

                unset($menu['filters']);

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

                        }

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

                $content .= "'mod'=>" . var_export($menu['mod'], true) . ',';

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

                if (\count($menu['childs']) > 0) {

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

                    $content = $menu['id'] . '=>[';

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

                    $content .= "'filters'=>" . var_export($menu['filters'], 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

                $allRoles = Settings_Roles_Record_Model::getAll();

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

                $this->generateFileMenu(0);

        Line exceeds 120 characters; contains 234 characters
        Open

                return ['yfm-VirtualDesk', 'fas fa-home', 'yfm-CompaniesAndContact', 'yfm-Campaigns', 'yfm-Support', 'yfm-Project', 'yfm-Bookkeeping', 'yfm-HumanResources', 'yfm-Secretary', 'yfm-Database', 'yfm-Sales', 'yfm-VendorsAccounts'];

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

            {

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

                    ->orderBy(['parentid' => SORT_ASC, 'sequence' => SORT_ASC])->createCommand()->queryAllByGroup(1);

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

                        if ($menuItem['parentid'] && !isset($related[$menuItem['parentid']])) {

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

        class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model

        There are no issues that match your filters.

        Category
        Status