YetiForceCompany/YetiForceCRM

View on GitHub
modules/Announcements/models/Module.php

Summary

Maintainability
A
1 hr
Test Coverage
F
18%

Method loadAnnouncements has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function loadAnnouncements()
    {
        $queryGenerator = new \App\QueryGenerator($this->getName());
        $queryGenerator->setFields(['id', 'subject', 'description', 'assigned_user_id', 'createdtime', 'is_mandatory', 'interval']);
        $query = $queryGenerator->createQuery();
Severity: Minor
Found in modules/Announcements/models/Module.php - About 1 hr to fix

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

        public function loadAnnouncements()
        {
            $queryGenerator = new \App\QueryGenerator($this->getName());
            $queryGenerator->setFields(['id', 'subject', 'description', 'assigned_user_id', 'createdtime', 'is_mandatory', 'interval']);
            $query = $queryGenerator->createQuery();
    Severity: Minor
    Found in modules/Announcements/models/Module.php - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Missing class import via use statement (line '41', column '25').
    Open

            $queryGenerator = new \App\QueryGenerator($this->getName());

    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 '125', column '19').
    Open

                $result = (new App\Db\Query())->from('u_#__announcement_mark')->where(['announcementid' => $record, 'userid' => $userId, 'status' => 1])->count();

    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 '47', column '18').
    Open

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

    MissingImport

    Since: 2.7.0

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

    Example

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

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

    Missing class import via use statement (line '91', column '17').
    Open

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

    MissingImport

    Since: 2.7.0

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

    Example

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

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

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

            return (new App\Db\Query())->from('u_#__announcement_mark')->where(['announcementid' => $record, 'userid' => $userId])->one() ?: [];

    MissingImport

    Since: 2.7.0

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

    Example

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

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

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

        public function getUsers($showAll = true)

    BooleanArgumentFlag

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class '\App\User' in method 'setMark'.
    Open

                ->where(['announcementid' => $record, 'userid' => \App\User::getCurrentUserId()])->limit(1);

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

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

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class '\App\Request' in method 'checkActive'.
    Open

            if ('Login' == \App\Request::_get('view') || !$this->isActive() || !\App\Privilege::isPermitted($this->getName())) {

    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\User' in method 'setMark'.
    Open

                        'userid' => \App\User::getCurrentUserId(),

    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_Record_Model' in method 'checkStatus'.
    Open

                $recordModel = Vtiger_Record_Model::getInstanceById($record, $this->getName());

    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\User' in method 'loadAnnouncements'.
    Open

                    ->where(['announcementid' => $row['id'], 'userid' => \App\User::getCurrentUserId()]);

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

            if ('Login' == \App\Request::_get('view') || !$this->isActive() || !\App\Privilege::isPermitted($this->getName())) {

    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\User' in method 'setMark'.
    Open

                    ], ['announcementid' => $record, 'userid' => \App\User::getCurrentUserId()])

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

            } else {
                $users = $userModel->getRoleBasedSubordinateUsers();
            }

    ElseExpression

    Since: 1.4.0

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

    Example

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

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

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

            $recordModel = Vtiger_Record_Model::getInstanceById($record, $this);

    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 setMark 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('u_#__announcement_mark', [
                        'date' => $date,
                        'status' => $state,

    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 'Users_Record_Model' in method 'getUsers'.
    Open

            $userModel = Users_Record_Model::getCurrentUserModel();

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

                    ->where(['announcementid' => $row['id'], 'userid' => \App\User::getCurrentUserId()]);

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

                    ->where(['announcementid' => $row['id'], 'userid' => \App\User::getCurrentUserId()]);

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

            $queryGenerator->setFields(['id', 'subject', 'description', 'assigned_user_id', 'createdtime', 'is_mandatory', 'interval']);

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

                        ['status' => 1],

    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_#__announcement_mark" 6 times.
    Open

                    ->from('u_#__announcement_mark')

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

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

    Exceptions

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

    Avoid unused local variables such as '$name'.
    Open

            foreach ($users as $userId => $name) {

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

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

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

            $queryGenerator->setFields(['id', 'subject', 'description', 'assigned_user_id', 'createdtime', 'is_mandatory', 'interval']);
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

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

            $query = $queryGenerator->createQuery();
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

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

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

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

                $result = (new App\Db\Query())->from('u_#__announcement_mark')->where(['announcementid' => $record, 'userid' => $userId, 'status' => 1])->count();
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

    Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

                ->where(['announcementid' => $record, 'userid' => \App\User::getCurrentUserId()])->limit(1);
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

    Argument 2 (module) is \Announcements_Module_Model|\Vtiger_Module_Model|\vtlib\Module|\vtlib\ModuleBasic but \Vtiger_Record_Model::getInstanceById() takes string defined at /code/modules/Vtiger/models/Record.php:763
    Open

            $recordModel = Vtiger_Record_Model::getInstanceById($record, $this);

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

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

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

            $query = (new \App\Db\Query())
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

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

            $queryGenerator = new \App\QueryGenerator($this->getName());
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

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

            return (new App\Db\Query())->from('u_#__announcement_mark')->where(['announcementid' => $record, 'userid' => $userId])->one() ?: [];
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

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

                $query = (new \App\Db\Query())
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

    Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

                    ->where(['announcementid' => $row['id'], 'userid' => \App\User::getCurrentUserId()]);
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

    Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

                        'userid' => \App\User::getCurrentUserId(),
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

    Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
    Open

                    ], ['announcementid' => $record, 'userid' => \App\User::getCurrentUserId()])
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

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

                $users = \App\Fields\Owner::getInstance()->getAccessibleUsers('Public');
    Severity: Critical
    Found in modules/Announcements/models/Module.php by phan

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

    class Announcements_Module_Model extends Vtiger_Module_Model

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

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

    ShortVariable

    Since: 0.2

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

    Example

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

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

    The class Announcements_Module_Model is not named in CamelCase.
    Open

    class Announcements_Module_Model extends Vtiger_Module_Model
    {
        /**
         * Announcements.
         *

    CamelCaseClassName

    Since: 0.2

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

    Example

    class class_name {
    }

    Source

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

        protected $announcements = [];

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

        /**

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

                            ['>', 'date', date('Y-m-d H:i:s')]

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

        /**

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

        {

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

            if (false === $query->scalar()) {

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

                        'announcementid' => $record,

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

                        'date' => $date,

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

                    ], ['announcementid' => $record, 'userid' => \App\User::getCurrentUserId()])

    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

         * Get mark info.

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

         * @var array

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

        /**

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

         * Check active.

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

         * Load announcements.

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

            }

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

         * @param int $record

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

                        'date' => $date,

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

            $query = $queryGenerator->createQuery();

    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

         * Set mark.

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

         * @param int $state

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

         */

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

         *

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

            $users = $this->getUsers(true);

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

                    $archive = false;

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

        public function getUsers($showAll = true)

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

            $userModel = Users_Record_Model::getCurrentUserModel();

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

            if ($showAll) {

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

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

            $this->checkStatus($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

                $recordModel->set('announcementstatus', 'PLL_ARCHIVES');

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

                $users = \App\Fields\Owner::getInstance()->getAccessibleUsers('Public');

    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

                    ->where(['announcementid' => $row['id'], 'userid' => \App\User::getCurrentUserId()]);

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

         * Get announcements.

    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 setMark($record, $state)

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

            $recordModel = Vtiger_Record_Model::getInstanceById($record, $this);

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

                $db->createCommand()

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

                    ->update('u_#__announcement_mark', [

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

        public function checkActive()

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

            $this->loadAnnouncements();

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

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

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

                $result = (new App\Db\Query())->from('u_#__announcement_mark')->where(['announcementid' => $record, 'userid' => $userId, 'status' => 1])->count();

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

         * @param int $record

    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

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

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

            $date = date('Y-m-d H:i:s', strtotime('+' . (int) $recordModel->get('interval') . ' day'));

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

        {

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

            $dataReader = $query->createCommand()->query();

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

                            ['status' => 0],

    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

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

                $recordModel->save();

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

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

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

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

                ->where(['announcementid' => $record, 'userid' => \App\User::getCurrentUserId()])->limit(1);

    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

                $db->createCommand()

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

                if (!$result) {

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

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

         */

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

         * @return bool

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

            $queryGenerator->setFields(['id', 'subject', 'description', 'assigned_user_id', 'createdtime', 'is_mandatory', 'interval']);

    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

                $this->loadAnnouncements();

    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 !empty($this->announcements);

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

                        ['and',

    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

                        'status' => $state,

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

        /**

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

         * @param int $record

    Line exceeds 120 characters; contains 158 characters
    Open

                $result = (new App\Db\Query())->from('u_#__announcement_mark')->where(['announcementid' => $record, 'userid' => $userId, 'status' => 1])->count();

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

        }

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

         * @return array

    Line exceeds 120 characters; contains 124 characters
    Open

            if ('Login' == \App\Request::_get('view') || !$this->isActive() || !\App\Privilege::isPermitted($this->getName())) {

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

            $queryGenerator = new \App\QueryGenerator($this->getName());

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

         *

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

                    ->insert('u_#__announcement_mark', [

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

            }

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

         */

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

        {

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

            foreach ($users as $userId => $name) {

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

         * Announcements.

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

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

                        'status' => $state,

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

        /**

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

        }

    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 ('Login' == \App\Request::_get('view') || !$this->isActive() || !\App\Privilege::isPermitted($this->getName())) {

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

            $query->andWhere(['announcementstatus' => 'PLL_PUBLISHED']);

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

                    $query->andWhere(['or',

    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

                $recordModel->setId($row['id']);

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

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

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

         * Check status.

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

                $users = $userModel->getRoleBasedSubordinateUsers();

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

         * @param int $userId

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

         *

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

        public function loadAnnouncements()

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

                    ->from('u_#__announcement_mark')

    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 (0 !== $query->count()) {

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

                $this->announcements[] = $recordModel;

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

                ->from('u_#__announcement_mark')

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

                        'userid' => \App\User::getCurrentUserId(),

    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

        public function checkStatus($record)

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

            $archive = true;

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

                $recordModel = Vtiger_Record_Model::getInstanceById($record, $this->getName());

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

            }

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

        {

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

         */

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

        {

    Line exceeds 120 characters; contains 132 characters
    Open

            $queryGenerator->setFields(['id', 'subject', 'description', 'assigned_user_id', 'createdtime', 'is_mandatory', 'interval']);

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

                    ]);

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

                $recordModel = $this->getRecordFromArray($row);

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

            return $this->announcements;

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

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

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

        }

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

            if ($archive) {

    Line exceeds 120 characters; contains 140 characters
    Open

            return (new App\Db\Query())->from('u_#__announcement_mark')->where(['announcementid' => $record, 'userid' => $userId])->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

            return (new App\Db\Query())->from('u_#__announcement_mark')->where(['announcementid' => $record, 'userid' => $userId])->one() ?: [];

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

        public function getMarkInfo($record, $userId)

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

    class Announcements_Module_Model extends Vtiger_Module_Model

    There are no issues that match your filters.

    Category
    Status