YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/models/TreeCategoryModal.php

Summary

Maintainability
B
4 hrs
Test Coverage
F
0%

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

    private function getTreeList()
    {
        $trees = [];
        $isDeletable = $this->getRelationModel()->privilegeToTreeDelete();
        $lastId = 0;
Severity: Minor
Found in modules/Vtiger/models/TreeCategoryModal.php - About 1 hr to fix

    Method getRecords has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getRecords()
        {
            $selectedRecords = $this->getSelectedRecords();
            $isDeletable = $this->isDeletable();
            if (2 == $this->getRelationType()) {
    Severity: Minor
    Found in modules/Vtiger/models/TreeCategoryModal.php - About 1 hr to fix

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

          private function getTreeList()
          {
              $trees = [];
              $isDeletable = $this->getRelationModel()->privilegeToTreeDelete();
              $lastId = 0;
      Severity: Minor
      Found in modules/Vtiger/models/TreeCategoryModal.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 getRecords has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getRecords()
          {
              $selectedRecords = $this->getSelectedRecords();
              $isDeletable = $this->isDeletable();
              if (2 == $this->getRelationType()) {
      Severity: Minor
      Found in modules/Vtiger/models/TreeCategoryModal.php - About 25 mins to fix

      Cognitive Complexity

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

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

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

      Further reading

      Missing class import via use statement (line '47', column '21').
      Open

              $fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();

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

              $dataReader = (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 '172', column '15').
      Open

              return (new App\Db\Query())->select(['tree'])->from('u_#__crmentity_rel_tree')

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

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

      The method getSelectedRecords has a boolean flag argument $onlyKeys, which is a certain sign of a Single Responsibility Principle violation.
      Open

          private function getSelectedRecords($onlyKeys = true)

      BooleanArgumentFlag

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class '\App\Language' in method 'getTreeList'.
      Open

                      'text' => \App\Language::translate($row['name'], $this->getModuleName()),

      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_Relation_Model' in method 'getRelationModel'.
      Open

                  $this->relationModel = Vtiger_Relation_Model::getInstance($srcModuleModel, $this->get('module'));

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

              } else {
                  $listEntries = $this->getSelectedRecords(false);
              }

      ElseExpression

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Record_Model' in method 'getSelectedRecords'.
      Open

              $parentRecordModel = Vtiger_Record_Model::getInstanceById($this->get('srcRecord'), $this->get('srcModule'));

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

              $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'TreeCategoryModal', $moduleName);

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

              $fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();

      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_RelationListView_Model' in method 'getSelectedRecords'.
      Open

              $relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $this->getModuleName());

      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_ListView_Model' in method 'getAllRecords'.
      Open

              $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($this->getModuleName(), $this->get('srcModule'));

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class 'Vtiger_Module_Model' in method 'getRelationModel'.
      Open

                  $srcModuleModel = Vtiger_Module_Model::getInstance($this->get('srcModule'));

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

              if ($this->has('fieldTemp')) {

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

              if ($this->has('relationType')) {

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

                      'type' => 'category',

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

              $fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();

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

                  $srcModuleModel = Vtiger_Module_Model::getInstance($this->get('srcModule'));

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

              $instance->set('module', $moduleModel)->set('moduleName', $moduleName);

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

                  ->where(['crmid' => $this->get('srcRecord'), 'relmodule' => $this->get('module')->getId()])

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

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

              $dataReader = (new App\Db\Query())

      Call to method setField from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
      Open

              $listViewModel->getQueryGenerator()->setField($this->getTreeField()['fieldname']);

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

              $fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();

      Return type of getTemplate() is undeclared type \type
      Open

          public function getTemplate()

      Reference to undeclared property \Vtiger_TreeCategoryModal_Model->lastIdinTree
      Open

                      'id' => $this->lastIdinTree,

      Reference to undeclared property \Vtiger_TreeCategoryModal_Model->relationModel
      Open

                  $this->relationModel = Vtiger_Relation_Model::getInstance($srcModuleModel, $this->get('module'));

      Saw possibly unextractable annotation for a fragment of comment '* @param string name of the module': after string, did not see an element name (will guess based on comment order)
      Open

           * @param string name of the module

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

              return (new App\Db\Query())->select(['tree'])->from('u_#__crmentity_rel_tree')

      Reference to undeclared property \Vtiger_TreeCategoryModal_Model->lastIdinTree
      Open

                  ++$this->lastIdinTree;

      Returning type array<int>|array<int>|array<int>|array<int>|array{}</int></int></int></int> but getTreeList() is declared to return string
      Open

              return $trees;

      Argument 1 (arr1) is string but \array_merge() takes array
      Open

              return array_merge($this->getTreeList(), $this->getRecords());

      Reference to undeclared property \Vtiger_TreeCategoryModal_Model->lastIdinTree
      Open

              $this->lastIdinTree = $lastId;

      Reference to undeclared property \Vtiger_TreeCategoryModal_Model->relationModel
      Open

              if (!isset($this->relationModel)) {

      Reference to undeclared property \Vtiger_TreeCategoryModal_Model->relationModel
      Open

              return $this->relationModel;

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

      class Vtiger_TreeCategoryModal_Model extends \App\Base

      The class Vtiger_TreeCategoryModal_Model is not named in CamelCase.
      Open

      class Vtiger_TreeCategoryModal_Model extends \App\Base
      {
          public static $_cached_instance;
      
          /**

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

      The property $_cached_instance is not named in camelCase.
      Open

      class Vtiger_TreeCategoryModal_Model extends \App\Base
      {
          public static $_cached_instance;
      
          /**

      CamelCasePropertyName

      Since: 0.2

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

      Example

      class ClassName {
          protected $property_name;
      }

      Source

      Property name "$_cached_instance" should not be prefixed with an underscore to indicate visibility
      Open

          public static $_cached_instance;

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

           * @return array

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

          {

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

          /**

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

              return $this->getRelationModel()->privilegeToDelete();

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

           * Load tree.

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

              $trees = [];

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

                      'type' => 'category',

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

                      $tree['state']['disabled'] = true;

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

          public static $_cached_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

              $selected = $this->getSelectedTreeList();

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

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

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

          public function getTemplate()

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

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

          public static function getInstance(Vtiger_Module_Model $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

           * @return mixed

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

              if ($this->has('relationType')) {

      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

              $lastId = 0;

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

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

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

                  }

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

                  if (!$isDeletable && $checked) {

      Line exceeds 120 characters; contains 238 characters
      Open

              $fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();

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

           * @param Vtiger_Module_Model $moduleModel

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

              self::$_cached_instance[$moduleName] = $instance;

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

           * @return bool|\Vtiger_Relation_Model

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

          public function getRelationModel()

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

      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

                  ->where(['templateid' => $this->getTemplate()])

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

                  }

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

          /**

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

           * @return string Module name

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

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

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

              $this->set('fieldTemp', $fieldTemp);

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

              if (isset(self::$_cached_instance[$moduleName])) {

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

                  return self::$_cached_instance[$moduleName];

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

              return $this->relationModel;

      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

           * @return string

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

          private function getTreeList()

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

          {

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

                  $pieces = explode('::', $row['parentTree']);

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

                  $tree = [

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

                  if (!empty($row['icon'])) {

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

      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

           * Load tree 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->relationModel = Vtiger_Relation_Model::getInstance($srcModuleModel, $this->get('module'));

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

           *

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

                      'text' => \App\Language::translate($row['name'], $this->getModuleName()),

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

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

           */

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

              $fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();

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

           * Static Function to get the instance of Vtiger TreeView Model for the given Vtiger Module 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

           * Function check if record is deletable.

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

              $isDeletable = $this->getRelationModel()->privilegeToTreeDelete();

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

                  $checked = \in_array($row['tree'], $selected);

      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

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

                  $treeID = (int) ltrim($row['tree'], 'T');

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

          public function getModuleName()

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

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

                  ->from('vtiger_trees_templates_data')

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

           * Function to get the Module Name.

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

           * @return type

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

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

      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

                      'id' => $treeID,

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

                      'parent' => 0 == $parent ? '#' : $parent,

      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

           * Load tree field info.

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

              }

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

              $instance = new $modelClassName();

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

          }

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

           * Gets relation type.

      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_merge($this->getTreeList(), $this->getRecords());

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

                  if ($checked) {

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

                      $tree['category'] = ['checked' => true];

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

          public function getTreeField()

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

                  $srcModuleModel = Vtiger_Module_Model::getInstance($this->get('srcModule'));

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

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

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

              $dataReader = (new App\Db\Query())

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

                  $parent = (int) ltrim(prev($pieces), 'T');

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

                      $lastId = $treeID;

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

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

              $instance->set('module', $moduleModel)->set('moduleName', $moduleName);

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

          {

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

          {

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

              if ($this->has('fieldTemp')) {

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

              $moduleName = $moduleModel->get('name');

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

              $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'TreeCategoryModal', $moduleName);

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

              return self::$_cached_instance[$moduleName];

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

                  ->createCommand()->query();

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

                  $trees[] = $tree;

      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

                  $listEntries = $this->getSelectedRecords(false);

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

                      'category' => ['checked' => $selected]

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

          }

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

              $isDeletable = $this->isDeletable();

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

                  $parent = (int) ltrim($item->get($fieldName), 'T');

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

              return $listViewModel->getAllEntries();

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

              if (2 == $this->getRelationType()) {

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

              $tree = [];

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

                  ++$this->lastIdinTree;

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

                  if (!$isDeletable && $selected) {

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

              return $this->getTreeField()['fieldparams'];

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

           * @param string name of the module

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

              if (!isset($this->relationModel)) {

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

              $this->set('relationType', $this->getRelationModel()->getRelationType());

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

                  end($pieces);

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

                      'record_id' => $row['tree'],

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

                      $tree['icon'] = $row['icon'];

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

                  ->where(['crmid' => $this->get('srcRecord'), 'relmodule' => $this->get('module')->getId()])

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

              $listViewModel = Vtiger_ListView_Model::getInstanceForPopup($this->getModuleName(), $this->get('srcModule'));

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

      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

                      'parent' => 0 == $parent ? '#' : $parent,

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

          }

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

              $listViewModel->getQueryGenerator()->setField($this->getTreeField()['fieldname']);

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

              $fieldName = $this->getTreeField()['fieldname'];

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

                  $tree[] = [

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

                      'text' => $item->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

                  }

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

          private function getSelectedTreeList()

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

              return (new App\Db\Query())->select(['tree'])->from('u_#__crmentity_rel_tree')

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

              $parentRecordModel = Vtiger_Record_Model::getInstanceById($this->get('srcRecord'), $this->get('srcModule'));

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

              if (!empty($this->get('srcModule'))) {

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

              $selectedRecords = $this->getSelectedRecords();

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

                      'id' => $this->lastIdinTree,

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

                      'record_id' => $item->getId(),

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

              return $tree;

      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

                  $listViewModel->set('src_module', $this->get('srcModule'));

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

          {

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

                      'type' => 'category',

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

                      'attr' => 'record',

      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 getSelectedRecords($onlyKeys = true)

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

                  $listViewModel->set('src_record', $this->get('srcRecord'));

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

                  $listEntries = $this->getAllRecords();

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

              $this->lastIdinTree = $lastId;

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

              $relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $this->getModuleName());

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

              $entries = $relationListView->getAllEntries();

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

                  $state = ['selected' => $selected];

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

                      $state['disabled'] = true;

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

          private function getAllRecords()

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

           * Function to get selected item in the tree.

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

              }

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

                      'state' => $state,

      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

                  return array_keys($entries);

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

              foreach ($listEntries as $item) {

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

              return $trees;

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

           * @return array

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

          {

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

              if ($onlyKeys) {

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

          private function getRecords()

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

                  $selected = \in_array($item->getId(), $selectedRecords);

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

                      'icon' => "js-detail__icon yfm-{$this->getModuleName()}",

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

      class Vtiger_TreeCategoryModal_Model extends \App\Base

      The variable $_cached_instance is not named in camelCase.
      Open

          public static function getInstance(Vtiger_Module_Model $moduleModel)
          {
              $moduleName = $moduleModel->get('name');
              if (isset(self::$_cached_instance[$moduleName])) {
                  return self::$_cached_instance[$moduleName];

      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 $_cached_instance is not named in camelCase.
      Open

          public static function getInstance(Vtiger_Module_Model $moduleModel)
          {
              $moduleName = $moduleModel->get('name');
              if (isset(self::$_cached_instance[$moduleName])) {
                  return self::$_cached_instance[$moduleName];

      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 $_cached_instance is not named in camelCase.
      Open

          public static function getInstance(Vtiger_Module_Model $moduleModel)
          {
              $moduleName = $moduleModel->get('name');
              if (isset(self::$_cached_instance[$moduleName])) {
                  return self::$_cached_instance[$moduleName];

      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 $_cached_instance is not named in camelCase.
      Open

          public static function getInstance(Vtiger_Module_Model $moduleModel)
          {
              $moduleName = $moduleModel->get('name');
              if (isset(self::$_cached_instance[$moduleName])) {
                  return self::$_cached_instance[$moduleName];

      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