YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/actions/PDF.php

Summary

Maintainability
D
2 days
Test Coverage
F
0%

Function generate has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring.
Open

    public function generate(App\Request $request): void
    {
        $pdfModuleName = $request->getModule();
        $view = $request->getByType('fromview', \App\Purifier::STANDARD);
        $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('record');
Severity: Minor
Found in modules/Vtiger/actions/PDF.php - About 1 day 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 generate has 115 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function generate(App\Request $request): void
    {
        $pdfModuleName = $request->getModule();
        $view = $request->getByType('fromview', \App\Purifier::STANDARD);
        $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('record');
Severity: Major
Found in modules/Vtiger/actions/PDF.php - About 4 hrs to fix

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

    class Vtiger_PDF_Action extends \App\Controller\Action
    {
        use \App\Controller\ExposeMethod;
    
        /**
    Severity: Minor
    Found in modules/Vtiger/actions/PDF.php by phpmd

    Function validateRecords has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function validateRecords(App\Request $request): void
        {
            $moduleName = $request->getModule();
            $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('record');
            $result = false;
    Severity: Minor
    Found in modules/Vtiger/actions/PDF.php - About 45 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

    Consider simplifying this complex logical expression.
    Open

                    if ($attach || $emailPdf || ($countTemplates > 1 || (1 === $countTemplates && !isset($skip[$templateId]) && $countRecords > 1))) {
                        $fileName = ($pdf->getFileName() ?: time());
                        $increment[$fileName] = $increment[$fileName] ?? 0;
                        $fileName .= ($increment[$fileName]++ > 0 ? '_' . $increment[$fileName] : '') . '.pdf';
    
    
    Severity: Major
    Found in modules/Vtiger/actions/PDF.php - About 40 mins to fix

      The method generate() has 126 lines of code. Current threshold is set to 100. Avoid really long methods.
      Open

          public function generate(App\Request $request): void
          {
              $pdfModuleName = $request->getModule();
              $view = $request->getByType('fromview', \App\Purifier::STANDARD);
              $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('record');
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      The method generate() has an NPath complexity of 2130912. The configured NPath complexity threshold is 200.
      Open

          public function generate(App\Request $request): void
          {
              $pdfModuleName = $request->getModule();
              $view = $request->getByType('fromview', \App\Purifier::STANDARD);
              $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('record');
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      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 generate() has a Cyclomatic Complexity of 41. The configured cyclomatic complexity threshold is 10.
      Open

          public function generate(App\Request $request): void
          {
              $pdfModuleName = $request->getModule();
              $view = $request->getByType('fromview', \App\Purifier::STANDARD);
              $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('record');
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      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 96 to the 15 allowed.
      Open

          public function generate(App\Request $request): void
      Severity: Critical
      Found in modules/Vtiger/actions/PDF.php by sonar-php

      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 Vtiger_PDF_Action has a coupling between objects value of 19. Consider to reduce the number of dependencies under 13.
      Open

      class Vtiger_PDF_Action extends \App\Controller\Action
      {
          use \App\Controller\ExposeMethod;
      
          /**
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      CouplingBetweenObjects

      Since: 1.1.0

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

      Example

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

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

      Missing class import via use statement (line '72', column '19').
      Open

              $response = new Vtiger_Response();
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 '35', column '14').
      Open

                  throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 '116', column '23').
      Open

              $eventHandler = new App\EventHandler();
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 '114', column '14').
      Open

                  throw new \App\Exceptions\NoPermitted('LBL_EXPORT_ERROR');
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 '246', column '14').
      Open

                  throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED');
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 '231', column '41').
      Open

              $response->setResult(['valid' => (new Vtiger_PDF_Model())->checkActiveTemplates($recordId, $moduleName, $request->getByType('view'))]);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 '230', column '19').
      Open

              $response = new Vtiger_Response();
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 '228', column '14').
      Open

                  throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 '255', column '19').
      Open

              $response = new Vtiger_Response();
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 assigning values to variables in if clauses and the like (line '94', column '7').
      Open

          public function generate(App\Request $request): void
          {
              $pdfModuleName = $request->getModule();
              $view = $request->getByType('fromview', \App\Purifier::STANDARD);
              $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('record');
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

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

      Avoid using static access to class 'Vtiger_PDF_Model' in method 'generate'.
      Open

                  Vtiger_PDF_Model::attachToEmail(\App\Json::encode($pdfFiles));
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  'message' => \App\Language::translate('LBL_SCHEME_SAVED', 'Settings:PDF'),
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  || ($request->has($key) && !\App\Privilege::isPermitted($pdfModuleName, 'RecordPdfInventory'))
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

              if (($emailPdf && !\App\Mail::checkInternalMailClient())
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  \App\Pdf\Pdf::merge(array_column($pdfFiles, 'path'), \App\Fields\File::sanitizeUploadFileName(\App\Language::translate('LBL_PDF_MANY_IN_ONE')) . '.pdf', $pdfFlag ?: 'D');
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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_PDF_Model' in method 'validateRecords'.
      Open

                  $templateRecord = Vtiger_PDF_Model::getInstanceById($templateId);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  'message' => \App\Language::translateArgs('LBL_NO_DATA_AVAILABLE', $moduleName),
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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\Pdf\Pdf' in method 'generate'.
      Open

                  \App\Pdf\Pdf::merge(array_column($pdfFiles, 'path'), \App\Fields\File::sanitizeUploadFileName(\App\Language::translate('LBL_PDF_MANY_IN_ONE')) . '.pdf', $pdfFlag ?: 'D');
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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\File' in method 'generate'.
      Open

                  \App\Pdf\Pdf::merge(array_column($pdfFiles, 'path'), \App\Fields\File::sanitizeUploadFileName(\App\Language::translate('LBL_PDF_MANY_IN_ONE')) . '.pdf', $pdfFlag ?: 'D');
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  Vtiger_PDF_Model::attachToEmail(\App\Json::encode($pdfFiles));
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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_PDF_Model' in method 'generate'.
      Open

                  Vtiger_PDF_Model::zipAndDownload($pdfFiles);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

              $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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_Loader' in method 'generate'.
      Open

              $handlerClass = Vtiger_Loader::getComponentClassName('Model', 'PDF', $pdfModuleName);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

              if (!\App\Privilege::isPermitted($moduleName, 'RecordPdfInventory')) {
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                      if (\App\Privilege::isPermitted($moduleName, 'DetailView', $recordId) && $templateRecord->checkFiltersForRecord((int) $recordId)) {
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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\Pdf\Pdf' in method 'generate'.
      Open

                      $pdf = \App\Pdf\Pdf::getInstanceByTemplateId($templateId);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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\Condition' in method 'generate'.
      Open

                                      $template->setVariable($keyName, App\Condition::validSearchParams($pdfModuleName, $request->getArray($keyName)));
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

              if (!\App\Privilege::isPermitted($moduleName, 'DetailView', $recordId)) {
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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\Pdf\InventoryColumns' in method 'saveInventoryColumnScheme'.
      Open

              \App\Pdf\InventoryColumns::saveInventoryColumnsForRecords($moduleName, $save);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 generate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                                  } else {
                                      $template->setVariable($keyName, $request->isEmpty($keyName) ? '' : $request->getByType($keyName, \App\Purifier::ALNUM));
                                  }
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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_RelationAjax_Action' in method 'getRecords'.
      Open

                  $records = \Vtiger_RelationAjax_Action::getRecordsListFromRequest($request);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 getRecords uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $records = \Vtiger_Mass_Action::getRecordsListFromRequest($request);
              }
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 validateRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $request->validateWriteAccess();
              }
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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_Mass_Action' in method 'getRecords'.
      Open

                  $records = \Vtiger_Mass_Action::getRecordsListFromRequest($request);
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.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 "records" 3 times.
      Open

                  'records' => $recordIds,
      Severity: Critical
      Found in modules/Vtiger/actions/PDF.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" 4 times.
      Open

                              $template->setVariable('recordId', $recordId);
      Severity: Critical
      Found in modules/Vtiger/actions/PDF.php by sonar-php

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Define a constant instead of duplicating this literal "relatedModule" 5 times.
      Open

                  $pdfModuleName = $request->getByType('relatedModule', \App\Purifier::ALNUM);
      Severity: Critical
      Found in modules/Vtiger/actions/PDF.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 "record" 8 times.
      Open

              $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('record');
      Severity: Critical
      Found in modules/Vtiger/actions/PDF.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.

      Argument 3 (value) is null but \App\Request::getArray() takes array defined at /code/app/Request.php:225
      Open

                              $template->setVariable($key, $request->getArray($key, 'Alnum', null));
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phan

      Call to method setParam from undeclared class \App\TextParser (Did you mean class \Tests\App\TextParser)
      Open

                              $template->getParser()->setParam($key, $value);
      Severity: Critical
      Found in modules/Vtiger/actions/PDF.php by phan

      Reference to undeclared property \Vtiger_PDF_Model->attachFiles
      Open

                      $attach = $template->attachFiles ?? [];
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phan

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

      class Vtiger_PDF_Action extends \App\Controller\Action

      The class Vtiger_PDF_Action is not named in CamelCase.
      Open

      class Vtiger_PDF_Action extends \App\Controller\Action
      {
          use \App\Controller\ExposeMethod;
      
          /**
      Severity: Minor
      Found in modules/Vtiger/actions/PDF.php by phpmd

      CamelCaseClassName

      Since: 0.2

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

      Example

      class class_name {
      }

      Source

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

          public function checkPermission(App\Request $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

                  foreach ($this->getRecords($request) as $recordId) {

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

              $response->emit();

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

              $pdfModuleName = $request->getModule();

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

                  'viewInstance' => $this,

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

                      $filePath = '';

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

                      switch ($template->get('type')) {

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

           */

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

          {

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

                          break 2;

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

                              foreach (['viewname', 'search_value', 'search_key', 'search_params', 'operator', 'cvId', 'relatedModule', 'relationId'] as $keyName) {

      Line exceeds 120 characters; contains 158 characters
      Open

                              foreach (['viewname', 'search_value', 'search_key', 'search_params', 'operator', 'cvId', 'relatedModule', 'relationId'] as $keyName) {

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

              if (!$userPrivilegesModel->hasModuleActionPermission($request->getModule(), 'ExportPdf')) {

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

              $pdfFlag = $request->getByType('flag', \App\Purifier::STANDARD) ?: null;

      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

           * @throws \App\Exceptions\NoPermitted

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

           *

      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

              $result = false;

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

                      if (\App\Privilege::isPermitted($moduleName, 'DetailView', $recordId) && $templateRecord->checkFiltersForRecord((int) $recordId)) {

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

              $this->exposeMethod('saveInventoryColumnScheme');

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

              $response = new Vtiger_Response();

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

              $view = $request->getByType('fromview', \App\Purifier::STANDARD);

      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

              if ($isRelatedView = ('RelatedList' === $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

              $emailPdf = 1 === $request->getInteger('email_pdf');

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

           * @return void

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

              $userVariables = $request->getArray('userVariables', \App\Purifier::TEXT);

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

              }

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

              $templates = ($recordId && !$isRelatedView) ? $pdfModel->getActiveTemplatesForRecord($recordId, $view, $pdfModuleName) : $pdfModel->getActiveTemplatesForModule($pdfModuleName, $view);

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

                  'records' => $recordIds,

      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

          use \App\Controller\ExposeMethod;

      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

           *

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

           */

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

              $response->setResult([

      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

                  'pdfModel' => $pdfModel,

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

                              $template->setVariable('recordsId', $validRecords);

      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

           * Constructor.

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

          public function __construct()

      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

                  'message' => \App\Language::translateArgs('LBL_NO_DATA_AVAILABLE', $moduleName),

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

                  $pdfModuleName = $request->getByType('relatedModule', \App\Purifier::ALNUM);

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

              $handlerClass = Vtiger_Loader::getComponentClassName('Model', 'PDF', $pdfModuleName);

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

              $pdfModel = new $handlerClass();

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

              $eventHandler->setParams([

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

              ]);

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

              $countTemplates = \count($templateIds);

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

                                      $template->setVariable($keyName, App\Condition::validSearchParams($pdfModuleName, $request->getArray($keyName)));

      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

                  $templateRecord = Vtiger_PDF_Model::getInstanceById($templateId);

      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 generate(App\Request $request): void

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

                  || ($request->has($key) && !\App\Privilege::isPermitted($pdfModuleName, 'RecordPdfInventory'))

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

                              $skip[$templateId] = 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

              $this->exposeMethod('generate');

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

           * Function to validate date.

      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 App\Request $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

              $recordIds = $this->getRecords($request);

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

              $key = 'inventoryColumns';

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

                      $pdf = \App\Pdf\Pdf::getInstanceByTemplateId($templateId);

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

                                  }

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

              $templateIds = $request->getArray('pdf_template', 'Integer');

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

              $eventHandler->setModuleName($pdfModuleName);

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

                  'templates' => $templateIds,

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

                              foreach ($recordIds as $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

                      }

      Line exceeds 120 characters; contains 146 characters
      Open

                      if ($attach || $emailPdf || ($countTemplates > 1 || (1 === $countTemplates && !isset($skip[$templateId]) && $countRecords > 1))) {

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

                          foreach ($attach as $info) {

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

              $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('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

           * Generate pdf.

      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

                  foreach ($templateIds as $templateId) {

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

                                      $validRecords[] = $record;

      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

                          default:

      Line exceeds 120 characters; contains 138 characters
      Open

              $moduleName = $request->has('relatedModule') ? $request->getByType('relatedModule', \App\Purifier::ALNUM) : $request->getModule();

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

           * @param \App\Request $request

      Line exceeds 120 characters; contains 147 characters
      Open

                      if (\App\Privilege::isPermitted($moduleName, 'DetailView', $recordId) && $templateRecord->checkFiltersForRecord((int) $recordId)) {

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

              $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('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

              $singlePdf = 1 === $request->getInteger('single_pdf');

      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 ($recordIds as $recordId) {

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

                      if (isset($skip[$templateId])) {

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

                          case Vtiger_PDF_Model::TEMPLATE_TYPE_SUMMARY:

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

                              $validRecords = [];

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

                                  if ($template->checkFiltersForRecord($record)) {

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

                                  if ('search_params' === $keyName) {

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

                              $template->setVariable($key, $request->getArray($key, 'Alnum', null));

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

                                  break 2;

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

                          $pdfFiles[] = ['name' => $fileName, 'path' => $filePath, 'recordId' => $recordId, 'moduleName' => $pdfModuleName];

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

                                  $tmpFileName = 'cache' . \DIRECTORY_SEPARATOR . 'pdf' . \DIRECTORY_SEPARATOR;

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

                                  if (\copy($info['path'], $tmpFileName)) {

      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->has('relatedModule') ? $request->getByType('relatedModule', \App\Purifier::ALNUM) : $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

              $save = [];

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

              $response->setResult([

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

                  'records' => $records,

      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

                      $attach = $template->attachFiles ?? [];

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

                          $fileName .= ($increment[$fileName]++ > 0 ? '_' . $increment[$fileName] : '') . '.pdf';

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

                              if (!isset($pdfFiles[$info['path']])) {

      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

              } elseif ($emailPdf) {

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

              parent::__construct();

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

                  Vtiger_PDF_Model::attachToEmail(\App\Json::encode($pdfFiles));

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

              $this->exposeMethod('hasValidTemplate');

      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

          }

      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

          public function validateRecords(App\Request $request): void

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

          public function hasValidTemplate(App\Request $request): void

      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

           *

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

          private function getRecords(App\Request $request): 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

           */

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

                  $records = [$request->getInteger('record')];

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

                  || array_diff($templateIds, array_keys($templates))

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

          }

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

              $eventHandler->trigger('PdfGenerateInit');

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

              $countRecords = \count($recordIds);

      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 145 characters
      Open

                                      $template->setVariable($keyName, App\Condition::validSearchParams($pdfModuleName, $request->getArray($keyName)));

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

                          case Vtiger_PDF_Model::TEMPLATE_TYPE_DYNAMIC:

      Line exceeds 120 characters; contains 166 characters
      Open

                                      $pdfFiles[$info['path']] = ['name' => $info['name'], 'path' => $tmpFileName, 'recordId' => $recordId, 'moduleName' => $pdfModuleName];

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

           * Checks if given record has valid pdf template.

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

              $response = new Vtiger_Response();

      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

              $this->exposeMethod('validateRecords');

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

           * @return void

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

              foreach ($request->getArray('templates', \App\Purifier::INTEGER) as $templateId) {

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

                  'valid' => $result,

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

              $recordIds = $eventHandler->getParam('records');

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

                      $template = $pdf->getTemplate();

      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

              if ($singlePdf) {

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

              } elseif ($pdfFiles) {

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

           * @return void

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

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

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

           * @param App\Request $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

              foreach ($records as $recordId) {

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

                  'message' => \App\Language::translate('LBL_SCHEME_SAVED', 'Settings:PDF'),

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

              $response->emit();

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

              return $records;

      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

                          $result = true;

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

          {

      Line exceeds 120 characters; contains 191 characters
      Open

              $templates = ($recordId && !$isRelatedView) ? $pdfModel->getActiveTemplatesForRecord($recordId, $view, $pdfModuleName) : $pdfModel->getActiveTemplatesForModule($pdfModuleName, $view);

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

              if (($emailPdf && !\App\Mail::checkInternalMailClient())

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

                      $pdf->loadTemplateData();

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

                  foreach ($pdfFiles as $pdfFile) {

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

                  $pdfFiles = array_values($pdfFiles);

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

                  Vtiger_PDF_Model::zipAndDownload($pdfFiles);

      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

              $recordId = $request->isEmpty('record', true) ? null : $request->getInteger('record');

      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

           * Save inventory column scheme.

      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

              } elseif (!$request->isEmpty('record', true)) {

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

              if ('generate' === $request->getMode()) {

      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\NoPermitted('LBL_EXPORT_ERROR');

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

              $eventHandler = new App\EventHandler();

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

              $increment = $skip = $pdfFiles = [];

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

                                      $template->setVariable($keyName, $request->isEmpty($keyName) ? '' : $request->getByType($keyName, \App\Purifier::ALNUM));

      Line exceeds 120 characters; contains 153 characters
      Open

                                      $template->setVariable($keyName, $request->isEmpty($keyName) ? '' : $request->getByType($keyName, \App\Purifier::ALNUM));

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

                              }

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

                              $template->getParser()->setParam($key, $value);

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

                          $filePath = $template->getPath();

      Line exceeds 120 characters; contains 134 characters
      Open

                          $pdfFiles[] = ['name' => $fileName, 'path' => $filePath, 'recordId' => $recordId, 'moduleName' => $pdfModuleName];

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

                      $pdf->output($filePath, $mode ?? $pdfFlag ?? 'D');

      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

              $records = $this->getRecords($request);

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

              $columns = $request->getArray('inventoryColumns');

      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

                  $request->validateReadAccess();

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

                      $eventHandler->trigger('PdfGenerate');

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

          /**

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

                  $save[$recordId] = $columns;

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

           * @return int[]

      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 validateRequest(App\Request $request)

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

                              $template->setVariable('recordId', $recordId);

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

                      if ($attach || $emailPdf || ($countTemplates > 1 || (1 === $countTemplates && !isset($skip[$templateId]) && $countRecords > 1))) {

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

                                  $tmpFileName = $tmpFileName . basename(tempnam($tmpFileName, 'Attach' . time()));

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

              $response->emit();

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

           * @return void

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

                          foreach ($userVariables[$template->getId()] as $key => $value) {

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

                  $records = \Vtiger_Mass_Action::getRecordsListFromRequest($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

          /**

      Line exceeds 120 characters; contains 143 characters
      Open

              $response->setResult(['valid' => (new Vtiger_PDF_Model())->checkActiveTemplates($recordId, $moduleName, $request->getByType('view'))]);

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

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

      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

                              }

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

                          $mode = 'F';

      Line exceeds 120 characters; contains 182 characters
      Open

                  \App\Pdf\Pdf::merge(array_column($pdfFiles, 'path'), \App\Fields\File::sanitizeUploadFileName(\App\Language::translate('LBL_PDF_MANY_IN_ONE')) . '.pdf', $pdfFlag ?: 'D');

      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

              \App\Pdf\InventoryColumns::saveInventoryColumnsForRecords($moduleName, $save);

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

                  $records = \Vtiger_RelationAjax_Action::getRecordsListFromRequest($request);

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

                              if (!$template->checkFiltersForRecord($recordId)) {

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

                      if (isset($userVariables[$template->getId()])) {

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

                      $eventHandler->addParams('pdf', $pdf);

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

                          $fileName = ($pdf->getFileName() ?: time());

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

                      unlink($pdfFile['path']);

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

              $response->setResult(['valid' => (new Vtiger_PDF_Model())->checkActiveTemplates($recordId, $moduleName, $request->getByType('view'))]);

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

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

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

              $response = new Vtiger_Response();

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

           * Get record ids.

      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

                  $request->validateWriteAccess();

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

                              if (!$template->checkFiltersForRecord($recordId)) {

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

                                  break 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

                                      $pdfFiles[$info['path']] = ['name' => $info['name'], 'path' => $tmpFileName, 'recordId' => $recordId, 'moduleName' => $pdfModuleName];

      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 saveInventoryColumnScheme(App\Request $request): void

      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

                              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

                          }

      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\Pdf\Pdf::merge(array_column($pdfFiles, 'path'), \App\Fields\File::sanitizeUploadFileName(\App\Language::translate('LBL_PDF_MANY_IN_ONE')) . '.pdf', $pdfFlag ?: 'D');

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

                              $template->setVariable('recordId', $recordId);

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

                          $increment[$fileName] = $increment[$fileName] ?? 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

          }

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

              if ($request->has('relatedModule')) {

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

      class Vtiger_PDF_Action extends \App\Controller\Action

      There are no issues that match your filters.

      Category
      Status