YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/widgets/Documents.php

Summary

Maintainability
A
1 hr
Test Coverage
F
0%

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

    public function getHeaderButtons(): array
    {
        $links = [];
        $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];
        if (\App\Privilege::isPermitted($moduleName, 'CreateView')) {
Severity: Minor
Found in modules/Vtiger/widgets/Documents.php - About 1 hr to fix

    Function getCustomFields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getCustomFields(): array
        {
            $fields = [];
            $fromRelations = (array) ($this->Data['fromRelation'] ?? []);
            if ($fromRelations && ($relations = array_intersect_key($this->getRelations($this->moduleModel->getId()), array_flip($fromRelations)))) {
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php - About 35 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

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

                        $params['picklistValues'][$key] = $relation['translate'];
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    UndefinedVariable

    Since: 2.8.0

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

    Example

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

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

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

                $params['uitype'] = 16;
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    UndefinedVariable

    Since: 2.8.0

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

    Example

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

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

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

                $fields[] = \Vtiger_Field_Model::init($this->moduleModel->getName(), $params, 'fromRelation');
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    UndefinedVariable

    Since: 2.8.0

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

    Example

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

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

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

                $params['picklistValues'] = [];
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    UndefinedVariable

    Since: 2.8.0

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

    Example

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

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

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

    class Vtiger_Documents_Widget extends Vtiger_RelatedModule_Widget
    {
        /** {@inheritdoc} */
        public function isPermitted(): bool
        {
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    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 '93', column '59').
    Open

                ->andWhere(['and', ['vtiger_relatedlists.tabid' => new \yii\db\Expression('brl.tabid')], ['brl.related_tabid' => $moduleId], ['brl.name' => 'getDependentsList']])
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    MissingImport

    Since: 2.7.0

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

    Example

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

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

    Missing class import via use statement (line '88', column '22').
    Open

            $dataReader = (new \App\Db\Query())->select(['vtiger_relatedlists.*', 'moduleName' => 'vtiger_tab.name', 'relatedField' => 'brl.field_name'])
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    MissingImport

    Since: 2.7.0

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

    Example

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

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

    Avoid using static access to class '\App\Relation' in method 'isPermitted'.
    Open

            return parent::isPermitted() && \App\Relation::getByModule($this->moduleModel->getName(), false, 'Documents');
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class '\App\Privilege' in method 'getHeaderButtons'.
    Open

            if (\App\Privilege::isPermitted($moduleName, 'CreateView')) {
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

                $this->moduleModel = Vtiger_Module_Model::getInstance($moduleId);
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class '\Vtiger_Field_Model' in method 'getCustomFields'.
    Open

                $fields[] = \Vtiger_Field_Model::init($this->moduleModel->getName(), $params, 'fromRelation');
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'Vtiger_Link_Model' in method 'getHeaderButtons'.
    Open

                $links[] = Vtiger_Link_Model::getInstanceFromValues([
                    'linkhint' => App\Language::translate('LBL_SEND_MAIL', $moduleName),
                    'linkdata' => [
                        'url' => OSSMail_Module_Model::getComposeUrl($this->Module, $this->Record, 'Detail', 'new') . '&template=' . $this->Data['email_template'],
                        'module' => $this->Module,
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

                    'linklabel' => App\Language::translate('LBL_MASS_ADD', $moduleName),
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class '\App\Mail' in method 'getHeaderButtons'.
    Open

            if (!empty($this->Data['email_template']) && \App\Mail::checkInternalMailClient() && \App\Record::isExists($this->Data['email_template'], 'EmailTemplates')
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

                    'linkhint' => App\Language::translate('LBL_SEND_MAIL', $moduleName),
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

                $this->Data['relatedmodule'] = \App\Module::getModuleId('Documents');
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'Vtiger_Link_Model' in method 'getHeaderButtons'.
    Open

                $links[] = Vtiger_Link_Model::getInstanceFromValues([
                    'linklabel' => App\Language::translate('LBL_MASS_ADD', $moduleName),
                    'linkdata' => [
                        'url' => 'index.php?module=Documents&view=MassAddDocuments&sourceModule=' . $this->Module . '&sourceRecord=' . $this->Record,
                        'cb' => 'Documents_MassAddDocuments_Js.register',
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class '\App\Json' in method 'getRelations'.
    Open

                $relations[\App\Json::encode($key)] = $row;
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class '\App\Record' in method 'getHeaderButtons'.
    Open

            if (!empty($this->Data['email_template']) && \App\Mail::checkInternalMailClient() && \App\Record::isExists($this->Data['email_template'], 'EmailTemplates')
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid assigning values to variables in if clauses and the like (line '112', column '26').
    Open

        public function getCustomFields(): array
        {
            $fields = [];
            $fromRelations = (array) ($this->Data['fromRelation'] ?? []);
            if ($fromRelations && ($relations = array_intersect_key($this->getRelations($this->moduleModel->getId()), array_flip($fromRelations)))) {
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    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 'OSSMail_Module_Model' in method 'getHeaderButtons'.
    Open

                        'url' => OSSMail_Module_Model::getComposeUrl($this->Module, $this->Record, 'Detail', 'new') . '&template=' . $this->Data['email_template'],
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class '\App\Privilege' in method 'getCustomFields'.
    Open

                    if (\App\Privilege::isPermitted($relation['moduleName'])) {
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Define a constant instead of duplicating this literal "relatedField" 4 times.
    Open

            $dataReader = (new \App\Db\Query())->select(['vtiger_relatedlists.*', 'moduleName' => 'vtiger_tab.name', 'relatedField' => 'brl.field_name'])
    Severity: Critical
    Found in modules/Vtiger/widgets/Documents.php by sonar-php

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

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

    Exceptions

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

    Define a constant instead of duplicating this literal "relatedmodule" 6 times.
    Open

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];
    Severity: Critical
    Found in modules/Vtiger/widgets/Documents.php by sonar-php

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

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

    Exceptions

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

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

            if (!empty($this->Data['email_template']) && \App\Mail::checkInternalMailClient() && \App\Record::isExists($this->Data['email_template'], 'EmailTemplates')
    Severity: Critical
    Found in modules/Vtiger/widgets/Documents.php by sonar-php

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

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

    Exceptions

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

    Reference to undeclared property \Vtiger_Documents_Widget->Data
    Open

            if (empty($this->Data['relatedmodule'])) {
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phan

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

            $dataReader = (new \App\Db\Query())->select(['vtiger_relatedlists.*', 'moduleName' => 'vtiger_tab.name', 'relatedField' => 'brl.field_name'])
    Severity: Critical
    Found in modules/Vtiger/widgets/Documents.php by phan

    Call to method __construct from undeclared class \yii\db\Expression
    Open

                ->andWhere(['and', ['vtiger_relatedlists.tabid' => new \yii\db\Expression('brl.tabid')], ['brl.related_tabid' => $moduleId], ['brl.name' => 'getDependentsList']])
    Severity: Critical
    Found in modules/Vtiger/widgets/Documents.php by phan

    Call to method getFieldByName on non-class type false
    Open

                $row['translate'] = $this->moduleModel->getFieldByName($row['relatedField'])->getFullLabelTranslation();
    Severity: Critical
    Found in modules/Vtiger/widgets/Documents.php by phan

    Reference to undeclared property \Vtiger_Documents_Widget->Data
    Open

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phan

    Suspicious type false of a variable or expression used to build a string. (Expected type to be able to cast to a string)
    Open

                        'url' => 'index.php?module=Documents&view=MassAddDocuments&sourceModule=' . $this->Module . '&sourceRecord=' . $this->Record,
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phan

    Reference to undeclared property \Vtiger_Documents_Widget->Data
    Open

                $this->Data['relatedmodule'] = \App\Module::getModuleId('Documents');
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phan

    Reference to undeclared property \Vtiger_Documents_Widget->Data
    Open

            if (!empty($this->Data['email_template']) && \App\Mail::checkInternalMailClient() && \App\Record::isExists($this->Data['email_template'], 'EmailTemplates')
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phan

    Assigning \Vtiger_Module_Model to property but \Vtiger_Documents_Widget->moduleModel is false
    Open

                $this->moduleModel = Vtiger_Module_Model::getInstance($moduleId);
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phan

    Reference to undeclared property \Vtiger_Documents_Widget->Data
    Open

                ->where(['and', ['vtiger_tab.presence' => 0], ['vtiger_relatedlists.related_tabid' => $this->Data['relatedmodule']]])
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phan

    Reference to undeclared property \Vtiger_Documents_Widget->Data
    Open

            $fromRelations = (array) ($this->Data['fromRelation'] ?? []);
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phan

    Call to method getName on non-class type false
    Open

                $fields[] = \Vtiger_Field_Model::init($this->moduleModel->getName(), $params, 'fromRelation');
    Severity: Critical
    Found in modules/Vtiger/widgets/Documents.php by phan

    Call to method getId on non-class type false
    Open

            if ($fromRelations && ($relations = array_intersect_key($this->getRelations($this->moduleModel->getId()), array_flip($fromRelations)))) {
    Severity: Critical
    Found in modules/Vtiger/widgets/Documents.php by phan

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

                $params['uitype'] = 16;
    Severity: Info
    Found in modules/Vtiger/widgets/Documents.php by phan

    Call to method getName on non-class type false
    Open

            return parent::isPermitted() && \App\Relation::getByModule($this->moduleModel->getName(), false, 'Documents');
    Severity: Critical
    Found in modules/Vtiger/widgets/Documents.php by phan

    Reference to undeclared property \Vtiger_Documents_Widget->Data
    Open

                        'url' => OSSMail_Module_Model::getComposeUrl($this->Module, $this->Record, 'Detail', 'new') . '&template=' . $this->Data['email_template'],
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phan

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

    class Vtiger_Documents_Widget extends Vtiger_RelatedModule_Widget

    The class Vtiger_Documents_Widget is not named in CamelCase.
    Open

    class Vtiger_Documents_Widget extends Vtiger_RelatedModule_Widget
    {
        /** {@inheritdoc} */
        public function isPermitted(): bool
        {
    Severity: Minor
    Found in modules/Vtiger/widgets/Documents.php by phpmd

    CamelCaseClassName

    Since: 0.2

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

    Example

    class class_name {
    }

    Source

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

        public function getWidget()

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

            if (!empty($this->Data['email_template']) && \App\Mail::checkInternalMailClient() && \App\Record::isExists($this->Data['email_template'], 'EmailTemplates')

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

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

            if (\App\Privilege::isPermitted($moduleName, 'CreateView')) {

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

        public function getConfigTplName()

    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::isPermitted() && \App\Relation::getByModule($this->moduleModel->getName(), false, 'Documents');

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

            $this->Config['tpl'] = 'Basic.tpl';

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

        {

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

                    'linkclass' => 'btn-light btn-sm js-show-modal',

    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->Config['buttonHeader'] = $this->getHeaderButtons();

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

                    'linklabel' => App\Language::translate('LBL_MASS_ADD', $moduleName),

    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

         */

    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 buttons which visible in header widget.

    Line exceeds 120 characters; contains 152 characters
    Open

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

    Line exceeds 120 characters; contains 145 characters
    Open

                        'url' => 'index.php?module=Documents&view=MassAddDocuments&sourceModule=' . $this->Module . '&sourceRecord=' . $this->Record,

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

                        'view' => 'Detail',

    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

                ->andWhere(['and', ['vtiger_relatedlists.tabid' => new \yii\db\Expression('brl.tabid')], ['brl.related_tabid' => $moduleId], ['brl.name' => 'getDependentsList']])

    Line exceeds 120 characters; contains 145 characters
    Open

            if ($fromRelations && ($relations = array_intersect_key($this->getRelations($this->moduleModel->getId()), array_flip($fromRelations)))) {

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

                $links[] = Vtiger_Link_Model::getInstanceFromValues([

    Line exceeds 120 characters; contains 163 characters
    Open

            if (!empty($this->Data['email_template']) && \App\Mail::checkInternalMailClient() && \App\Record::isExists($this->Data['email_template'], 'EmailTemplates')

    Line exceeds 120 characters; contains 149 characters
    Open

            $dataReader = (new \App\Db\Query())->select(['vtiger_relatedlists.*', 'moduleName' => 'vtiger_tab.name', 'relatedField' => 'brl.field_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

                        'url' => 'index.php?module=Documents&view=MassAddDocuments&sourceModule=' . $this->Module . '&sourceRecord=' . $this->Record,

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

                        'cb' => 'Documents_MassAddDocuments_Js.register',

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

                        'record' => $this->Record,

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

                ->from('vtiger_relatedlists')

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

                ->leftJoin(['brl' => 'vtiger_relatedlists'], 'vtiger_tab.tabid = brl.tabid')

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

                $this->Data['relatedmodule'] = \App\Module::getModuleId('Documents');

    Line exceeds 120 characters; contains 129 characters
    Open

                ->where(['and', ['vtiger_tab.presence' => 0], ['vtiger_relatedlists.related_tabid' => $this->Data['relatedmodule']]])

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

                ->innerJoin('vtiger_tab', 'vtiger_tab.tabid = vtiger_relatedlists.tabid')

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

                $key = ['relatedField' => $row['relatedField'], 'relationId' => $row['relation_id']];

    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

                $relations[\App\Json::encode($key)] = $row;

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

                $fields[] = \Vtiger_Field_Model::init($this->moduleModel->getName(), $params, 'fromRelation');

    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

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

            $relations = [];

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

                $row['translate'] = $this->moduleModel->getFieldByName($row['relatedField'])->getFullLabelTranslation();

    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

            $fields = [];

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

            if ($fromRelations && ($relations = array_intersect_key($this->getRelations($this->moduleModel->getId()), array_flip($fromRelations)))) {

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

                }

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

        /** {@inheritdoc} */

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

        /**

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

        {

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

                    'linkicon' => 'yfi-document-templates',

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

                    'linkhint' => App\Language::translate('LBL_SEND_MAIL', $moduleName),

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

                    'linkdata' => [

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

                        'url' => OSSMail_Module_Model::getComposeUrl($this->Module, $this->Record, 'Detail', 'new') . '&template=' . $this->Data['email_template'],

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

         * Gets relations.

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

         *

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

                ->where(['and', ['vtiger_tab.presence' => 0], ['vtiger_relatedlists.related_tabid' => $this->Data['relatedmodule']]])

    Line exceeds 120 characters; contains 174 characters
    Open

                ->andWhere(['and', ['vtiger_relatedlists.tabid' => new \yii\db\Expression('brl.tabid')], ['brl.related_tabid' => $moduleId], ['brl.name' => 'getDependentsList']])

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

         * Gets custom fields.

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

                $params['uitype'] = 16;

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

            return 'DocumentsConfig';

    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

         * @param int $moduleId

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

        public function getRelations(int $moduleId): array

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

            return $fields;

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

         *

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

            $moduleName = is_numeric($this->Data['relatedmodule']) ? App\Module::getModuleName($this->Data['relatedmodule']) : $this->Data['relatedmodule'];

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

                        'module' => $this->Module,

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

                    'linkclass' => 'btn-light btn-sm sendMailBtn'

    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

            return $relations;

    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

            $fromRelations = (array) ($this->Data['fromRelation'] ?? []);

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

                foreach ($relations as $key => $relation) {

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

            return parent::getWidget();

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

                    'linkdata' => [

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

                        'popup' => 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

        /**

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

                    if (\App\Privilege::isPermitted($relation['moduleName'])) {

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

                    'linkicon' => 'fas fa-envelope',

    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

                    }

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

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

        /**

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

            if (empty($this->moduleModel)) {

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

                $this->moduleModel = Vtiger_Module_Model::getInstance($moduleId);

    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

            $dataReader = (new \App\Db\Query())->select(['vtiger_relatedlists.*', 'moduleName' => 'vtiger_tab.name', 'relatedField' => 'brl.field_name'])

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

                        $params['picklistValues'][$key] = $relation['translate'];

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

        }

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

            if (empty($this->Data['relatedmodule'])) {

    Line exceeds 120 characters; contains 159 characters
    Open

                        'url' => OSSMail_Module_Model::getComposeUrl($this->Module, $this->Record, 'Detail', 'new') . '&template=' . $this->Data['email_template'],

    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 getCustomFields(): array

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

                $params['picklistValues'] = [];

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

    class Vtiger_Documents_Widget extends Vtiger_RelatedModule_Widget

    There are no issues that match your filters.

    Category
    Status