YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
D
2 days
Test Coverage
D
68%

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

<?php
/* +***********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
Severity: Minor
Found in modules/Settings/Groups/models/Record.php - About 5 hrs to fix

    Settings_Groups_Record_Model has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Settings_Groups_Record_Model extends Settings_Vtiger_Record_Model
    {
        /** @var array Record changes */
        protected $changes = [];
    
    
    Severity: Minor
    Found in modules/Settings/Groups/models/Record.php - About 3 hrs to fix

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

      class Settings_Groups_Record_Model extends Settings_Vtiger_Record_Model
      {
          /** @var array Record changes */
          protected $changes = [];
      
      

      Function checkLoop has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public function checkLoop(): ?int
          {
              $error = null;
              $groupsDown = $allGroups = $this->getMembersByType(\App\PrivilegeUtil::MEMBER_TYPE_GROUPS);
              if (!$groupsDown) {
      Severity: Minor
      Found in modules/Settings/Groups/models/Record.php - About 2 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

      Function saveToDb has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public function saveToDb()
          {
              $db = \App\Db::getInstance('admin');
              $tablesData = $this->getId() ? array_intersect_key($this->getData(), $this->changes) : array_intersect_key($this->getData(), array_flip($this->getModule()->getEditableFields()));
              if ($tablesData) {
      Severity: Minor
      Found in modules/Settings/Groups/models/Record.php - About 2 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 getValuesToSave has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function getValuesToSave(array $data): array
          {
              $forSave = [];
              if (!$this->getId()) {
                  $forSave[$this->getModule()->baseTable][$this->getModule()->baseIndex] = \App\Db::getInstance('admin')->getUniqueId('vtiger_users');
      Severity: Minor
      Found in modules/Settings/Groups/models/Record.php - About 1 hr to fix

        Method checkLoop has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function checkLoop(): ?int
            {
                $error = null;
                $groupsDown = $allGroups = $this->getMembersByType(\App\PrivilegeUtil::MEMBER_TYPE_GROUPS);
                if (!$groupsDown) {
        Severity: Minor
        Found in modules/Settings/Groups/models/Record.php - About 1 hr to fix

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

              public function setDataFromRequest(App\Request $request)
              {
                  foreach ($this->getModule()->getEditableFields() as $fieldName) {
                      if ($request->has($fieldName)) {
                          switch ($fieldName) {
          Severity: Minor
          Found in modules/Settings/Groups/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 getValuesToSave has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getValuesToSave(array $data): array
              {
                  $forSave = [];
                  if (!$this->getId()) {
                      $forSave[$this->getModule()->baseTable][$this->getModule()->baseIndex] = \App\Db::getInstance('admin')->getUniqueId('vtiger_users');
          Severity: Minor
          Found in modules/Settings/Groups/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

          The method checkLoop() has an NPath complexity of 580. The configured NPath complexity threshold is 200.
          Open

              public function checkLoop(): ?int
              {
                  $error = null;
                  $groupsDown = $allGroups = $this->getMembersByType(\App\PrivilegeUtil::MEMBER_TYPE_GROUPS);
                  if (!$groupsDown) {

          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 checkLoop() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
          Open

              public function checkLoop(): ?int
              {
                  $error = null;
                  $groupsDown = $allGroups = $this->getMembersByType(\App\PrivilegeUtil::MEMBER_TYPE_GROUPS);
                  if (!$groupsDown) {

          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 19 to the 15 allowed.
          Open

              public function saveToDb()

          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 17 to the 15 allowed.
          Open

              public function checkLoop(): ?int

          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

          Class "Settings_Groups_Record_Model" has 31 methods, which is greater than 20 authorized. Split it into smaller classes.
          Open

          class Settings_Groups_Record_Model extends Settings_Vtiger_Record_Model

          A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

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

          class Settings_Groups_Record_Model extends Settings_Vtiger_Record_Model
          {
              /** @var array Record changes */
              protected $changes = [];
          
          

          CouplingBetweenObjects

          Since: 1.1.0

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

          Example

          class Foo {
              /**
               * @var \foo\bar\X
               */
              private $x = null;
          
              /**
               * @var \foo\bar\Y
               */
              private $y = null;
          
              /**
               * @var \foo\bar\Z
               */
              private $z = null;
          
              public function setFoo(\Foo $foo) {}
              public function setBar(\Bar $bar) {}
              public function setBaz(\Baz $baz) {}
          
              /**
               * @return \SplObjectStorage
               * @throws \OutOfRangeException
               * @throws \InvalidArgumentException
               * @throws \ErrorException
               */
              public function process(\Iterator $it) {}
          
              // ...
          }

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

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

                          throw new \App\Exceptions\AppException($errorLabel);

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

                          $groupsDown = (new App\Db\Query())->select(['containsgroupid'])->from('vtiger_group2grouprel')->where(['groupid' => $groupsDown])->column();

          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 '137', column '26').
          Open

                      $memberInstance = new Settings_Groups_Member_Model();

          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 '452', column '22').
          Open

                  $dataReader = (new App\Db\Query())->from('vtiger_groups')->createCommand()->query();

          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 '497', column '23').
          Open

                      $dataReader = (new App\Db\Query())->from('vtiger_groups')->where(['groupname' => $value])->createCommand()->query();

          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 '495', column '23').
          Open

                      $dataReader = (new App\Db\Query())->from('vtiger_groups')->where(['groupid' => $value])->createCommand()->query();

          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 '410', column '23').
          Open

                  $eventHandler = new App\EventHandler();

          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 '164', column '21').
          Open

                          $modules = (new App\Db\Query())->select(['vtiger_group2modules.tabid'])->from('vtiger_group2modules')->where(['vtiger_group2modules.groupid' => $this->getId()])

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

                  $query = new App\Db\Query();

          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 '603', column '22').
          Open

                          $groupsUp = (new App\Db\Query())->select(['groupid'])->from('vtiger_group2grouprel')->where(['containsgroupid' => $groupsUp])->column();

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

              public function save()
              {
                  $db = App\Db::getInstance('admin');
                  $transaction = $db->beginTransaction();
                  try {

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

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

          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\Fields\Owner' in method 'getLeaderUsers'.
          Open

                      if ('Users' === \App\Fields\Owner::getType($leader)) {

          StaticAccess

          Since: 1.4.0

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

          Example

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

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

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

                  \App\Cache::staticSave($cacheName, $key, $instance);

          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_Vtiger_Module_Model' in method 'getCleanInstance'.
          Open

                  $moduleInstance = Settings_Vtiger_Module_Model::getInstance('Settings:Groups');

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

                      } else {
                          unset($members[$key]);
                      }

          ElseExpression

          Since: 1.4.0

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

          Example

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

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

          Avoid using static access to class 'Settings_Groups_Member_Model' in method 'getMemberId'.
          Open

                  return Settings_Groups_Member_Model::getQualifiedId(Settings_Groups_Member_Model::MEMBER_TYPE_GROUPS, $this->getId());

          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 '241', column '10').
          Open

              public function saveToDb()
              {
                  $db = \App\Db::getInstance('admin');
                  $tablesData = $this->getId() ? array_intersect_key($this->getData(), $this->changes) : array_intersect_key($this->getData(), array_flip($this->getModule()->getEditableFields()));
                  if ($tablesData) {

          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\Config' in method 'recalculate'.
          Open

                  $php_max_execution_time = \App\Config::main('php_max_execution_time');

          StaticAccess

          Since: 1.4.0

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

          Example

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

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

          Avoid using static access to class '\App\PrivilegeUtil' in method 'getLeaderUsers'.
          Open

                          $users = \App\PrivilegeUtil::getUsersByGroup($leader);

          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\Fields\Owner' in method 'transferOwnership'.
          Open

                  App\Fields\Owner::transferOwnership($groupId, $transferGroupId);

          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\Utils' in method 'getInstance'.
          Open

                  if (vtlib\Utils::isNumber($value)) {

          StaticAccess

          Since: 1.4.0

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

          Example

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

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

          Avoid using static access to class '\App\PrivilegeUtil' in method 'delete'.
          Open

                  \App\PrivilegeUtil::deleteRelatedSharingRules($groupId, 'Groups');

          StaticAccess

          Since: 1.4.0

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

          Example

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

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

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

                  \App\Cache::clear();

          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_Groups_Member_Model' in method 'getInstance'.
          Open

                      $data['members'] = $instance->getFieldInstanceByName('members')->getDBValue(Settings_Groups_Member_Model::getAllByTypeForGroup($data['groupid']));

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

                          } else {
                              $db->createCommand()->delete($tableName, ['groupid' => $this->getId()])->execute();
                              if ($names = $tableData['names'] ?? []) {
                                  $values = $tableData['values'] ?? [];
                                  foreach ($values as &$value) {

          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\UserPrivilegesFile' in method 'recalculate'.
          Open

                      \App\UserPrivilegesFile::createUserPrivilegesfile($userId);

          StaticAccess

          Since: 1.4.0

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

          Example

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

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

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

                  if (\App\Cache::staticHas($cacheName, $key)) {

          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_Link_Model' in method 'getRecordLinks'.
          Open

                      $links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink);

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

                  } else {
                      $error = $this->checkLoop();
                  }

          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\Cache' in method 'getCleanInstance'.
          Open

                      return \App\Cache::staticGet($cacheName, $key);

          StaticAccess

          Since: 1.4.0

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

          Example

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

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

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

                  \App\Cache::clear();

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

                      } else {
                          $users = \App\PrivilegeUtil::getUsersByGroup($leader);
                      }

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

                      \App\Log::error($ex->__toString());

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

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

          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 '321', column '22').
          Open

              public function setDataFromRequest(App\Request $request)
              {
                  foreach ($this->getModule()->getEditableFields() as $fieldName) {
                      if ($request->has($fieldName)) {
                          switch ($fieldName) {

          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

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

                  } else {
                      $dataReader = (new App\Db\Query())->from('vtiger_groups')->where(['groupname' => $value])->createCommand()->query();
                  }

          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

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

                  foreach ($this->getFieldInstanceByName('members')->getEditViewDisplayValue($this->get('members') ?? '') as $member) {

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

                          $this->getLeaderUsers($this->getPreviousValue('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 "groupname" 4 times.
          Open

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

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

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

          Noncompliant Code Example

          With the default threshold of 3:

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

          Compliant Solution

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

          Exceptions

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

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

                                  \App\PrivilegeUtil::MEMBER_TYPE_GROUPS => ['table' => 'vtiger_group2grouprel', 'memberColumn' => 'containsgroupid', 'groupColumn' => 'groupid'],

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

                                  $values = $tableData['values'] ?? [];

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

                  if ($this->isEmpty('modules')) {

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

                              if ($names = $tableData['names'] ?? []) {

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

                                  \App\PrivilegeUtil::MEMBER_TYPE_USERS => ['table' => 'vtiger_users2group', 'memberColumn' => 'userid', 'groupColumn' => 'groupid'],

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

                                  \App\PrivilegeUtil::MEMBER_TYPE_USERS => ['table' => 'vtiger_users2group', 'memberColumn' => 'userid', 'groupColumn' => 'groupid'],

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

                                  \App\PrivilegeUtil::MEMBER_TYPE_GROUPS => ['table' => 'vtiger_group2grouprel', 'memberColumn' => 'containsgroupid', 'groupColumn' => 'groupid'],

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

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

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

                  return (int) $this->get('groupid');

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

                                  \App\PrivilegeUtil::MEMBER_TYPE_USERS => ['table' => 'vtiger_users2group', 'memberColumn' => 'userid', 'groupColumn' => 'groupid'],

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

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

          Noncompliant Code Example

          With the default threshold of 3:

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

          Compliant Solution

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

          Exceptions

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

          Define a constant instead of duplicating this literal "vtiger_groups" 5 times.
          Open

                  $db->createCommand()->delete('vtiger_groups', ['groupid' => $groupId])->execute();

          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.

          Argument 1 (value) is array{} but \Vtiger_Field_Model::getDBValue() takes \type defined at /code/modules/Vtiger/models/Field.php:1357
          Open

                      parent::set('modules', $this->getFieldInstanceByName('modules')->getDBValue($modules));

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

                          $groupsUp = (new App\Db\Query())->select(['groupid'])->from('vtiger_group2grouprel')->where(['containsgroupid' => $groupsUp])->column();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

          Reference to undeclared property \Settings_Groups_Record_Model->module
          Open

                  $instance->module = $moduleInstance;

          Call to method error from undeclared class \App\Log
          Open

                      \App\Log::error($ex->__toString());
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                      $userIdsList = \App\PrivilegeUtil::getQueryToUsersByMembers($fieldModel->getEditViewValue($members))->column();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

          Returning type ?int but validate() is declared to return null|string
          Open

                  return $error ? self::GROUP_ERRORS[$error] : $error;

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

                                  $db->createCommand()->batchInsert($tableName, $names, $values)->execute();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                      $dataReader = (new App\Db\Query())->from('vtiger_groups')->where(['groupid' => $value])->createCommand()->query();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

          Call to undeclared method \Vtiger_Base_UIType::getOwnerList
          Open

                                  if ($value && ($ownerList = $fieldUITypeModel->getOwnerList($this)) && !isset($ownerList['LBL_USERS'][$value]) && !isset($ownerList['LBL_GROUPS'][$value])) {
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

          Doc-block of getCleanInstance contains declared return type \self which is incompatible with the return type \Settings_Groups_Record_Model declared in the signature
          Open

               * @return \self

          Call to method transferOwnership from undeclared class \App\Fields\Owner
          Open

                  App\Fields\Owner::transferOwnership($groupId, $transferGroupId);
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                          $groupsDown = (new App\Db\Query())->select(['containsgroupid'])->from('vtiger_group2grouprel')->where(['groupid' => $groupsDown])->column();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                      $query->andWhere(['<>', 'groupid', $this->getId()]);
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

          Reference to undeclared property \Settings_Groups_Record_Model->module
          Open

                  return $this->module;

          Call to method getType from undeclared class \App\Fields\Owner
          Open

                      if ('Users' === \App\Fields\Owner::getType($leader)) {
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                              $db->createCommand()->delete($tableName, ['groupid' => $this->getId()])->execute();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                              $db->createCommand()->insert($tableName, $tableData)->execute();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

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

          Reference to undeclared property \Settings_Groups_Record_Model->module
          Open

                  $this->module = $moduleModel;

          Saw unextractable annotation for comment '* @return <array> - Array of Settings_Groups_Record_Model instances'</array>
          Open

               * @return <Array> - Array of Settings_Groups_Record_Model instances

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

                              $db->createCommand()->update($tableName, $tableData, [$baseTableIndex => $this->getId()])->execute();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

          Return type of getCleanInstance() is undeclared type \self
          Open

              public static function getCleanInstance(): self

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

                      $dataReader = (new App\Db\Query())->from('vtiger_groups')->where(['groupname' => $value])->createCommand()->query();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                  return $query->exists();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                  $transaction = $db->beginTransaction();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                          $modules = (new App\Db\Query())->select(['vtiger_group2modules.tabid'])->from('vtiger_group2modules')->where(['vtiger_group2modules.groupid' => $this->getId()])
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                  App\Db::getInstance()->createCommand()->update('vtiger_crmentity', ['smownerid' => $transferGroupId], ['smownerid' => $groupId])->execute();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                  $dataReader = (new App\Db\Query())->from('vtiger_groups')->createCommand()->query();
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

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

                  $query->from('vtiger_groups')->where(['groupname' => $this->get('groupname')]);
          Severity: Critical
          Found in modules/Settings/Groups/models/Record.php by phan

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

              public function getRecordLinks(): array
              {
                  $links = [];
                  $recordLinks = [
                      [
          Severity: Major
          Found in modules/Settings/Groups/models/Record.php and 3 other locations - About 1 hr to fix
          modules/Settings/AutomaticAssignment/models/Record.php on lines 213..236
          modules/Settings/BusinessHours/models/Record.php on lines 242..265
          modules/Settings/TreesManager/models/Record.php on lines 97..120

          Duplicated Code

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

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

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

          Tuning

          This issue has a mass of 117.

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

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

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

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

          Refactorings

          Further Reading

          Avoid excessively long variable names like $php_max_execution_time. Keep variable name length under 20.
          Open

                  $php_max_execution_time = \App\Config::main('php_max_execution_time');

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

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

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

          class Settings_Groups_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

          The class Settings_Groups_Record_Model is not named in CamelCase.
          Open

          class Settings_Groups_Record_Model extends Settings_Vtiger_Record_Model
          {
              /** @var array Record changes */
              protected $changes = [];
          
          

          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 $i. Configured minimum length is 3.
          Open

                  $i = 2;

          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 function setId($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

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

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

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

          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

               * Function to get the Delete Action Url for the current group.

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

               * Function to get the Detail Url for the current group.

          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 ($this->getId() && !\in_array($key, ['id']) && (\array_key_exists($key, $this->value) && $this->value[$key] !== $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

              {

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

               * Function to get the Group Name.

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

               * @return string

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

              }

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

              {

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

               */

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

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

              }

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

               * Set module 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

              /**

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

                  $this->module = $moduleModel;

          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

               * @return mixed

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

              }

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

               * @return string

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

              /**

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

              protected $changes = [];

          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

               */

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

              /**

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

              /** {@inheritdoc} */

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

               * Function to get all the members of the groups.

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

               */

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

              }

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

               *

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

               *

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

              public function getDeleteActionUrl()

          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 '?module=Groups&parent=Settings&view=Detail&record=' . $this->getId();

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

               * Function to get Module 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

                  foreach ($this->getFieldInstanceByName('members')->getEditViewDisplayValue($this->get('members') ?? '') as $member) {

          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 Settings_Groups_Module_Model $moduleModel

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

                  return $this;

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

              {

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

                  $members = [];

          Line exceeds 120 characters; contains 125 characters
          Open

                  foreach ($this->getFieldInstanceByName('members')->getEditViewDisplayValue($this->get('members') ?? '') as $member) {

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

                  }

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

              /**

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

              /**

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

               */

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

               *

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

              public function setModule($moduleModel)

          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 parent::set($key, $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

              public function getPreviousValue(string $fieldName = '')

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

                      $memberInstance->set('id', $member);

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

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

               * Function to get the Edit View Url for the Group.

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

                  return 'index.php?module=Groups&parent=Settings&view=DeleteAjax&record=' . $this->getId();

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

              public function getMemberId()

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

               * @return int Group Id

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

               * @return $this 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 Settings_Groups_Module_Model

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

              public function set($key, $value)

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

                  return Settings_Groups_Member_Model::getQualifiedId(Settings_Groups_Member_Model::MEMBER_TYPE_GROUPS, $this->getId());

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

              /** @var array Record changes */

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

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

              {

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

               * @return string

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

               * @return string

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

               *

          Line exceeds 120 characters; contains 133 characters
          Open

                  if ($this->getId() && !\in_array($key, ['id']) && (\array_key_exists($key, $this->value) && $this->value[$key] !== $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

              {

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

              public function getModule()

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

               *

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

               * @param string $fieldName

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

              /**

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

               *

          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

              public function getMembers(): array

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

                      $members[$type][] = $memberInstance;

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

               *

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

              }

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

               * Function to set the 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

                  $this->set('groupid', $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

                      $memberInstance = new Settings_Groups_Member_Model();

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

              /**

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

              {

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

               * @param int $id Group Id

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

               * Get pervious value by field.

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

               * Gets member 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

                  return $this;

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

                  return '?module=Groups&parent=Settings&view=Edit&record=' . $this->getId();

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

               * @return string

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

              }

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

              {

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

              {

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

                  return $fieldName ? ($this->changes[$fieldName] ?? null) : $this->changes;

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

                  return $members;

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

               */

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

               * Function to get the 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

              public function setId($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 getEditViewUrl()

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

                  return $this->module;

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

               * @return $this

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

                      $this->changes[$key] = $this->get($key);

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

                      [$type] = explode(':', $member, 2);

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

              }

          Line exceeds 120 characters; contains 126 characters
          Open

                  return Settings_Groups_Member_Model::getQualifiedId(Settings_Groups_Member_Model::MEMBER_TYPE_GROUPS, $this->getId());

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

               * @return $this

          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

                  $transaction = $db->beginTransaction();

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

                      $userIds = array_unique(array_merge(

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

                  } catch (\Throwable $ex) {

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

                  ));

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

                          $users = \App\PrivilegeUtil::getUsersByGroup($leader);

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

                      $baseTableIndex = $this->getModule()->baseIndex;

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

                                  \App\PrivilegeUtil::MEMBER_TYPE_GROUPS => ['table' => 'vtiger_group2grouprel', 'memberColumn' => 'containsgroupid', 'groupColumn' => 'groupid'],

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

                              }

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

                                  $forSave[$tableName]['names'] = ['tabid', 'groupid'];

          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

                          $this->getUsersList($this->getPreviousValue('members') ?? ''),

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

                      \App\Log::error($ex->__toString());

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

              public function getLeaderUsers(?int $leader): array

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

                  if ($tablesData) {

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

                      foreach ($this->getValuesToSave($tablesData) as $tableName => $tableData) {

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

                          } elseif ($baseTable === $tableName) {

          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

               * @param array $data

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

                                  $memberColumn = $tables[$type]['memberColumn'];

          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

              {

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

                  }

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

               * Get leader users.

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

                      }

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

              /**

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

                      $baseTable = $this->getModule()->baseTable;

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

                              $members = $fieldModel->getEditViewDisplayValue($value);

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

                              $forSave[$tableName] = [];

          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

                      }

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

                  }

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

               * Function to get the Modules.

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

                      throw $ex;

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

                  $userIds = array_unique(array_merge($userIds,

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

              {

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

                                  $values = $tableData['values'] ?? [];

          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 (!$this->getId()) {

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

                              foreach ($members as $member) {

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

                                  $groupColumn = $tables[$type]['groupColumn'];

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

                                  $forSave[$tableName]['values'][] = [$tabId];

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

                      if ($errorLabel = $this->validate()) {

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

                      $this->saveToDb();

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

                  \App\Cache::clear();

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

               * @param int|null $leader

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

               * Save data to the database.

          Line exceeds 120 characters; contains 186 characters
          Open

                  $tablesData = $this->getId() ? array_intersect_key($this->getData(), $this->changes) : array_intersect_key($this->getData(), array_flip($this->getModule()->getEditableFields()));

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

                              $tables = [

          Line exceeds 120 characters; contains 154 characters
          Open

                                  \App\PrivilegeUtil::MEMBER_TYPE_ROLES => ['table' => 'vtiger_group2role', 'memberColumn' => 'roleid', 'groupColumn' => 'groupid'],

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

                              ];

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

                              $tableName = 'vtiger_group2modules';

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

                      parent::set('modules', $this->getFieldInstanceByName('modules')->getDBValue($modules));

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

              {

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

                          throw new \App\Exceptions\AppException($errorLabel);

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

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

              public function saveToDb()

          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 $fieldName => $value) {

          Line exceeds 120 characters; contains 168 characters
          Open

                                  \App\PrivilegeUtil::MEMBER_TYPE_GROUPS => ['table' => 'vtiger_group2grouprel', 'memberColumn' => 'containsgroupid', 'groupColumn' => 'groupid'],

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

                      $transaction->commit();

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

                      $this->getUsersList($this->get('members') ?? ''),

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

                  $this->recalculate($userIds);

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

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

          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

                      $fieldModel = $this->getFieldInstanceByName($fieldName);

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

                  return $users;

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

                              $db->createCommand()->update($tableName, $tableData, [$baseTableIndex => $this->getId()])->execute();

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

                                  $db->createCommand()->batchInsert($tableName, $names, $values)->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

              private function getValuesToSave(array $data): array

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

                      switch ($fieldName) {

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

                          case 'members':

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

                                  $forSave[$tableName]['values'][] = [$memberId];

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

                  if ($this->isEmpty('modules')) {

          Line exceeds 120 characters; contains 176 characters
          Open

                          $modules = (new App\Db\Query())->select(['vtiger_group2modules.tabid'])->from('vtiger_group2modules')->where(['vtiger_group2modules.groupid' => $this->getId()])

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

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

          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 formats data for saving.

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

                                  \App\PrivilegeUtil::MEMBER_TYPE_ROLES => ['table' => 'vtiger_group2role', 'memberColumn' => 'roleid', 'groupColumn' => 'groupid'],

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

                                  \App\PrivilegeUtil::MEMBER_TYPE_ROLE_AND_SUBORDINATES => ['table' => 'vtiger_group2rs', 'memberColumn' => 'roleandsubid', 'groupColumn' => 'groupid']

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

                                  $tableName = $tables[$type]['table'];

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

                      $modules = [];

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

                          $modules = (new App\Db\Query())->select(['vtiger_group2modules.tabid'])->from('vtiger_group2modules')->where(['vtiger_group2modules.groupid' => $this->getId()])

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

               * Function to save.

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

              }

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

               *

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

                      if ('Users' === \App\Fields\Owner::getType($leader)) {

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

                                  \App\PrivilegeUtil::MEMBER_TYPE_USERS => ['table' => 'vtiger_users2group', 'memberColumn' => 'userid', 'groupColumn' => 'groupid'],

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

                              $forSave[$fieldModel->getTableName()][$fieldModel->getColumnName()] = $value;

          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

                  return $this;

          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

                          if (!$this->getId() && $baseTable === $tableName) {

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

                              $this->setId((int) $tableData[$baseTableIndex]);

          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

                  $forSave = [];

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

                                  [$type, $memberId] = explode(':', $member);

          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

                      $transaction->rollBack();

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

                      $this->getLeaderUsers($this->get('parentid'))

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

               */

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

                  $tablesData = $this->getId() ? array_intersect_key($this->getData(), $this->changes) : array_intersect_key($this->getData(), array_flip($this->getModule()->getEditableFields()));

          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

                      $forSave[$this->getModule()->baseTable][$this->getModule()->baseIndex] = \App\Db::getInstance('admin')->getUniqueId('vtiger_users');

          Line exceeds 120 characters; contains 155 characters
          Open

                                  \App\PrivilegeUtil::MEMBER_TYPE_USERS => ['table' => 'vtiger_users2group', 'memberColumn' => 'userid', 'groupColumn' => 'groupid'],

          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

                              $modules = $fieldModel->getEditViewDisplayValue($value);

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

              public function setModules()

          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

          Line exceeds 120 characters; contains 121 characters
          Open

                              $db->createCommand()->update($tableName, $tableData, [$baseTableIndex => $this->getId()])->execute();

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

                              $db->createCommand()->delete($tableName, ['groupid' => $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

                      }

          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 ($modules as $tabId) {

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

               */

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

                              ->column();

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

                      ));

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

              /**

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

                  $users = [];

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

                              $db->createCommand()->insert($tableName, $tableData)->execute();

          Line exceeds 120 characters; contains 173 characters
          Open

                                  \App\PrivilegeUtil::MEMBER_TYPE_ROLE_AND_SUBORDINATES => ['table' => 'vtiger_group2rs', 'memberColumn' => 'roleandsubid', 'groupColumn' => 'groupid']

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

                          case 'modules':

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

                  try {

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

                              if ($names = $tableData['names'] ?? []) {

          Line exceeds 120 characters; contains 144 characters
          Open

                      $forSave[$this->getModule()->baseTable][$this->getModule()->baseIndex] = \App\Db::getInstance('admin')->getUniqueId('vtiger_users');

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

                              $forSave += array_fill_keys(array_column($tables, 'table'), []);

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

                                  $forSave[$tableName]['names'] = [$memberColumn, $groupColumn];

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

                      if ($this->getId()) {

          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

                          $this->getLeaderUsers($this->getPreviousValue('parentid'))

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

              {

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

                          $users[] = $leader;

          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 ($values as &$value) {

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

                                      $value[] = $this->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

              public function setDataFromRequest(App\Request $request)

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

                                  $fieldModel = $this->getFieldInstanceByName($fieldName);

          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

               *

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

               * @param Settings_Groups_Record_Model|Users_Record_Model $transferToGroup

          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 Settings_Groups_Record_Model $transferToGroup

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

              public function delete($transferToGroup)

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

                  $recordLinks = [

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

                          'linktype' => 'LISTVIEWRECORD',

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

                          'linklabel' => 'LBL_EDIT_RECORD',

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

                      $groups[$group->getId()] = $group;

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

                                  $fieldUITypeModel->validate($value, 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

              /**

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

               * @param array $userIdsList

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

                  $this->transferOwnership($transferToGroup);

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

              }

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

                  $links = [];

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

                          'linkclass' => 'btn-sm btn-danger'

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

               *

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

                      }

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

              }

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

              /**

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

               * @param string $members

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

                  $groupId = $this->getId();

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

                          'linkclass' => 'btn-sm btn-primary'

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

                      [

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

                          'linktype' => 'LISTVIEWRECORD',

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

               * Function to get all the groups.

          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

              }

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

                  set_time_limit($php_max_execution_time);

          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

                  $transferGroupId = $transferToGroup->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

                      ],

          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

               * Function returns field instances for given 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

              public function getUsersList(string $members): array

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

                  }

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

              }

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

                  $eventHandler->trigger('GroupBeforeDelete');

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

                  foreach ($recordLinks as $recordLink) {

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

                  return $forSave;

          Line exceeds 120 characters; contains 181 characters
          Open

                                  if ($value && ($ownerList = $fieldUITypeModel->getOwnerList($this)) && !isset($ownerList['LBL_USERS'][$value]) && !isset($ownerList['LBL_GROUPS'][$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

                  }

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

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

                                  $value = $fieldModel->getDBValue($value);

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

              public function getFieldInstanceByName($name)

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

                  $userIdsList = [];

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

               * TransferOwnership.

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

                  \App\PrivilegeUtil::deleteRelatedSharingRules($groupId, 'Groups');

          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

               *

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

              }

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

                      $fieldModel = $this->getFieldInstanceByName('members');

          Line exceeds 120 characters; contains 148 characters
          Open

                  App\Db::getInstance()->createCommand()->update('vtiger_crmentity', ['smownerid' => $transferGroupId], ['smownerid' => $groupId])->execute();

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

               * Function to delete the group.

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

                  \App\Cache::clear();

          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

               * Sets data from request.

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

                      if ($request->has($fieldName)) {

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

                                  $value = $request->getByType($fieldName, $fieldModel->get('purifyType'));

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

                  if ($members) {

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

                      $userIdsList = \App\PrivilegeUtil::getQueryToUsersByMembers($fieldModel->getEditViewValue($members))->column();

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

              /**

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

              protected function transferOwnership($transferToGroup)

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

                  App\Fields\Owner::transferOwnership($groupId, $transferGroupId);

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

              /** {@inheritdoc} */

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

                      [

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

                      $links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink);

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

                                  $fieldModel = $this->getFieldInstanceByName($fieldName);

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

                                  $value = $request->getByType($fieldName, $fieldModel->get('purifyType'));

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

                                  $fieldUITypeModel = $fieldModel->getUITypeModel();

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

                          $this->set($fieldName, $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

              {

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

                      \App\UserPrivilegesFile::createUserPrivilegesfile($userId);

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

               * Function to get all users related to this group.

          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

                          'linkurl' => $this->getEditViewUrl(),

          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

                          switch ($fieldName) {

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

                                  if ($value && ($ownerList = $fieldUITypeModel->getOwnerList($this)) && !isset($ownerList['LBL_USERS'][$value]) && !isset($ownerList['LBL_GROUPS'][$value])) {

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

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

                  $fieldModel = $this->getModule()->getFieldInstanceByName($name);

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

               * Function to recalculate user privileges files.

          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

                  $eventHandler->setParams(['groupId' => $groupId, 'transferToGroup' => $transferToGroup]);

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

                          'linkicon' => 'yfi yfi-full-editing-view',

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

                  $dataReader = (new App\Db\Query())->from('vtiger_groups')->createCommand()->query();

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

                  $groups = [];

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

               * @param string $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

                  foreach ($userIdsList as $userId) {

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

              }

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

                  $groupId = $this->getId();

          Line exceeds 120 characters; contains 125 characters
          Open

                          'linkurl' => "javascript:Settings_Vtiger_List_Js.triggerDelete(event,'" . $this->getDeleteActionUrl() . "')",

          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

                      $group = new self();

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

                                  $fieldUITypeModel->validate($value, true);

          Line exceeds 120 characters; contains 123 characters
          Open

                      $userIdsList = \App\PrivilegeUtil::getQueryToUsersByMembers($fieldModel->getEditViewValue($members))->column();

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

                  return $userIdsList;

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

                  $eventHandler = new App\EventHandler();

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

                      ],

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

                          'linklabel' => 'LBL_DELETE_RECORD',

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

                          'linkicon' => 'fas fa-trash-alt',

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

                  return $links;

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

               * @return <Array> - Array of Settings_Groups_Record_Model instances

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

                      $group->setData($row);

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

                              case 'parentid':

          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 ($this->has($name)) {

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

                  return $fieldModel;

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

                  $php_max_execution_time = \App\Config::main('php_max_execution_time');

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

               */

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

                  App\Db::getInstance()->createCommand()->update('vtiger_crmentity', ['smownerid' => $transferGroupId], ['smownerid' => $groupId])->execute();

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

              public function getRecordLinks(): 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

                  foreach ($this->getModule()->getEditableFields() as $fieldName) {

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

                                  $fieldUITypeModel = $fieldModel->getUITypeModel();

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

                                  }

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

               * @return Vtiger_Field_Model

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

                      $fieldModel->set('fieldvalue', $this->get($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

              public function recalculate(array $userIdsList)

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

                  }

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

               *

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

               *

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

              /**

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

              {

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

                  $db->createCommand()->delete('vtiger_groups', ['groupid' => $groupId])->execute();

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

                          'linkurl' => "javascript:Settings_Vtiger_List_Js.triggerDelete(event,'" . $this->getDeleteActionUrl() . "')",

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

              public static function getAll()

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

              /**

          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

              /**

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

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

                  \App\Cache::staticSave($cacheName, $key, $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

               * Function to get the instance of Group model, given group id or name.

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

               * @return Settings_Groups_Record_Model instance, if exists. Null otherwise

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

                  }

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

              /**

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

                  $query = new App\Db\Query();

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

                      $query->andWhere(['<>', 'groupid', $this->getId()]);

          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

                  foreach ($members as $key => $member) {

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

               * @return int|null

          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 (!$groupsDown && !$groupsUp) {

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

                      return \App\Cache::staticGet($cacheName, $key);

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

                      $data['members'] = $instance->getFieldInstanceByName('members')->getDBValue(Settings_Groups_Member_Model::getAllByTypeForGroup($data['groupid']));

          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 validate(): ?string

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

                  if ($this->checkDuplicate()) {

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

               *

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

                      $allGroups[] = $this->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

                  return $query->exists();

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

              public function getMembersByType(string $type): array

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

                  $length = \strlen($needle);

          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

                  $groupsUp = [];

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

                          $error = self::ERROR_LOOP_INF;

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

                      ++$i;

          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

               * Get elements by member type.

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

                  $fieldModel = $this->getFieldInstanceByName('members');

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

                  $needle = $type . ':';

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

              /** @var int Error ID - Indefinite loop */

          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

                          $groupsUp = (new App\Db\Query())->select(['groupid'])->from('vtiger_group2grouprel')->where(['containsgroupid' => $groupsUp])->column();

          Line exceeds 120 characters; contains 152 characters
          Open

                          $groupsUp = (new App\Db\Query())->select(['groupid'])->from('vtiger_group2grouprel')->where(['containsgroupid' => $groupsUp])->column();

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

                      if ($i >= $max) {

          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 = null;

          Line exceeds 120 characters; contains 126 characters
          Open

                      $dataReader = (new App\Db\Query())->from('vtiger_groups')->where(['groupid' => $value])->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

                      $instance->setData($data)->setModules();

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

                  $error = null;

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

               * @return bool

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

               *

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

               * @param string $type

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

              public const ERROR_LOOP_LIMIT = 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

                  $error = null;

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

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

                  $max = \App\PrivilegeUtil::GROUP_LOOP_LIMIT;

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

                      if ($groupsUp) {

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

                          $error = self::ERROR_LOOP_LIMIT;

          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

               *

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

               * @return \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

              public static function getInstance($value)

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

                          $members[$key] = substr($member, $length);

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

              public function checkLoop(): ?int

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

                  $groupsDown = $allGroups = $this->getMembersByType(\App\PrivilegeUtil::MEMBER_TYPE_GROUPS);

          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

                  $instance->module = $moduleInstance;

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

               * Data validation.

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

              {

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

                      $error = self::ERROR_DUPLICATE;

          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 ($i <= $max) {

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

                      if ($groupsDown) {

          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 (vtlib\Utils::isNumber($value)) {

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

                      $dataReader = (new App\Db\Query())->from('vtiger_groups')->where(['groupname' => $value])->createCommand()->query();

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

                  if ($dataReader->count() > 0) {

          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

                      if (0 === strncmp($member, $needle, $length)) {

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

                  return $members;

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

              /** @var array Labels by error ID */

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

                  self::ERROR_LOOP_INF => 'LBL_INDEFINITE_LOOP',

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

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

                          $groupsDown = (new App\Db\Query())->select(['containsgroupid'])->from('vtiger_group2grouprel')->where(['groupid' => $groupsDown])->column();

          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

               * @param int|string $value

          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

              /** @var int Error ID - The limit of allowed group nests has been exceeded */

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

               * Check group correlations.

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

              public static function getCleanInstance(): 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

                  if (\App\Cache::staticHas($cacheName, $key)) {

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

                      $dataReader = (new App\Db\Query())->from('vtiger_groups')->where(['groupid' => $value])->createCommand()->query();

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

                      $instance = self::getCleanInstance();

          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 checkDuplicate(): bool

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

              public const ERROR_LOOP_INF = 2;

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

                  $i = 2;

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

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

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

               * @return string|null

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

                  return $error ? self::GROUP_ERRORS[$error] : $error;

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

                          unset($members[$key]);

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

              }

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

                          ++$i;

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

               */

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

                  $cacheName = __CLASS__;

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

                  $key = 'Clean';

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

                  }

          Line exceeds 120 characters; contains 158 characters
          Open

                      $data['members'] = $instance->getFieldInstanceByName('members')->getDBValue(Settings_Groups_Member_Model::getAllByTypeForGroup($data['groupid']));

          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

                      $error = $this->checkLoop();

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

               * Check duplicate.

          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 const GROUP_ERRORS = [

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

                  self::ERROR_DUPLICATE => 'LBL_GROUP_DUPLICATE',

          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 ($groupsUp && $groupsDown) {

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

                  }

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

               * Function to get the clean instance.

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

                  $moduleInstance = Settings_Vtiger_Module_Model::getInstance('Settings:Groups');

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

                      $data = $dataReader->read();

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

                  if ($this->getId()) {

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

              public const ERROR_DUPLICATE = 3;

          Line exceeds 120 characters; contains 156 characters
          Open

                          $groupsDown = (new App\Db\Query())->select(['containsgroupid'])->from('vtiger_group2grouprel')->where(['groupid' => $groupsDown])->column();

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

                      }

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

                      $allGroups = array_merge($allGroups, $groupsDown, $groupsUp);

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

                      if (\count($allGroups) !== \count(array_flip($allGroups))) {

          Line exceeds 120 characters; contains 128 characters
          Open

                      $dataReader = (new App\Db\Query())->from('vtiger_groups')->where(['groupname' => $value])->createCommand()->query();

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

                  $query->from('vtiger_groups')->where(['groupname' => $this->get('groupname')]);

          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

                  $members = $fieldModel->getEditViewValue($this->get($fieldModel->getName()));

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

              /** @var int Error ID - Duplicate record */

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

                  self::ERROR_LOOP_LIMIT => 'LBL_ALLOWED_GROUP_NESTS_EXCEEDED',

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

                  }

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

                      $groupsUp[] = $this->getId();

          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

                  return $error;

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

              }

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

          class Settings_Groups_Record_Model extends Settings_Vtiger_Record_Model

          Opening parenthesis of a multi-line function call must be the last content on the line
          Open

                  $userIds = array_unique(array_merge($userIds,

          The variable $php_max_execution_time is not named in camelCase.
          Open

              public function recalculate(array $userIdsList)
              {
                  $php_max_execution_time = \App\Config::main('php_max_execution_time');
                  set_time_limit($php_max_execution_time);
          
          

          CamelCaseVariableName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name variables.

          Example

          class ClassName {
              public function doSomething() {
                  $data_module = new DataModule();
              }
          }

          Source

          The variable $php_max_execution_time is not named in camelCase.
          Open

              public function recalculate(array $userIdsList)
              {
                  $php_max_execution_time = \App\Config::main('php_max_execution_time');
                  set_time_limit($php_max_execution_time);
          
          

          CamelCaseVariableName

          Since: 0.2

          It is considered best practice to use the camelCase notation to name variables.

          Example

          class ClassName {
              public function doSomething() {
                  $data_module = new DataModule();
              }
          }

          Source

          There are no issues that match your filters.

          Category
          Status