YetiForceCompany/YetiForceCRM

View on GitHub
modules/Calendar/models/Record.php

Summary

Maintainability
D
2 days
Test Coverage
F
41%

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

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

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

    class Calendar_Record_Model extends Vtiger_Record_Model
    {
        /**
         *  Show Reminder popup.
         */
    Severity: Minor
    Found in modules/Calendar/models/Record.php by phpmd

    Calendar_Record_Model has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Calendar_Record_Model extends Vtiger_Record_Model
    {
        /**
         *  Show Reminder popup.
         */
    Severity: Minor
    Found in modules/Calendar/models/Record.php - About 2 hrs to fix

      Function insertIntoInviteTable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function insertIntoInviteTable()
          {
              if (!\App\Request::_has('inviteesid')) {
                  \App\Log::info('No invitations in request, Exiting insertIntoInviteeTable method ...');
                  return;
      Severity: Minor
      Found in modules/Calendar/models/Record.php - About 1 hr to fix

      Cognitive Complexity

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

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

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

      Further reading

      Method updateReminderPostpone has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function updateReminderPostpone(string $time)
          {
              switch ($time) {
                  case '15m':
                      $datatime = date('Y-m-d H:i:s', strtotime('+15 min'));
      Severity: Minor
      Found in modules/Calendar/models/Record.php - About 1 hr to fix

        Function setCrmActivity has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function setCrmActivity($referenceIds, $refModuleName = null)
            {
                $db = \App\Db::getInstance();
                foreach ($referenceIds as $id => $fieldName) {
                    if (empty($fieldName)) {
        Severity: Minor
        Found in modules/Calendar/models/Record.php - About 1 hr to fix

        Cognitive Complexity

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

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

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

        Further reading

        Method insertIntoInviteTable has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function insertIntoInviteTable()
            {
                if (!\App\Request::_has('inviteesid')) {
                    \App\Log::info('No invitations in request, Exiting insertIntoInviteeTable method ...');
                    return;
        Severity: Minor
        Found in modules/Calendar/models/Record.php - About 1 hr to fix

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

              public function insertIntoActivityReminderPopup()
              {
                  $cbrecord = $this->getId();
                  if (!empty($cbrecord)) {
                      $cbdate = $this->get('date_start');
          Severity: Minor
          Found in modules/Calendar/models/Record.php - About 1 hr to fix

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

                public function updateReminderPostpone(string $time)
                {
                    switch ($time) {
                        case '15m':
                            $datatime = date('Y-m-d H:i:s', strtotime('+15 min'));
            Severity: Minor
            Found in modules/Calendar/models/Record.php - About 1 hr to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                public function updateActivityReminder()
                {
                    if (!$this->isNew() && false === $this->getPreviousValue('reminder_time')) {
                        return false;
                    }
            Severity: Minor
            Found in modules/Calendar/models/Record.php - About 35 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                public function insertIntoActivityReminderPopup()
                {
                    $cbrecord = $this->getId();
                    if (!empty($cbrecord)) {
                        $cbdate = $this->get('date_start');
            Severity: Minor
            Found in modules/Calendar/models/Record.php - About 35 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

            Function getRecordRelatedListViewLinksLeftSide has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getRecordRelatedListViewLinksLeftSide(Vtiger_RelationListView_Model $viewModel)
                {
                    $links = parent::getRecordRelatedListViewLinksLeftSide($viewModel);
                    if ($viewModel->getRelationModel()->isEditable() && $this->isEditable()) {
                        if (\in_array($this->getValueByField('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {
            Severity: Minor
            Found in modules/Calendar/models/Record.php - About 25 mins to fix

            Cognitive Complexity

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

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

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

            Further reading

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

            class Calendar_Record_Model extends Vtiger_Record_Model

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

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

            class Calendar_Record_Model extends Vtiger_Record_Model
            {
                /**
                 *  Show Reminder popup.
                 */
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phpmd

            CouplingBetweenObjects

            Since: 1.1.0

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

            Example

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

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

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

                public static function getInvitionStatus($status = false)
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phpmd

            BooleanArgumentFlag

            Since: 1.4.0

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

            Example

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

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

            Missing class import via use statement (line '130', column '35').
            Open

                        $activityReminderExists = (new \App\Db\Query())->select(['activity_id'])
            Severity: Minor
            Found in modules/Calendar/models/Record.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 '169', column '22').
            Open

                    $dataReader = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $this->getId()])->createCommand()->query();
            Severity: Minor
            Found in modules/Calendar/models/Record.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 '264', column '12').
            Open

                    if ((new App\Db\Query())->select(['value'])->from('vtiger_calendar_config')
            Severity: Minor
            Found in modules/Calendar/models/Record.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 '63', column '16').
            Open

                        $row = (new \App\Db\Query())->select(['vtiger_activity.status', 'vtiger_activity.date_start'])
            Severity: Minor
            Found in modules/Calendar/models/Record.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 '178', column '16').
            Open

                                throw new \App\Exceptions\Security('ERR_ILLEGAL_FIELD_VALUE||inviteesid||Calendar||' . $invitation[0], 406);
            Severity: Minor
            Found in modules/Calendar/models/Record.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 '395', column '15').
            Open

                    return (new \App\Db\Query())
            Severity: Minor
            Found in modules/Calendar/models/Record.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 '267', column '16').
            Open

                        $row = (new App\Db\Query())->select(['date_start', 'time_start', 'due_date', 'time_end'])
            Severity: Minor
            Found in modules/Calendar/models/Record.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 '207', column '23').
            Open

                        $reminderid = (new \App\Db\Query())->select(['reminderid'])->from('vtiger_activity_reminder_popup')
            Severity: Minor
            Found in modules/Calendar/models/Record.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 'Vtiger_Module_Model' in method 'getNameByReference'.
            Open

                    $parentModuleModel = Vtiger_Module_Model::getInstance($refModuleName);
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                        $fieldModel = Vtiger_Module_Model::getInstance($refModuleName ?? \App\Record::getType($id))->getFieldByName('crmactivity');
            Severity: Minor
            Found in modules/Calendar/models/Record.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_Cache' in method 'getNameByReference'.
            Open

                        Vtiger_Cache::set('NameRelatedField', $refModuleName . '-Calendar', $fieldName);
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                        if (empty($fieldName) || !\App\Record::isExists($id)) {
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                    $relatedModule = Vtiger_Module_Model::getInstance('Calendar');
            Severity: Minor
            Found in modules/Calendar/models/Record.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_Relation_Model' in method 'getNameByReference'.
            Open

                    $relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
            Severity: Minor
            Found in modules/Calendar/models/Record.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 'setCrmActivity'.
            Open

                    $db = \App\Db::getInstance();
            Severity: Minor
            Found in modules/Calendar/models/Record.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_Cache' in method 'getNameByReference'.
            Open

                    $fieldName = Vtiger_Cache::get('NameRelatedField', $refModuleName . '-Calendar');
            Severity: Minor
            Found in modules/Calendar/models/Record.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\Fields\DateTime' in method 'setCrmActivity'.
            Open

                            $db->createCommand()->update('vtiger_entity_stats', ['crmactivity' => (int) \App\Fields\DateTime::getDiff(date('Y-m-d'), $row['date_start'], '%r%a')], ['crmid' => $id])->execute();
            Severity: Minor
            Found in modules/Calendar/models/Record.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\Request' in method 'insertIntoInviteTable'.
            Open

                    if (!\App\Request::_has('inviteesid')) {
            Severity: Minor
            Found in modules/Calendar/models/Record.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 'Calendar_Module_Model' in method 'setCrmActivity'.
            Open

                            ->where(['vtiger_crmentity.deleted' => 0, "vtiger_activity.$fieldName" => $id, 'vtiger_activity.status' => Calendar_Module_Model::getComponentActivityStateLabel('current')])
            Severity: Minor
            Found in modules/Calendar/models/Record.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 updateReminderPostpone 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_activity_reminder_popup', [
                                'status' => self::REMNDER_POPUP_WAIT,
                                'datetime' => $datatime
            Severity: Minor
            Found in modules/Calendar/models/Record.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

            The method setCrmActivity 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_entity_stats'), ['crmactivity' => null], ['crmid' => $id])->execute();
                        }
            Severity: Minor
            Found in modules/Calendar/models/Record.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\Log' in method 'insertIntoInviteTable'.
            Open

                        \App\Log::info('No invitations in request, Exiting insertIntoInviteeTable method ...');
            Severity: Minor
            Found in modules/Calendar/models/Record.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 'updateActivityReminder'.
            Open

                    $db = \App\Db::getInstance();
            Severity: Minor
            Found in modules/Calendar/models/Record.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 'Calendar_Module_Model' in method 'insertIntoActivityReminderPopup'.
            Open

                        $state = Calendar_Module_Model::getCalendarState($this->getData());
            Severity: Minor
            Found in modules/Calendar/models/Record.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 'insertIntoInviteTable'.
            Open

                    $db = App\Db::getInstance();
            Severity: Minor
            Found in modules/Calendar/models/Record.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\Validator' in method 'insertIntoInviteTable'.
            Open

                            if (\App\TextUtils::getTextLength($invitation[0]) > 100 || !\App\Validator::email($invitation[0])) {
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phpmd

            StaticAccess

            Since: 1.4.0

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

            Example

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

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

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

                        $links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink);
            Severity: Minor
            Found in modules/Calendar/models/Record.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 'Calendar_Module_Model' in method 'insertIntoActivityReminderPopup'.
            Open

                        $currentStates = Calendar_Module_Model::getComponentActivityStateLabel('current');
            Severity: Minor
            Found in modules/Calendar/models/Record.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 'Calendar_Module_Model' in method 'getRecordRelatedListViewLinksLeftSide'.
            Open

                        if (\in_array($this->getValueByField('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {
            Severity: Minor
            Found in modules/Calendar/models/Record.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 'Calendar_Module_Model' in method 'getRecordListViewLinksLeftSide'.
            Open

                    $statuses = Calendar_Module_Model::getComponentActivityStateLabel('current');
            Severity: Minor
            Found in modules/Calendar/models/Record.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\TextUtils' in method 'insertIntoInviteTable'.
            Open

                            if (\App\TextUtils::getTextLength($invitation[0]) > 100 || !\App\Validator::email($invitation[0])) {
            Severity: Minor
            Found in modules/Calendar/models/Record.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 insertIntoInviteTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                            } else {
                                $db->createCommand()->insert('u_#__activity_invitation', [
                                    'email' => $invitation[0],
                                    'crmid' => (int) $invitation[1],
                                    'name' => $invitation[3],
            Severity: Minor
            Found in modules/Calendar/models/Record.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\Log' in method 'insertIntoInviteTable'.
            Open

                    \App\Log::trace('Exiting ' . __METHOD__);
            Severity: Minor
            Found in modules/Calendar/models/Record.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 insertIntoActivityReminderPopup uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                        } else {
                            $status = self::REMNDER_POPUP_INACTIVE;
                        }
            Severity: Minor
            Found in modules/Calendar/models/Record.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_Link_Model' in method 'getRecordRelatedListViewLinksLeftSide'.
            Open

                            $links['LBL_SET_RECORD_STATUS'] = Vtiger_Link_Model::getInstanceFromValues([
                                'linklabel' => 'LBL_SET_RECORD_STATUS',
                                'linkhref' => true,
                                'linkurl' => $this->getActivityStateModalUrl(),
                                'linkicon' => 'fas fa-check',
            Severity: Minor
            Found in modules/Calendar/models/Record.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 updateActivityReminder uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
            Open

                    } else {
                        $db->createCommand()->delete('vtiger_activity_reminder', ['activity_id' => $this->getId()])->execute();
                    }
            Severity: Minor
            Found in modules/Calendar/models/Record.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_Link_Model' in method 'getRecordRelatedListViewLinksLeftSide'.
            Open

                            $links['LBL_EDIT'] = Vtiger_Link_Model::getInstanceFromValues([
                                'linklabel' => 'LBL_EDIT',
                                'linkurl' => $this->getEditViewUrl(),
                                'linkhref' => true,
                                'linkicon' => 'yfi yfi-full-editing-view',
            Severity: Minor
            Found in modules/Calendar/models/Record.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\Request' in method 'insertIntoInviteTable'.
            Open

                    $inviteesRequest = \App\Request::_getArray('inviteesid');
            Severity: Minor
            Found in modules/Calendar/models/Record.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 insertIntoActivityReminderPopup 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()->insert('vtiger_activity_reminder_popup', [
                                'recordid' => $cbrecord,
                                'datetime' => "$cbdate $cbtime",
                                'status' => $status
            Severity: Minor
            Found in modules/Calendar/models/Record.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

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

                        } else {
                            $db->createCommand()->insert('vtiger_activity_reminder', [
                                'reminder_time' => $this->get('reminder_time'),
                                'reminder_sent' => 0,
                                'activity_id' => $this->getId()
            Severity: Minor
            Found in modules/Calendar/models/Record.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\Log' in method 'insertIntoInviteTable'.
            Open

                    \App\Log::trace('Entering ' . __METHOD__);
            Severity: Minor
            Found in modules/Calendar/models/Record.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\Integrations\Dav\Calendar' in method 'getICal'.
            Open

                    $calendar = \App\Integrations\Dav\Calendar::createEmptyInstance();
            Severity: Minor
            Found in modules/Calendar/models/Record.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 "smownerid" 3 times.
            Open

                    if (isset($forSave['vtiger_crmentity']['smownerid'])) {
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "status" 3 times.
            Open

                                'status' => $status
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "due_date" 3 times.
            Open

                        $row = (new App\Db\Query())->select(['date_start', 'time_start', 'due_date', 'time_end'])
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "datetime" 3 times.
            Open

                                'datetime' => "$cbdate $cbtime",
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "btn-sm btn-default" 3 times.
            Open

                            'linkclass' => 'btn-sm btn-default',
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "linklabel" 3 times.
            Open

                            'linklabel' => 'LBL_SET_RECORD_STATUS',
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "u_#__activity_invitation" 4 times.
            Open

                    $dataReader = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $this->getId()])->createCommand()->query();
            Severity: Critical
            Found in modules/Calendar/models/Record.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_activity" 4 times.
            Open

                            ->from('vtiger_activity')
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "Y-m-d H:i:s" 6 times.
            Open

                            $datatime = date('Y-m-d H:i:s', strtotime('+15 min'));
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "reminder_time" 6 times.
            Open

                    if (!$this->isNew() && false === $this->getPreviousValue('reminder_time')) {
            Severity: Critical
            Found in modules/Calendar/models/Record.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_activity_reminder_popup" 4 times.
            Open

                        $reminderid = (new \App\Db\Query())->select(['reminderid'])->from('vtiger_activity_reminder_popup')
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "time_start" 4 times.
            Open

                        $cbtime = $this->get('time_start');
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "activityid" 5 times.
            Open

                    $dataReader = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $this->getId()])->createCommand()->query();
            Severity: Critical
            Found in modules/Calendar/models/Record.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_crmentity" 4 times.
            Open

                            ->innerJoin('vtiger_crmentity', 'vtiger_activity.activityid=vtiger_crmentity.crmid')
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "crmactivity" 3 times.
            Open

                        $fieldModel = Vtiger_Module_Model::getInstance($refModuleName ?? \App\Record::getType($id))->getFieldByName('crmactivity');
            Severity: Critical
            Found in modules/Calendar/models/Record.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

                            $db->createCommand()->update('vtiger_entity_stats', ['crmactivity' => (int) \App\Fields\DateTime::getDiff(date('Y-m-d'), $row['date_start'], '%r%a')], ['crmid' => $id])->execute();
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "linkicon" 3 times.
            Open

                            'linkicon' => 'fas fa-check',
            Severity: Critical
            Found in modules/Calendar/models/Record.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_activity_reminder" 6 times.
            Open

                    unset($forSave['vtiger_activity_reminder']);
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "current" 4 times.
            Open

                            ->where(['vtiger_crmentity.deleted' => 0, "vtiger_activity.$fieldName" => $id, 'vtiger_activity.status' => Calendar_Module_Model::getComponentActivityStateLabel('current')])
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "recordid" 3 times.
            Open

                            ->where(['recordid' => $cbrecord])
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "inviteesid" 5 times.
            Open

                    if (!\App\Request::_has('inviteesid')) {
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "time_end" 3 times.
            Open

                        $row = (new App\Db\Query())->select(['date_start', 'time_start', 'due_date', 'time_end'])
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "LBL_SET_RECORD_STATUS" 3 times.
            Open

                            'linklabel' => 'LBL_SET_RECORD_STATUS',
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "linkurl" 3 times.
            Open

                            'linkurl' => $this->getActivityStateModalUrl(),
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "activity_id" 6 times.
            Open

                        $activityReminderExists = (new \App\Db\Query())->select(['activity_id'])
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "date_start" 5 times.
            Open

                            $db->createCommand()->update('vtiger_entity_stats', ['crmactivity' => (int) \App\Fields\DateTime::getDiff(date('Y-m-d'), $row['date_start'], '%r%a')], ['crmid' => $id])->execute();
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "Y-m-d" 3 times.
            Open

                            $db->createCommand()->update('vtiger_entity_stats', ['crmactivity' => (int) \App\Fields\DateTime::getDiff(date('Y-m-d'), $row['date_start'], '%r%a')], ['crmid' => $id])->execute();
            Severity: Critical
            Found in modules/Calendar/models/Record.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 "linkclass" 3 times.
            Open

                            'linkclass' => 'btn-sm btn-default',
            Severity: Critical
            Found in modules/Calendar/models/Record.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.

            Call to method email from undeclared class \App\Validator (Did you mean class \Tests\App\Validator)
            Open

                            if (\App\TextUtils::getTextLength($invitation[0]) > 100 || !\App\Validator::email($invitation[0])) {
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                    \App\Db::getInstance()->createCommand()->update('vtiger_activity', ['deleted' => $stateId], ['activityid' => $this->getId()])->execute();
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                                $db->createCommand()->insert('u_#__activity_invitation', [
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                    \App\Log::trace('Exiting ' . __METHOD__);
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                        $reminderid = (new \App\Db\Query())->select(['reminderid'])->from('vtiger_activity_reminder_popup')
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                            \App\Db::getInstance()->createCommand()->update('vtiger_activity_reminder_popup', [
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                    return (new \App\Db\Query())
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                            $db->createCommand()->insert('vtiger_activity_reminder', [
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                    if ((new App\Db\Query())->select(['value'])->from('vtiger_calendar_config')
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                        $row = (new \App\Db\Query())->select(['vtiger_activity.status', 'vtiger_activity.date_start'])
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

            Returning type array{0:'LBL_NEEDS-ACTION',1:'LBL_ACCEPTED',2:'LBL_DECLINED'} but getInvitionStatus() is declared to return string
            Open

                    return false !== $status ? $statuses[$status] ?? '' : $statuses;
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phan

            @throws type of updateReminderPostpone has undeclared type \yii\db\Exception (Did you mean class \Exception)
            Open

                public function updateReminderPostpone(string $time)
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phan

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

                        \App\Db::getInstance()->createCommand()
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                            \App\Db::getInstance()->createCommand()->insert('vtiger_activity_reminder_popup', [
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                        $db->createCommand()->delete('u_#__activity_invitation', ['inviteesid' => $invitation['inviteesid']])->execute();
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

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

            Call to method serialize from undeclared class \Sabre\VObject\Component\VCalendar
            Open

                    return $calendar->getVCalendar()->serialize();
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                            $db->createCommand()->update('vtiger_activity_reminder', [
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                    \App\Log::trace('Entering ' . __METHOD__);
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                    $dataReader = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $this->getId()])->createCommand()->query();
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                        $row = (new App\Db\Query())->select(['date_start', 'time_start', 'due_date', 'time_end'])
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                    \App\Db::getInstance()->createCommand()->delete('vtiger_activity_reminder', ['activity_id' => $this->getId()])->execute();
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

            Call to deprecated function \Vtiger_Field_Model::getFieldName() defined at /code/modules/Vtiger/models/Field.php:203
            Open

                        $fieldName = $relationModel->getRelationField()->getFieldName();
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phan

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

                        $activityReminderExists = (new \App\Db\Query())->select(['activity_id'])
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                            $db->createCommand()->update('vtiger_entity_stats', ['crmactivity' => (int) \App\Fields\DateTime::getDiff(date('Y-m-d'), $row['date_start'], '%r%a')], ['crmid' => $id])->execute();
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                            $db->createCommand()->update(('vtiger_entity_stats'), ['crmactivity' => null], ['crmid' => $id])->execute();
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                        \App\Log::info('No invitations in request, Exiting insertIntoInviteeTable method ...');
            Severity: Critical
            Found in modules/Calendar/models/Record.php by phan

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

                public function changeState($state)
                {
                    parent::changeState($state);
                    $stateId = 0;
                    switch ($state) {
            Severity: Major
            Found in modules/Calendar/models/Record.php and 1 other location - About 1 hr to fix
            modules/OSSTimeControl/models/Record.php on lines 29..47

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

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

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

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

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

            Refactorings

            Further Reading

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

                        $activityReminderExists = (new \App\Db\Query())->select(['activity_id'])
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phpmd

            LongVariable

            Since: 0.2

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

            Example

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

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

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

            class Calendar_Record_Model extends Vtiger_Record_Model

            The class Calendar_Record_Model is not named in CamelCase.
            Open

            class Calendar_Record_Model extends Vtiger_Record_Model
            {
                /**
                 *  Show Reminder popup.
                 */
            Severity: Minor
            Found in modules/Calendar/models/Record.php by phpmd

            CamelCaseClassName

            Since: 0.2

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

            Example

            class class_name {
            }

            Source

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

                    $db = \App\Db::getInstance();
            Severity: Minor
            Found in modules/Calendar/models/Record.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/Calendar/models/Record.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/Calendar/models/Record.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

                    $fieldName = Vtiger_Cache::get('NameRelatedField', $refModuleName . '-Calendar');

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

                    if (!empty($fieldName)) {

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

                }

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

                            ->where(['vtiger_crmentity.deleted' => 0, "vtiger_activity.$fieldName" => $id, 'vtiger_activity.status' => Calendar_Module_Model::getComponentActivityStateLabel('current')])

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

                    $parentModuleModel = Vtiger_Module_Model::getInstance($refModuleName);

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

                        }

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

                            $fieldName = self::getNameByReference($refModuleName);

            Line exceeds 120 characters; contains 124 characters
            Open

                            $db->createCommand()->update(('vtiger_entity_stats'), ['crmactivity' => null], ['crmid' => $id])->execute();

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

                 * Skip reminder popup.

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

                    }

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

                        if (empty($fieldName)) {

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

                        if (empty($fieldName) || !\App\Record::isExists($id)) {

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

                            continue;

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

                        }

            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

                            $db->createCommand()->update(('vtiger_entity_stats'), ['crmactivity' => null], ['crmid' => $id])->execute();

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

                /**

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

                        $fieldName = $relationModel->getRelationField()->getFieldName();

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

                        }

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

                const REMNDER_POPUP_ACTIVE = 0;

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

                {

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

                    foreach ($referenceIds as $id => $fieldName) {

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

                 *  Show Reminder popup.

            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

                            ->from('vtiger_activity')

            Line exceeds 120 characters; contains 189 characters
            Open

                            ->where(['vtiger_crmentity.deleted' => 0, "vtiger_activity.$fieldName" => $id, 'vtiger_activity.status' => Calendar_Module_Model::getComponentActivityStateLabel('current')])

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

                 * Function returns the Module Name based on the activity type.

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

                 * @return string

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

                {

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

                 */

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

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

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

                 * Function to insert values in u_yf_activity_invitation table for the specified module,tablename ,invitees_array.

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

                const REMNDER_POPUP_INACTIVE = 1;

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

                    $relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);

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

                {

            Line exceeds 120 characters; contains 135 characters
            Open

                        $fieldModel = Vtiger_Module_Model::getInstance($refModuleName ?? \App\Record::getType($id))->getFieldByName('crmactivity');

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

                    }

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

                 * Function to get the Detail View url for the record.

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

                 * @return array

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

                    if (!$this->isEmpty('reminder_time')) {

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

                            ->where(['activity_id' => $this->getId()])

            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

                    $dataReader = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $this->getId()])->createCommand()->query();

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

                            if (isset($invities[$invitation[2]])) {

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

                        }

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

                    \App\Log::trace('Exiting ' . __METHOD__);

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

                        $cbtime = $this->get('time_start');

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

                        }

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

                        return $fieldName;

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

                    return $fieldName;

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

                 * @param array  $referenceIds

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

                        if (false === $fieldModel || !$fieldModel->isActiveField()) {

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

                        }

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

                /**

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

                    parent::saveToDb();

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

                {

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

                    if (!\App\Request::_has('inviteesid')) {

            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

                    }

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

                        $state = Calendar_Module_Model::getCalendarState($this->getData());

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

                 */

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

                    $relatedModule = Vtiger_Module_Model::getInstance('Calendar');

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

                    if ($relationModel && $relationModel->getRelationField()) {

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

                 * Set crm activity.

            Line exceeds 120 characters; contains 196 characters
            Open

                            $db->createCommand()->update('vtiger_entity_stats', ['crmactivity' => (int) \App\Fields\DateTime::getDiff(date('Y-m-d'), $row['date_start'], '%r%a')], ['crmid' => $id])->execute();

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

                public function getValuesForSave()

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

                {

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

                        $invities[$row['inviteesid']] = $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

                                    'email' => $invitation[0],

            Line exceeds 120 characters; contains 125 characters
            Open

                        $db->createCommand()->delete('u_#__activity_invitation', ['inviteesid' => $invitation['inviteesid']])->execute();

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

                 * Update event in popup reminder.

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

                        $reminderid = (new \App\Db\Query())->select(['reminderid'])->from('vtiger_activity_reminder_popup')

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

                        Vtiger_Cache::set('NameRelatedField', $refModuleName . '-Calendar', $fieldName);

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

                /**

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

                }

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

                 */

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

                    $this->updateActivityReminder();

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

                            ], ['activity_id' => $this->getId()])->execute();

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

                public function insertIntoInviteTable()

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

                        foreach ($inviteesRequest as &$invitation) {

            Line exceeds 120 characters; contains 128 characters
            Open

                                throw new \App\Exceptions\Security('ERR_ILLEGAL_FIELD_VALUE||inviteesid||Calendar||' . $invitation[0], 406);

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

                                    'crmid' => (int) $invitation[1],

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

                        if (\in_array($state, $currentStates)) {

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

                            \App\Db::getInstance()->createCommand()->update('vtiger_activity_reminder_popup', [

            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

                public static function getNameByReference($refModuleName)

            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_crmentity', 'vtiger_activity.activityid=vtiger_crmentity.crmid')

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

                    if (isset($forSave['vtiger_crmentity']['smownerid'])) {

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

                    }

            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

                    } else {

            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

                                $db->createCommand()->insert('u_#__activity_invitation', [

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

                            $status = self::REMNDER_POPUP_ACTIVE;

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

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

                 * Wait to show reminder popup.

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

                public static function setCrmActivity($referenceIds, $refModuleName = null)

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

                 */

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

                            continue;

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

                            $db->createCommand()->update('vtiger_entity_stats', ['crmactivity' => (int) \App\Fields\DateTime::getDiff(date('Y-m-d'), $row['date_start'], '%r%a')], ['crmid' => $id])->execute();

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

                            ->orderBy(['vtiger_activity.date_start' => SORT_ASC])->one();

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

                /**

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

                        } else {

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

                public function getDetailViewUrl()

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

                }

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

                }

            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

                        return false;

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

                            $db->createCommand()->update('vtiger_activity_reminder', [

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

                /** {@inheritdoc} */

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

                        } else {

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

                public function isMandatorySave()

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

                        $db->createCommand()->delete('vtiger_activity_reminder', ['activity_id' => $this->getId()])->execute();

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

                    $inviteesRequest = \App\Request::_getArray('inviteesid');

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

                        \App\Log::info('No invitations in request, Exiting insertIntoInviteeTable method ...');

            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 (\App\TextUtils::getTextLength($invitation[0]) > 100 || !\App\Validator::email($invitation[0])) {

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

                    $cbrecord = $this->getId();

            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

                        } 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

                const REMNDER_POPUP_WAIT = 2;

            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

                        $fieldModel = Vtiger_Module_Model::getInstance($refModuleName ?? \App\Record::getType($id))->getFieldByName('crmactivity');

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

                        $row = (new \App\Db\Query())->select(['vtiger_activity.status', 'vtiger_activity.date_start'])

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

                 *

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

                 *

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

                 * @return string - Record Detail View Url

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

                }

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

                 * Update cctivity reminder.

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

                                'reminder_sent' => 0

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

                /**

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

                    \App\Log::trace('Entering ' . __METHOD__);

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

                                throw new \App\Exceptions\Security('ERR_ILLEGAL_FIELD_VALUE||inviteesid||Calendar||' . $invitation[0], 406);

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

                        $db->createCommand()->delete('u_#__activity_invitation', ['inviteesid' => $invitation['inviteesid']])->execute();

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

                            $datatime = date('Y-m-d H:i:s', strtotime('+120 min'));

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

                            break;

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

                            break;

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

                        $this->set('date_start', date('Y-m-d', $datatimeSTR));

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

                                'status' => self::REMNDER_POPUP_WAIT,

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

                    }

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

                }

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

                 * Function to get modal view url for the 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

                    parent::delete();

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

                /**

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

                            'modalView' => true,

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

                        ];

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

                 */

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

                public function saveToDb()

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

                 *

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

                 */

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

            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

                        $cbdate = $this->get('date_start');

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

                                'datetime' => "$cbdate $cbtime",

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

                                'recordid' => $cbrecord,

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

                        default:

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

                public function getActivityTypeIcon()

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

                            $stateId = 2;

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

                            'linktype' => 'LIST_VIEW_ACTIONS_RECORD_LEFT_SIDE',

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

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

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

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

                                'linklabel' => 'LBL_EDIT',

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

                    return 'Calendar';

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

                    $this->insertIntoActivityReminderPopup();

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

                    if (!$this->isNew() && false === $this->getPreviousValue('reminder_time')) {

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

                            ->from('vtiger_activity_reminder')

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

                                'reminder_time' => $this->get('reminder_time'),

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

                 */

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

                {

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

                                    'name' => $invitation[3],

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

                public function insertIntoActivityReminderPopup()

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

                    if (!empty($cbrecord)) {

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

                            $status = self::REMNDER_POPUP_INACTIVE;

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

                                'status' => $status

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

                                'datetime' => "$cbdate $cbtime",

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

                        case '6h':

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

                            $datatime = date('Y-m-d H:i:s', strtotime('+6 hour'));

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

                        ->where(['type' => 'reminder', 'name' => 'update_event', 'value' => 1])

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

                        $this->set('due_date', date('Y-m-d', $datatimeSTR + $duration));

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

                    if ('Task' == $icon) {

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

                {

            Line exceeds 120 characters; contains 130 characters
            Open

                    \App\Db::getInstance()->createCommand()->delete('vtiger_activity_reminder', ['activity_id' => $this->getId()])->execute();

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

                                'modalView' => true,

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

                {

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

                }

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

                /** {@inheritdoc} */

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

                            ->exists();

            Line exceeds 120 characters; contains 145 characters
            Open

                    $dataReader = (new \App\Db\Query())->from('u_#__activity_invitation')->where(['activityid' => $this->getId()])->createCommand()->query();

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

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

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

                }

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

                 */

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

                            \App\Db::getInstance()->createCommand()->insert('vtiger_activity_reminder_popup', [

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

                 *

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

                        $this->set('time_end', date('H:i:s', $datatimeSTR + $duration));

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

                    }

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

                        case 'Trash':

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

                            break;

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

                }

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

                            'linklabel' => 'LBL_SET_RECORD_STATUS',

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

                    }

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

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

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

                        $forSave['vtiger_activity']['smownerid'] = $forSave['vtiger_crmentity']['smownerid'];

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

                    if (!empty($inviteesRequest)) {

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

                /**

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

                        if (!empty($reminderid)) {

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

                            $datatime = date('Y-m-d H:i:s', strtotime('+1 day'));

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

                            break;

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

                        \App\Db::getInstance()->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

                 *

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

                public function getActivityStateModalUrl()

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

                            break;

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

                 * @return Vtiger_Link_Model[] - Associate array of Vtiger_Link_Model instances

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

                {

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

                    $recordLinks = [];

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

                    if ($this->isEditable() && \in_array($this->getValueByField('activitystatus'), $statuses)) {

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

                        if (\in_array($this->getValueByField('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {

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

                public function getInvities()

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

                public function getInviteUserMailData()

            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

                    $calendar->loadFromArray($this->getData());

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

                /**

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

                 * Prepare value to save.

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

                                'reminder_time' => $this->get('reminder_time'),

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

                                'activity_id' => $this->getId()

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

                }

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

                    }

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

                                    'activityid' => $this->getId(),

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

                    }

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

                            ->scalar();

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

                        $currentStates = Calendar_Module_Model::getComponentActivityStateLabel('current');

            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 updateReminderPostpone(string $time)

            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

                    foreach ($recordLinks as $recordLink) {

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

                    return $links;

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

                            'u_#__crmentity_label.label',

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

                        ->where(['activityid' => (int) $this->getId()])

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

                public function getType()

            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 'index.php?module=Calendar&view=' . $this->getModule()->getDetailViewName() . '&record=' . $this->getId();

            Line exceeds 120 characters; contains 121 characters
            Open

                    return 'index.php?module=Calendar&view=' . $this->getModule()->getDetailViewName() . '&record=' . $this->getId();

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

                    $forSave = parent::getValuesForSave();

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

                    unset($forSave['vtiger_activity_reminder']);

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

                    return $forSave;

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

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

                        }

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

                    }

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

                    }

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

                {

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

                            break;

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

                            break;

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

                        $datatimeSTR = strtotime($datatime);

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

                        $icon = 'Tasks';

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

                    return 'index.php?module=Calendar&view=ActivityStateModal&record=' . $this->getId();

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

                            $stateId = 1;

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

                 *

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

                }

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

                 */

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

                        $duration = strtotime($row['due_date'] . ' ' . $row['time_end']) - strtotime($row['date_start'] . ' ' . $row['time_start']);

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

                    $icon = $this->get('activitytype');

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

                    $links = parent::getRecordListViewLinksLeftSide();

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

                            ]);

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

                                'linkhref' => true,

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

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

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

                {

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

                                'status' => $status

            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

                        case '1d':

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

                            ->from('vtiger_activity')

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

                        $this->set('time_start', date('H:i:s', $datatimeSTR));

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

                /**

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

                /** {@inheritdoc} */

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

                {

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

                    $stateId = 0;

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

                        default:

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

                    \App\Db::getInstance()->createCommand()->update('vtiger_activity', ['deleted' => $stateId], ['activityid' => $this->getId()])->execute();

            Line exceeds 120 characters; contains 145 characters
            Open

                    \App\Db::getInstance()->createCommand()->update('vtiger_activity', ['deleted' => $stateId], ['activityid' => $this->getId()])->execute();

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

                /** {@inheritdoc} */

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

                public function delete()

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

                    return $links;

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

                /** {@inheritdoc} */

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

                                'linklabel' => 'LBL_SET_RECORD_STATUS',

            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

                        ->select([

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

                            'u_#__activity_invitation.*',

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

                            ->where(['activityid' => $this->getId()])->one();

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

                /**

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

                }

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

                }

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

                 * @return string

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

                public function getICal(): string

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

                {

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

                    \App\Db::getInstance()->createCommand()->delete('vtiger_activity_reminder', ['activity_id' => $this->getId()])->execute();

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

                 */

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

                    }

            Line exceeds 120 characters; contains 136 characters
            Open

                        if (\in_array($this->getValueByField('activitystatus'), Calendar_Module_Model::getComponentActivityStateLabel('current'))) {

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

                            $links['LBL_SET_RECORD_STATUS'] = Vtiger_Link_Model::getInstanceFromValues([

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

                    return []; // To do

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

                    $calendar = \App\Integrations\Dav\Calendar::createEmptyInstance();

            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

                 * Update reminder postpone.

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

                            $datatime = date('Y-m-d H:i:s', strtotime('+30 min'));

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

                            ], ['recordid' => $this->getId()])

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

                 * @return string - Record Detail View Url

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

                            break;

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

                public function getRecordListViewLinksLeftSide()

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

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

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

                            $links['LBL_EDIT'] = Vtiger_Link_Model::getInstanceFromValues([

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

                        ->leftJoin('u_#__crmentity_label', 'u_#__crmentity_label.crmid = u_#__activity_invitation.crmid')

            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

                        $this->save();

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

                    switch ($state) {

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

                        case 'Archived':

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

                            'linkclass' => 'btn-sm btn-default',

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

                            'vtiger_crmentity.deleted'

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

                        ])->from('u_#__activity_invitation')

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

                 * Get invition status.

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

                 * @return array

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

                {

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

                    $calendar->createComponent();

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

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

                        $activityReminderExists = (new \App\Db\Query())->select(['activity_id'])

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

                                'reminder_sent' => 0,

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

                    $invities = [];

            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

                                unset($invities[$invitation[2]]);

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

                            } else {

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

                    foreach ($invities as &$invitation) {

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

                            ->where(['recordid' => $cbrecord])

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

                            ], ['reminderid' => $reminderid]

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

                        }

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

                            break;

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

                        case '1h':

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

                    if ((new App\Db\Query())->select(['value'])->from('vtiger_calendar_config')

            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

                            ->update('vtiger_activity_reminder_popup', [

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

                public function changeState($state)

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

                    parent::changeState($state);

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

                    $links = parent::getRecordRelatedListViewLinksLeftSide($viewModel);

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

                        ->leftJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = u_#__activity_invitation.crmid')

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

                public static function getInvitionStatus($status = 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

                        $row = (new App\Db\Query())->select(['date_start', 'time_start', 'due_date', 'time_end'])

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

                                'datetime' => $datatime

            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

                            $stateId = 0;

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

                 * Function to get the list view actions for the record.

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

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

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

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

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

                                'linkclass' => 'btn-sm btn-default',

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

                }

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

                 * @throws \yii\db\Exception

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

                    switch ($time) {

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

                        case '15m':

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

                            $datatime = date('Y-m-d H:i:s', strtotime('+15 min'));

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

                    return $icon . '.png';

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

                    $statuses = Calendar_Module_Model::getComponentActivityStateLabel('current');

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

                        $recordLinks[] = [

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

                }

            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 ($viewModel->getRelationModel()->isEditable() && $this->isEditable()) {

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

                        if ($viewModel->getRelationModel()->isEditable() && $this->isEditable()) {

            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

                            'vtiger_crmentity.setype',

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

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

                        case '30m':

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

                            $datatime = date('Y-m-d H:i:s', strtotime('+60 min'));

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

                            break;

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

                        case '2h':

            Line exceeds 120 characters; contains 136 characters
            Open

                        $duration = strtotime($row['due_date'] . ' ' . $row['time_end']) - strtotime($row['date_start'] . ' ' . $row['time_start']);

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

                 */

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

                }

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

                        case 'Active':

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

                            break;

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

                 *

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

                public function getRecordRelatedListViewLinksLeftSide(Vtiger_RelationListView_Model $viewModel)

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

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

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

                        }

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

                        ->all();

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

                    return false !== $status ? $statuses[$status] ?? '' : $statuses;

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

                /**

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

                 * Get invite user mail data.

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

                    return $calendar->getVCalendar()->serialize();

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

                 * @return array

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

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

                 * Gets ICal content.

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

                                'linkclass' => 'btn-sm btn-default',

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

                 * Get invitations with CRM metadata.

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

                 * @param false|int $status

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

                    $statuses = [0 => 'LBL_NEEDS-ACTION', 1 => 'LBL_ACCEPTED', 2 => 'LBL_DECLINED'];

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

                 *

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

                    }

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

                 * @return string

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

                 *

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

                }

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

            class Calendar_Record_Model extends Vtiger_Record_Model

            Expected 0 spaces before closing bracket; newline found
            Open

                            \App\Db::getInstance()->createCommand()->update('vtiger_activity_reminder_popup', [

            There are no issues that match your filters.

            Category
            Status