YetiForceCompany/YetiForceCRM

View on GitHub
modules/Leads/views/SaveConvertLead.php

Summary

Maintainability
B
4 hrs
Test Coverage
F
0%

Method process has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function process(App\Request $request)
    {
        $recordId = $request->getInteger('record');
        $modules = $request->getArray('modules', 'Alnum');
        $assignId = $request->getInteger('assigned_user_id');
Severity: Major
Found in modules/Leads/views/SaveConvertLead.php - About 2 hrs to fix

    Function process has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function process(App\Request $request)
        {
            $recordId = $request->getInteger('record');
            $modules = $request->getArray('modules', 'Alnum');
            $assignId = $request->getInteger('assigned_user_id');
    Severity: Minor
    Found in modules/Leads/views/SaveConvertLead.php - About 2 hrs 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

    The method process() has an NPath complexity of 400. The configured NPath complexity threshold is 200.
    Open

        public function process(App\Request $request)
        {
            $recordId = $request->getInteger('record');
            $modules = $request->getArray('modules', 'Alnum');
            $assignId = $request->getInteger('assigned_user_id');

    NPathComplexity

    Since: 0.1

    The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

    Example

    class Foo {
        function bar() {
            // lots of complicated code
        }
    }

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

    The method process() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
    Open

        public function process(App\Request $request)
        {
            $recordId = $request->getInteger('record');
            $modules = $request->getArray('modules', 'Alnum');
            $assignId = $request->getInteger('assigned_user_id');

    CyclomaticComplexity

    Since: 0.1

    Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

    Example

    // Cyclomatic Complexity = 11
    class Foo {
    1   public function example() {
    2       if ($a == $b) {
    3           if ($a1 == $b1) {
                    fiddle();
    4           } elseif ($a2 == $b2) {
                    fiddle();
                } else {
                    fiddle();
                }
    5       } elseif ($c == $d) {
    6           while ($c == $d) {
                    fiddle();
                }
    7        } elseif ($e == $f) {
    8           for ($n = 0; $n < $h; $n++) {
                    fiddle();
                }
            } else {
                switch ($z) {
    9               case 1:
                        fiddle();
                        break;
    10              case 2:
                        fiddle();
                        break;
    11              case 3:
                        fiddle();
                        break;
                    default:
                        fiddle();
                        break;
                }
            }
        }
    }

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

    Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
    Open

        public function process(App\Request $request)

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

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

    class Leads_SaveConvertLead_View extends \App\Controller\View\Page
    {
        /**
         * Record model instance.
         *

    CouplingBetweenObjects

    Since: 1.1.0

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

    Example

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

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

    Missing class import via use statement (line '37', column '14').
    Open

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

    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 '97', column '14').
    Open

                throw new \App\Exceptions\AppException($e->getMessage());

    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 showError has a boolean flag argument $exception, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function showError(App\Request $request, $exception = false, $message = '')

    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 '115', column '14').
    Open

                throw new \App\Exceptions\AppException('Error');

    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 '44', column '14').
    Open

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

    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 '103', column '14').
    Open

                throw new \App\Exceptions\AppException($e->getMessage());

    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 '41', column '14').
    Open

                throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

    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 preProcess has a boolean flag argument $display, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function preProcess(App\Request $request, $display = 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 'Vtiger_Record_Model' in method 'checkPermission'.
    Open

            $this->record = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'Users_Privileges_Model' in method 'checkPermission'.
    Open

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

                ModTracker_Record_Model::addConvertToAccountRelation('Accounts', $accountId, \App\User::getCurrentUserRealId());

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

            } else {
                $this->showError($request);
                throw new \App\Exceptions\AppException('Error');
            }

    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\Language' in method 'showError'.
    Open

                $viewer->assign('EXCEPTION', \App\Language::translate($exception->getMessage(), $moduleName));

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

                    $leadModel = Vtiger_Module_Model::getCleanInstance($request->getModule());

    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 'Leads_Module_Model' in method 'checkPermission'.
    Open

            if (!Leads_Module_Model::checkIfAllowedToConvert($this->record->get('leadstatus'))) {

    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_Processes_Model' in method 'process'.
    Open

            $createAlways = Vtiger_Processes_Model::getConfig('marketing', 'conversion', 'create_always');

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

                    $message = \App\Language::translate('LBL_TOO_MANY_ACCOUNTS_TO_CONVERT', $request->getModule(), '');

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

            $currentUser = 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

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

                        $message = \App\Language::translate('LBL_TOO_MANY_ACCOUNTS_TO_CONVERT', $request->getModule(), '<a href="index.php?module=MarketingProcesses&view=Index&parent=Settings"><span class="fas fa-folder-open"></span></a>');

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'ModTracker_Record_Model' in method 'process'.
    Open

                ModTracker_Record_Model::addConvertToAccountRelation('Accounts', $accountId, \App\User::getCurrentUserRealId());

    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 '\WebservicesConvertLead' in method 'process'.
    Open

                $result = \WebservicesConvertLead::vtwsConvertlead($entityValues, $currentUser);

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

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

                if (\App\Module::isModuleActive($module) && \in_array($module, $modules)) {

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

            $availableModules = ['Accounts'];

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

                    $entityValues['entities'][$module]['create'] = true;

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

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

    Noncompliant Code Example

    With the default threshold of 3:

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

    Compliant Solution

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

    Exceptions

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

    Avoid unused parameters such as '$display'.
    Open

        public function preProcess(App\Request $request, $display = true)

    UnusedFormalParameter

    Since: 0.2

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

    Example

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

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

    Avoid unused parameters such as '$request'.
    Open

        public function preProcess(App\Request $request, $display = true)

    UnusedFormalParameter

    Since: 0.2

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

    Example

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

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

    Argument 2 (exception) is \Exception|\Throwable but \Leads_SaveConvertLead_View::showError() takes bool|false defined at /code/modules/Leads/views/SaveConvertLead.php:126
    Open

                $this->showError($request, $e);

    Assigning false to property but \Leads_SaveConvertLead_View->record is \Vtiger_Record_Model
    Open

        protected $record = false;

    true to array comparison
    Open

                if (true === $createAlways || 'true' === $createAlways) {

    Call to undeclared method \Vtiger_Module_Model::searchAccountsToConvert
    Open

                    $results = $leadModel->searchAccountsToConvert($this->record);
    Severity: Critical
    Found in modules/Leads/views/SaveConvertLead.php by phan

    Call to undeclared method \Vtiger_Record_Model::getConvertLeadFields
    Open

            $convertLeadFields = $this->record->getConvertLeadFields();
    Severity: Critical
    Found in modules/Leads/views/SaveConvertLead.php by phan

    Argument 1 (entityvalues) is array{entities:array{Accounts:array{convert_to_id:}}}|array{entities:array{Accounts:array{create:true}}}|array{entities:array{Accounts:array{name:'Accounts'}}}|array{entities:array{Accounts:array}}|array{leadId:int,assignedTo:int,transferRelatedRecordsTo:bool|mixed} but \WebservicesConvertLead::vtwsConvertlead() takes string defined at /code/include/Webservices/ConvertLead.php:22
    Open

                $result = \WebservicesConvertLead::vtwsConvertlead($entityValues, $currentUser);

    Argument 2 (exception) is \Exception|\Throwable but \Leads_SaveConvertLead_View::showError() takes bool|false defined at /code/modules/Leads/views/SaveConvertLead.php:126
    Open

                $this->showError($request, $e);

    Call to method getMessage on non-class type true
    Open

                $viewer->assign('EXCEPTION', \App\Language::translate($exception->getMessage(), $moduleName));
    Severity: Critical
    Found in modules/Leads/views/SaveConvertLead.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                $viewer->assign('EXCEPTION', \App\Language::translate($exception->getMessage(), $moduleName));
    Severity: Critical
    Found in modules/Leads/views/SaveConvertLead.php by phan

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

                ModTracker_Record_Model::addConvertToAccountRelation('Accounts', $accountId, \App\User::getCurrentUserRealId());
    Severity: Critical
    Found in modules/Leads/views/SaveConvertLead.php by phan

    Call to undeclared method \Vtiger_Viewer::assign
    Open

                $viewer->assign('EXCEPTION', $message);
    Severity: Critical
    Found in modules/Leads/views/SaveConvertLead.php by phan

    string to array comparison
    Open

                if (true === $createAlways || 'true' === $createAlways) {

    Suspicious array access to int
    Open

                $accountId = $result['Accounts'];

    Call to undeclared method \Vtiger_Viewer::assign
    Open

            $viewer->assign('MODULE', $moduleName);
    Severity: Critical
    Found in modules/Leads/views/SaveConvertLead.php by phan

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

    class Leads_SaveConvertLead_View extends \App\Controller\View\Page

    A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 13 and the first side effect is on line 11.
    Open

    <?php

    The class Leads_SaveConvertLead_View is not named in CamelCase.
    Open

    class Leads_SaveConvertLead_View extends \App\Controller\View\Page
    {
        /**
         * Record model instance.
         *

    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

         */

    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

            $assignId = $request->getInteger('assigned_user_id');

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

            try {

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

                    $leadModel = Vtiger_Module_Model::getCleanInstance($request->getModule());

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

                }

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

                    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

         *

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

         * @throws \App\Exceptions\NoPermitted

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

        public function checkPermission(App\Request $request)

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

        public function preProcess(App\Request $request, $display = true)

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

            $entityValues['assignedTo'] = $assignId;

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

                        $uitypeModel->validate($request->get($fieldName, null), true);

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

                $results = true;

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

                    $message = \App\Language::translate('LBL_TOO_MANY_ACCOUNTS_TO_CONVERT', $request->getModule(), '');

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

            }

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

                throw new \App\Exceptions\AppException('Error');

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

            $moduleName = $request->getModule();

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

            } elseif ($message) {

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

         * Record model instance.

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

            $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();

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

            if (!Leads_Module_Model::checkIfAllowedToConvert($this->record->get('leadstatus'))) {

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

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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

        }

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

            $availableModules = ['Accounts'];

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

            if (false !== $exception) {

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

            $request->validateWriteAccess();

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

         * @param \App\Request $request

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

            $recordId = $request->getInteger('record');

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

            if (!$userPrivilegesModel->hasModuleActionPermission($moduleName, 'ConvertLead')) {

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

                throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);

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

                    $results = $leadModel->searchAccountsToConvert($this->record);

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

                throw new \App\Exceptions\AppException($e->getMessage());

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

                throw new \App\Exceptions\AppException($e->getMessage());

    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

            $moduleName = $request->getModule();

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

            }

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

                    }

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

                $viewer->assign('EXCEPTION', $message);

    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

            if (!$this->record->isEditable()) {

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

            $entityValues['transferRelatedRecordsTo'] = $request->getByType('transferModule', 'Alnum');

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

            foreach ($availableModules as $module) {

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

                    $entityValues['entities'][$module]['create'] = true;

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

                    $this->showError($request, false, $message);

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

            } catch (Exception $e) {

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

                $this->showError($request, $e);

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

            }

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

            try {

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

            if (!empty($result['Accounts'])) {

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

                $this->showError($request);

    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 check permission.

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

        {

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

            $modules = $request->getArray('modules', 'Alnum');

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

                if (\App\Module::isModuleActive($module) && \in_array($module, $modules)) {

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

                        $uitypeModel = $fieldModel->getUITypeModel();

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

            }

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

                        $message = \App\Language::translate('LBL_TOO_MANY_ACCOUNTS_TO_CONVERT', $request->getModule(), '<a href="index.php?module=MarketingProcesses&view=Index&parent=Settings"><span class="fas fa-folder-open"></span></a>');

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

                $this->showError($request, $e);

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

         * @param \App\Request $request

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

        public function showError(App\Request $request, $exception = false, $message = '')

    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

            $entityValues['leadId'] = $recordId;

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

                    $entityValues['entities']['Accounts']['convert_to_id'] = $results;

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

                }

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

        protected $record = false;

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

                $accountId = $result['Accounts'];

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

                        $fieldName = $fieldModel->getName();

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

                header("location: index.php?view=Detail&module=Accounts&record=$accountId");

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

                        $entityValues['entities'][$module][$fieldName] = $fieldValue;

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

                ModTracker_Record_Model::addConvertToAccountRelation('Accounts', $accountId, \App\User::getCurrentUserRealId());

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

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

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

                if (!$results) {

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

                $result = \WebservicesConvertLead::vtwsConvertlead($entityValues, $currentUser);

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

         * @var Vtiger_Record_Model

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

         * @throws \App\Exceptions\NoPermittedToRecord

    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 ($convertLeadFields[$module] as $fieldModel) {

    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

            $viewer->view('ConvertLeadError.tpl', $moduleName);

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

        {

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

         *

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

                    $entityValues['entities'][$module]['name'] = $module;

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

        }

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

         * This function shows an error.

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

            $viewer->assign('MODULE', $moduleName);

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

            $createAlways = Vtiger_Processes_Model::getConfig('marketing', 'conversion', 'create_always');

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

                    }

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

            } catch (Exception $e) {

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

            if (!empty($accountId)) {

    Line exceeds 120 characters; contains 124 characters
    Open

                ModTracker_Record_Model::addConvertToAccountRelation('Accounts', $accountId, \App\User::getCurrentUserRealId());

    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->record = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);

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

        public function process(App\Request $request)

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

            $entityValues = [];

    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

            $recordId = $request->getInteger('record');

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

            $convertLeadFields = $this->record->getConvertLeadFields();

    Line exceeds 120 characters; contains 236 characters
    Open

                        $message = \App\Language::translate('LBL_TOO_MANY_ACCOUNTS_TO_CONVERT', $request->getModule(), '<a href="index.php?module=MarketingProcesses&view=Index&parent=Settings"><span class="fas fa-folder-open"></span></a>');

    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

            $currentUser = Users_Record_Model::getCurrentUserModel();

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

                        $fieldValue = $uitypeModel->getDBValue($request->get($fieldName, null));

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

                if (true === $createAlways || 'true' === $createAlways) {

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

                    if ($currentUser->isAdminUser()) {

    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 bool         $exception

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

         * @param string       $message

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

        {

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

            $viewer = $this->getViewer($request);

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

                $viewer->assign('EXCEPTION', \App\Language::translate($exception->getMessage(), $moduleName));

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

        public function validateRequest(App\Request $request)

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

    class Leads_SaveConvertLead_View extends \App\Controller\View\Page

    There are no issues that match your filters.

    Category
    Status