YetiForceCompany/YetiForceCRM

View on GitHub
modules/ModTracker/ModTracker.php

Summary

Maintainability
B
5 hrs
Test Coverage
F
26%

The class ModTracker has 17 fields. Consider redesigning ModTracker to keep the number of fields under 15.
Open

class ModTracker
{
    /**
     * Constant variables which indicates the status of the changed record.
     */
Severity: Minor
Found in modules/ModTracker/ModTracker.php by phpmd

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

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

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

    public static function trackRelation($sourceModule, $sourceId, $targetModule, $targetId, $type)
    {
        $db = App\Db::getInstance();
        $currentUser = Users_Record_Model::getCurrentUserModel();
        $currentTime = date('Y-m-d H:i:s');
Severity: Minor
Found in modules/ModTracker/ModTracker.php - About 1 hr to fix

    Method transferRelation has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public static function transferRelation(string $sourceModule, int $sourceId, string $targetModule, int $targetId, int $process)
    Severity: Minor
    Found in modules/ModTracker/ModTracker.php - About 35 mins to fix

      Method trackRelation has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static function trackRelation($sourceModule, $sourceId, $targetModule, $targetId, $type)
      Severity: Minor
      Found in modules/ModTracker/ModTracker.php - About 35 mins to fix

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

                return (new \App\Db\Query())->from('vtiger_links')
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 '251', column '22').
        Open

                $isMyRecord = (new App\Db\Query())->from('vtiger_crmentity')
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 '190', column '16').
        Open

                    $row = (new \App\Db\Query())->from('vtiger_modtracker_tabs')->where(['tabid' => $tabId])->one();
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 '174', column '20').
        Open

                $isExists = (new \App\Db\Query())->from('vtiger_modtracker_tabs')
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 '322', column '23').
        Open

                    $dataReader = (new \App\Db\Query())
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Db' in method 'trackRelation'.
        Open

                $db = App\Db::getInstance();
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'disableTrackingForModule'.
        Open

                App\Cache::save('isTrackingEnabledForModule', $tabid, false, App\Cache::LONG);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'isTrackingEnabledForModule'.
        Open

                if (App\Cache::has('isTrackingEnabledForModule', $tabId)) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'isTrackingEnabledForModule'.
        Open

                App\Cache::save('isTrackingEnabledForModule', $tabId, $isExists, App\Cache::LONG);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        StaticAccess

        Since: 1.4.0

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

        Example

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

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

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

                } else {
                    $db->createCommand()->update('vtiger_modtracker_tabs', ['visible' => 0], ['tabid' => $tabid])->execute();
                }
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        ElseExpression

        Since: 1.4.0

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

        Example

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

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

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

                App\Cache::save('isTrackingEnabledForModule', $tabid, true, App\Cache::LONG);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'isTrackingEnabledForModule'.
        Open

                    return App\Cache::get('isTrackingEnabledForModule', $tabId);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Config' in method 'linkRelation'.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'linkRelation'.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\EventHandler' in method 'moduleHandler'.
        Open

                    \App\EventHandler::setInActive('ModTracker_ModTrackerHandler_Handler');
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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_HistoryRelation_Widget' in method 'linkRelation'.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'enableTrackingForModule'.
        Open

                \App\Cache::delete('getTrackingModules', 'all');
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'isViewPermitted'.
        Open

                if (\App\Privilege::isPermitted($moduleName, 'DetailView', $recordId)) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'ModTracker_Record_Model' in method 'trackRelation'.
        Open

                ModTracker_Record_Model::unsetReviewed($sourceId, $currentUser->getRealId(), $id);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'vtlib\Module' in method 'enableTrackingForModule'.
        Open

                $moduleInstance = vtlib\Module::getInstance($tabid);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Db' in method 'disableTrackingForModule'.
        Open

                $db = \App\Db::getInstance();
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'vtlib\Module' in method 'disableTrackingForModule'.
        Open

                $moduleInstance = vtlib\Module::getInstance($tabid);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'isTrackingEnabledForModule'.
        Open

                $tabId = \App\Module::getModuleId($moduleName);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'isModulePresent'.
        Open

                if (!App\Cache::has('isTrackingEnabledForModule', $tabId)) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'isModulePresent'.
        Open

                        App\Cache::save('isTrackingEnabledForModule', $tabId, (bool) $row['visible'], App\Cache::LONG);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        StaticAccess

        Since: 1.4.0

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

        Example

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

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

        Avoid using static access to class 'Users_Record_Model' in method 'trackRelation'.
        Open

                $currentUser = Users_Record_Model::getCurrentUserModel();
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\EventHandler' in method 'moduleHandler'.
        Open

                    \App\EventHandler::setActive('ModTracker_ModTrackerHandler_Handler');
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'disableTrackingForModule'.
        Open

                \App\Cache::delete('getTrackingModules', 'all');
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'ModTracker_Record_Model' in method 'linkRelation'.
        Open

                    ModTracker_Record_Model::setLastRelation($sourceId, $sourceModule);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'getTrackingModules'.
        Open

                    $modules = App\Cache::get(__FUNCTION__, $cacheName);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'getTrackingModules'.
        Open

                        App\Cache::save('isTrackingEnabledForModule', $row['tabid'], true, App\Cache::LONG);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'unLinkRelation'.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Config' in method 'transferRelation'.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        StaticAccess

        Since: 1.4.0

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

        Example

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

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

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

                } else {
                    \App\Db::getInstance()->createCommand()->update('vtiger_modtracker_tabs', ['visible' => 1], ['tabid' => $tabid])->execute();
                }
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        ElseExpression

        Since: 1.4.0

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

        Example

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

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

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

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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_HistoryRelation_Widget' in method 'unLinkRelation'.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'getTrackingModules'.
        Open

                    App\Cache::save(__FUNCTION__, $cacheName, $modules);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Config' in method 'unLinkRelation'.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'ModTracker_Record_Model' in method 'unLinkRelation'.
        Open

                    ModTracker_Record_Model::setLastRelation($sourceId, $sourceModule);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        StaticAccess

        Since: 1.4.0

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

        Example

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

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

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

                } else {
                    $dataReader = (new \App\Db\Query())
                        ->select(['vtiger_tab.tabid', 'vtiger_tab.name'])
                        ->from('vtiger_tab')
                        ->innerJoin('vtiger_modtracker_tabs', 'vtiger_modtracker_tabs.tabid = vtiger_tab.tabid')
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        ElseExpression

        Since: 1.4.0

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

        Example

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

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

        Avoid using static access to class 'Vtiger_HistoryRelation_Widget' in method 'transferRelation'.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 'ModTracker_Record_Model' in method 'transferRelation'.
        Open

                    ModTracker_Record_Model::setLastRelation($sourceId, $sourceModule);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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\Cache' in method 'getTrackingModules'.
        Open

                if (App\Cache::has(__FUNCTION__, $cacheName)) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.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 "isTrackingEnabledForModule" 8 times.
        Open

                App\Cache::save('isTrackingEnabledForModule', $tabid, false, App\Cache::LONG);
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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 "crmid" 3 times.
        Open

                    'crmid' => $sourceId,
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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 "visible" 5 times.
        Open

                    $db->createCommand()->insert('vtiger_modtracker_tabs', ['tabid' => $tabid, 'visible' => 0])->execute();
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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 "View History" 3 times.
        Open

                    $moduleInstance->deleteLink('DETAIL_VIEW_ADDITIONAL', 'View History');
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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 "DETAIL_VIEW_ADDITIONAL" 3 times.
        Open

                    $moduleInstance->deleteLink('DETAIL_VIEW_ADDITIONAL', 'View History');
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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 "TimeLineList" 3 times.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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 "vtiger_modtracker_tabs" 7 times.
        Open

                    $db->createCommand()->insert('vtiger_modtracker_tabs', ['tabid' => $tabid, 'visible' => 0])->execute();
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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.

        Remove the unused function parameter "$moduleName".
        Open

            public function moduleHandler($moduleName, $eventType)
        Severity: Major
        Found in modules/ModTracker/ModTracker.php by sonar-php

        Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

        Noncompliant Code Example

        function doSomething($a, $b) { // "$a" is unused
          return compute($b);
        }
        

        Compliant Solution

        function doSomething($b) {
          return compute($b);
        }
        

        Exceptions

        Functions in classes that override a class or implement interfaces are ignored.

        class C extends B {
        
          function doSomething($a, $b) {     // no issue reported on $b
            compute($a);
          }
        
        }
        

        See

        • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
        • MISRA C:2012, 2.7 - There should be no unused parameters in functions
        • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
        • CERT, MSC12-CPP. - Detect and remove code that has no effect

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

                    ->update('vtiger_field', ['presence' => 1], ['tabid' => $tabid, 'fieldname' => 'was_read'])
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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 "SHOW_TIMELINE_IN_LISTVIEW" 3 times.
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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 "ModTracker" 6 times.
        Open

                $moduleInstance->disableTools('ModTracker');
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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 "tabid" 10 times.
        Open

                    $db->createCommand()->insert('vtiger_modtracker_tabs', ['tabid' => $tabid, 'visible' => 0])->execute();
        Severity: Critical
        Found in modules/ModTracker/ModTracker.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.

        Avoid unused parameters such as '$moduleName'.
        Open

            public function moduleHandler($moduleName, $eventType)
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        UnusedFormalParameter

        Since: 0.2

        Avoid passing parameters to methods or constructors and then not using those parameters.

        Example

        class Foo
        {
            private function bar($howdy)
            {
                // $howdy is not used
            }
        }

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

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

                $db->createCommand()
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

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

                    $db->createCommand()->update('vtiger_modtracker_tabs', ['visible' => 0], ['tabid' => $tabid])->execute();
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

        Argument 2 (key) is int but \App\Cache::save() takes string defined at /code/app/Cache.php:89
        Open

                App\Cache::save('isTrackingEnabledForModule', $tabid, false, App\Cache::LONG);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phan

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

                    $db->createCommand()->insert('vtiger_modtracker_tabs', ['tabid' => $tabid, 'visible' => 0])->execute();
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

        Argument 2 (key) is int but \App\Cache::save() takes string defined at /code/app/Cache.php:89
        Open

                App\Cache::save('isTrackingEnabledForModule', $tabid, true, App\Cache::LONG);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phan

        Argument 2 (key) is bool|int but \App\Cache::get() takes string defined at /code/app/Cache.php:61
        Open

                    return App\Cache::get('isTrackingEnabledForModule', $tabId);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phan

        Argument 2 (key) is int but \App\Cache::has() takes string defined at /code/app/Cache.php:74
        Open

                if (!App\Cache::has('isTrackingEnabledForModule', $tabId)) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phan

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

                    \App\Db::getInstance()->createCommand()->insert('vtiger_modtracker_tabs', ['tabid' => $tabid, 'visible' => 1])->execute();
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

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

                $db->createCommand()->insert('vtiger_modtracker_basic', [
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

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

                    $dataReader = (new \App\Db\Query())
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

        Argument 2 (key) is bool|int but \App\Cache::has() takes string defined at /code/app/Cache.php:74
        Open

                if (App\Cache::has('isTrackingEnabledForModule', $tabId)) {
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phan

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

                $isExists = (new \App\Db\Query())->from('vtiger_modtracker_tabs')
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

        Argument 2 (key) is int but \App\Cache::save() takes string defined at /code/app/Cache.php:89
        Open

                        App\Cache::save('isTrackingEnabledForModule', $tabId, (bool) $row['visible'], App\Cache::LONG);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phan

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

                    $db->createCommand()
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

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

                return (new \App\Db\Query())->from('vtiger_links')
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

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

                $isMyRecord = (new App\Db\Query())->from('vtiger_crmentity')
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

        Argument 2 (key) is bool|int but \App\Cache::save() takes string defined at /code/app/Cache.php:89
        Open

                App\Cache::save('isTrackingEnabledForModule', $tabId, $isExists, App\Cache::LONG);
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phan

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

                $db->createCommand()->insert('vtiger_modtracker_relations', [
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

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

                    \App\Db::getInstance()->createCommand()->update('vtiger_modtracker_tabs', ['visible' => 1], ['tabid' => $tabid])->execute();
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

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

                    $row = (new \App\Db\Query())->from('vtiger_modtracker_tabs')->where(['tabid' => $tabId])->one();
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

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

                \App\Db::getInstance()->createCommand()->update('vtiger_field', ['presence' => 2], ['tabid' => $tabid, 'fieldname' => 'was_read'])->execute();
        Severity: Critical
        Found in modules/ModTracker/ModTracker.php by phan

        Either remove or fill this block of code.
        Open

                if ('module.postinstall' === $eventType) {
                } elseif ('module.disabled' === $eventType) {
        Severity: Major
        Found in modules/ModTracker/ModTracker.php by sonar-php

        Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.

        Noncompliant Code Example

        for ($i = 0; $i < 42; $i++){}  // Empty on purpose or missing piece of code ?
        

        Exceptions

        When a block contains a comment, this block is not considered to be empty.

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

            public static function linkRelation($sourceModule, $sourceId, $targetModule, $targetId)
            {
                self::trackRelation($sourceModule, $sourceId, $targetModule, $targetId, self::$LINK);
                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
                    ModTracker_Record_Model::setLastRelation($sourceId, $sourceModule);
        Severity: Major
        Found in modules/ModTracker/ModTracker.php and 1 other location - About 1 hr to fix
        modules/ModTracker/ModTracker.php on lines 286..292

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 115.

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

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

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

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

        Refactorings

        Further Reading

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

            public static function unLinkRelation($sourceModule, $sourceId, $targetModule, $targetId)
            {
                self::trackRelation($sourceModule, $sourceId, $targetModule, $targetId, self::$UNLINK);
                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {
                    ModTracker_Record_Model::setLastRelation($sourceId, $sourceModule);
        Severity: Major
        Found in modules/ModTracker/ModTracker.php and 1 other location - About 1 hr to fix
        modules/ModTracker/ModTracker.php on lines 270..276

        Duplicated Code

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

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

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

        Tuning

        This issue has a mass of 115.

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

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

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

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

        Refactorings

        Further Reading

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

        class ModTracker

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

                $id = $db->getLastInsertID('vtiger_modtracker_basic_id_seq');
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

        The property $SHOW_HIDDEN_DATA is not named in camelCase.
        Open

        class ModTracker
        {
            /**
             * Constant variables which indicates the status of the changed record.
             */
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        CamelCasePropertyName

        Since: 0.2

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

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        The property $TRANSFER_EDIT is not named in camelCase.
        Open

        class ModTracker
        {
            /**
             * Constant variables which indicates the status of the changed record.
             */
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        CamelCasePropertyName

        Since: 0.2

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

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        The property $TRANSFER_UNLINK is not named in camelCase.
        Open

        class ModTracker
        {
            /**
             * Constant variables which indicates the status of the changed record.
             */
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        CamelCasePropertyName

        Since: 0.2

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

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        The property $TRANSFER_LINK is not named in camelCase.
        Open

        class ModTracker
        {
            /**
             * Constant variables which indicates the status of the changed record.
             */
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        CamelCasePropertyName

        Since: 0.2

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

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        The property $TRANSFER_DELETE is not named in camelCase.
        Open

        class ModTracker
        {
            /**
             * Constant variables which indicates the status of the changed record.
             */
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        CamelCasePropertyName

        Since: 0.2

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

        Example

        class ClassName {
            protected $property_name;
        }

        Source

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

                $db = \App\Db::getInstance();
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

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

                $db = App\Db::getInstance();
        Severity: Minor
        Found in modules/ModTracker/ModTracker.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

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

             * Icon actions.

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

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

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

             */

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

            public static $TRANSFER_DELETE = 11;

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

                4 => 'fas fa-link',

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

            /**

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

            public static $LINK = 4;

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

            public static $TRANSFER_EDIT = 10;

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

            ];

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

             * Colors actions.

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

            /**

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

                8 => '#0032a2',

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

             */

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

                7 => 'fas fa-th-list',

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

            public static $colorsActions = [

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

                0 => '#9c27b0',

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

            public static $TRANSFER_LINK = 13;

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

            public static $iconActions = [

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

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

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

                6 => '#e2e3e5',

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

             * Constant variables which indicates the status of the changed record.

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

            public static $CONVERTTOACCOUNT = 6;

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

            public static $TRANSFER_UNLINK = 12;

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

            /**

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

             * @var array

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

                7 => '#65a9ff',

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

                5 => 'fas fa-unlink',

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

                14 => 'fas fa-eye',

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

            {

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

                    static::$ARCHIVED => 'LBL_AT_ARCHIVED',

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

             * Invoked when special actions are performed on the module.

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

                } elseif ('module.enabled' === $eventType) {

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

                $db->createCommand()

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

            public function enableTrackingForModule($tabid)

        Line exceeds 120 characters; contains 150 characters
        Open

                \App\Db::getInstance()->createCommand()->update('vtiger_field', ['presence' => 2], ['tabid' => $tabid, 'fieldname' => 'was_read'])->execute();

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

             *

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

                    ->exists();

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

                return $isExists;

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

             */

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

            public static $TRASH = 1;

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

             * @param int $tabid

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

            public static $UNLINK = 5;

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

            public static $ARCHIVED = 8;

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

                2 => 'fas fa-plus',

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

                13 => 'fas fa-link',

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

            ];

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

                    static::$UNLINK => 'LBL_AT_UNLINK',

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

                    \App\EventHandler::setInActive('ModTracker_ModTrackerHandler_Handler');

        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

                6 => 'fas fa-exchange-alt',

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

                8 => 'fas fa-archive',

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

                9 => 'fas fa-eraser',

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

                12 => 'fas fa-unlink',

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

             *

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

                10 => '#000',

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

                    \App\EventHandler::setActive('ModTracker_ModTrackerHandler_Handler');

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

                \App\Cache::delete('getTrackingModules', 'all');

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

             *

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

             */

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

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

            public static $CREATED = 2;

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

            public static $DISPLAYED = 7;

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

            public static $DELETED = 9;

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

                3 => 'fas fa-undo-alt',

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

                2 => '#607d8b',

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

                12 => '#000',

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

                    static::$TRANSFER_DELETE => 'LBL_AT_TRANSFER_DELETE',

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

                    static::$SHOW_HIDDEN_DATA => 'LBL_SHOW_HIDDEN_DATA',

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

                ];

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

                } elseif ('module.disabled' === $eventType) {

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

                if (!static::isModulePresent($tabid)) {

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

                $moduleInstance->disableTools('ModTracker');

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

            }

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

                $moduleInstance = vtlib\Module::getInstance($tabid);

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

                $moduleInstance->enableTools('ModTracker');

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

                \App\Cache::delete('getTrackingModules', 'all');

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

                $tabId = \App\Module::getModuleId($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

                    return true;

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

            public static $ACTIVE = 3;

        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

                } else {

        Line exceeds 120 characters; contains 136 characters
        Open

                    \App\Db::getInstance()->createCommand()->update('vtiger_modtracker_tabs', ['visible' => 1], ['tabid' => $tabid])->execute();

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

                $isExists = (new \App\Db\Query())->from('vtiger_modtracker_tabs')

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

             * @param int $tabId

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

                    ->exists();

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

            public static function isViewPermitted(vtlib\LinkData $linkData)

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

             * @var array

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

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

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

             */

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

                3 => '#009405',

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

                4 => '#009cb9',

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

             * @param string $eventType

        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 disableTrackingForModule($tabid)

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

                    $db->createCommand()->update('vtiger_modtracker_tabs', ['visible' => 0], ['tabid' => $tabid])->execute();

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

                    ->execute();

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

             * @param int $tabid

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

                if (!static::isModulePresent($tabid)) {

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

                }

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

                App\Cache::save('isTrackingEnabledForModule', $tabid, true, App\Cache::LONG);

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

            }

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

                    $row = (new \App\Db\Query())->from('vtiger_modtracker_tabs')->where(['tabid' => $tabId])->one();

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

                    return false;

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

            /**

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

             * Invoked to check if ModTracker links are enabled for the module.

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

            public static function isModtrackerLinkPresent($tabid)

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

            }

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

            /**

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

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

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

                1 => '#ab0505',

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

                5 => '#de9100',

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

                9 => '#000',

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

                14 => '#000',

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

                return [

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

                    static::$UPDATED => 'LBL_AT_UPDATE',

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

                    static::$TRASH => 'LBL_AT_TRASH',

        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 moduleHandler($moduleName, $eventType)

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

            {

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

                App\Cache::save('isTrackingEnabledForModule', $tabid, false, App\Cache::LONG);

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

                    $moduleInstance->addLink('DETAIL_VIEW_ADDITIONAL', 'View History', "javascript:ModTrackerCommon.showhistory('\$RECORD\$')", '', '', ['path' => 'modules/ModTracker/ModTracker.php', 'class' => 'ModTracker', 'method' => 'isViewPermitted']);

        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

             * Invoked to check if the module is present in the table or not.

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

            public static function isModulePresent($tabId)

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

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

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

            public static $UPDATED = 0;

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

            public static $SHOW_HIDDEN_DATA = 14;

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

                    static::$TRANSFER_EDIT => 'LBL_AT_TRANSFER_EDIT',

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

                }

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

                $moduleInstance = vtlib\Module::getInstance($tabid);

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

                    $moduleInstance->deleteLink('DETAIL_VIEW_ADDITIONAL', 'View History');

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

                    ->update('vtiger_field', ['presence' => 1], ['tabid' => $tabid, 'fieldname' => 'was_read'])

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

            {

        Line exceeds 120 characters; contains 249 characters
        Open

                    $moduleInstance->addLink('DETAIL_VIEW_ADDITIONAL', 'View History', "javascript:ModTrackerCommon.showhistory('\$RECORD\$')", '', '', ['path' => 'modules/ModTracker/ModTracker.php', 'class' => 'ModTracker', 'method' => 'isViewPermitted']);

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

                if (!App\Cache::has('isTrackingEnabledForModule', $tabId)) {

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

                    ->where(['linktype' => 'DETAIL_VIEW_ADDITIONAL', 'linklabel' => 'View History', 'tabid' => $tabid])

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

             *

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

                $moduleName = $linkData->getModule();

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

                }

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

                    static::$CREATED => 'LBL_AT_CREATE',

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

                    static::$CONVERTTOACCOUNT => 'LBL_AT_CONVERTTOACCOUNT',

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

                if (static::isModtrackerLinkPresent($tabid)) {

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

                        App\Cache::save('isTrackingEnabledForModule', $tabId, (bool) $row['visible'], App\Cache::LONG);

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

             * @return bool

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

             */

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

                13 => '#000',

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

                    static::$LINK => 'LBL_AT_LINK',

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

                    ->where(['vtiger_modtracker_tabs.visible' => 1, 'vtiger_modtracker_tabs.tabid' => $tabId])

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

                return true;

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

                    'whodid' => $currentUser->getRealId(),

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

             * @param int    $sourceId

        Line exceeds 120 characters; contains 237 characters
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {

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

            {

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

                    $dataReader->close();

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

                }

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

                11 => '#000',

        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 ('module.postinstall' === $eventType) {

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

            }

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

             * Invoked to disable tracking for the 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

             * Invoked to enable tracking for the module.

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

                    \App\Db::getInstance()->createCommand()->insert('vtiger_modtracker_tabs', ['tabid' => $tabid, 'visible' => 1])->execute();

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

                } else {

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

            /**

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

             *

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

             * This function checks access to the view.

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

                $recordId = $linkData->getInputParameter('record');

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

                    $db->createCommand()

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

             *

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

             *

        Line exceeds 120 characters; contains 237 characters
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {

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

            public static function getTrackingModules(): array

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

                        ->where(['vtiger_modtracker_tabs.visible' => 1, 'vtiger_tab.presence' => 0, 'vtiger_tab.isentitytype' => 1])

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

                        App\Cache::save('isTrackingEnabledForModule', $row['tabid'], true, App\Cache::LONG);

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

             * @param string $moduleName

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

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

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

             * Invoked to check if tracking is enabled or disabled for the module.

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

             * @param string $moduleName

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

                    if ($row) {

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

                    }

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

             *

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

                    'last_reviewed_users' => '#' . $currentUser->getRealId() . '#'

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

             * Function is executed when adding related record.

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

             * @param int    $targetId

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

                }

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

                    ModTracker_Record_Model::setLastRelation($sourceId, $sourceModule);

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

                }

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

                        ->from('vtiger_tab')

        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

                    }

        Line exceeds 120 characters; contains 237 characters
        Open

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {

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

            }

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

             * @param string $sourceModule

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

             * @param string $targetModule

        Line exceeds 120 characters; contains 131 characters
        Open

            public static function transferRelation(string $sourceModule, int $sourceId, string $targetModule, int $targetId, int $process)

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

                    ModTracker_Record_Model::setLastRelation($sourceId, $sourceModule);

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

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

                    static::$ACTIVE => 'LBL_AT_ACTIVE',

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

                    static::$DELETED => 'LBL_AT_DELETE',

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

                    $db->createCommand()->insert('vtiger_modtracker_tabs', ['tabid' => $tabid, 'visible' => 0])->execute();

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

                    return App\Cache::get('isTrackingEnabledForModule', $tabId);

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

                }

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

             */

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

                $currentTime = date('Y-m-d H:i:s');

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

                }

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

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {

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

             * @param string $targetModule

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

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {

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

                $cacheName = 'all';

        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

            }

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

             */

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

                \App\Db::getInstance()->createCommand()->update('vtiger_field', ['presence' => 2], ['tabid' => $tabid, 'fieldname' => 'was_read'])->execute();

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

            }

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

                if (App\Cache::has('isTrackingEnabledForModule', $tabId)) {

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

                }

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

                        return true;

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

            }

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

                    'module' => $sourceModule,

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

                ModTracker_Record_Model::unsetReviewed($sourceId, $currentUser->getRealId(), $id);

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

                $db->createCommand()->insert('vtiger_modtracker_relations', [

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

                    'changedon' => $currentTime,

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

                ])->execute();

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

                if ($isMyRecord) {

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

            {

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

             * @param int    $targetId

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

                        ->select(['vtiger_tab.tabid', 'vtiger_tab.name'])

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

                        $modules[$row['tabid']] = $row['name'];

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

            public static function getAllActionsTypes()

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

                    static::$DISPLAYED => 'LBL_AT_DISPLAY',

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

            {

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

            /**

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

             * @param int $tabid

        Line exceeds 120 characters; contains 134 characters
        Open

                    \App\Db::getInstance()->createCommand()->insert('vtiger_modtracker_tabs', ['tabid' => $tabid, 'visible' => 1])->execute();

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

                    \App\Db::getInstance()->createCommand()->update('vtiger_modtracker_tabs', ['visible' => 1], ['tabid' => $tabid])->execute();

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

                if (static::isModtrackerLinkPresent($tabid)) {

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

            {

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

             * @param \vtlib\LinkData $linkData

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

            {

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

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

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

            }

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

                    static::$TRANSFER_UNLINK => 'LBL_AT_TRANSFER_UNLINK',

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

                    static::$TRANSFER_LINK => 'LBL_AT_TRANSFER_LINK',

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

             */

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

                App\Cache::save('isTrackingEnabledForModule', $tabId, $isExists, App\Cache::LONG);

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

            /**

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

                return (new \App\Db\Query())->from('vtiger_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

             * @param int    $targetId

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

                return false;

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

            public static function trackRelation($sourceModule, $sourceId, $targetModule, $targetId, $type)

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

                    'changedon' => $currentTime,

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

                $id = $db->getLastInsertID('vtiger_modtracker_basic_id_seq');

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

                    ->where(['<>', 'smownerid', $currentUser->getRealId()])

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

             * @param string $sourceModule

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

            {

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

                if (\in_array($targetModule, Vtiger_HistoryRelation_Widget::getActions()) && \in_array($sourceModule, App\Config::module('ModTracker', 'SHOW_TIMELINE_IN_LISTVIEW')) && \App\Privilege::isPermitted($sourceModule, 'TimeLineList')) {

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

             * @param int    $process

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

             * Function gives an array of module names for which tracking is enabled.

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

                    App\Cache::save(__FUNCTION__, $cacheName, $modules);

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

            {

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

                    'crmid' => $sourceId,

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

                self::trackRelation($sourceModule, $sourceId, $targetModule, $targetId, self::$LINK);

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

             * Function is executed when removing related 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

             * Transfer relation.

        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

                    'status' => $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

             * @param int    $sourceId

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

            {

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

            }

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

             *

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

                if (App\Cache::has(__FUNCTION__, $cacheName)) {

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

                $db->createCommand()->insert('vtiger_modtracker_basic', [

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

                    ->andWhere(['crmid' => $sourceId])

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

            public static function linkRelation($sourceModule, $sourceId, $targetModule, $targetId)

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

                    ModTracker_Record_Model::setLastRelation($sourceId, $sourceModule);

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

             * @param int    $sourceId

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

            public static function unLinkRelation($sourceModule, $sourceId, $targetModule, $targetId)

        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

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

        Line exceeds 120 characters; contains 124 characters
        Open

                        ->where(['vtiger_modtracker_tabs.visible' => 1, 'vtiger_tab.presence' => 0, 'vtiger_tab.isentitytype' => 1])

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

                $currentUser = Users_Record_Model::getCurrentUserModel();

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

                ])->execute();

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

                    ->exists();

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

                        ->execute();

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

             */

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

                self::trackRelation($sourceModule, $sourceId, $targetModule, $targetId, $process);

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

                    'targetmodule' => $targetModule,

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

                $isMyRecord = (new App\Db\Query())->from('vtiger_crmentity')

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

                        ->update('vtiger_crmentity', ['was_read' => 0], ['crmid' => $sourceId])

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

            public static function transferRelation(string $sourceModule, int $sourceId, string $targetModule, int $targetId, int $process)

        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' => $id,

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

             * @param string $targetModule

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

             * @param string $sourceModule

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

                self::trackRelation($sourceModule, $sourceId, $targetModule, $targetId, self::$UNLINK);

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

             */

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

                    $modules = App\Cache::get(__FUNCTION__, $cacheName);

        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

                        ->createCommand()->query();

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

                    'targetid' => $targetId,

        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

                    $modules = [];

        There are no issues that match your filters.

        Category
        Status