isMandatorySave accesses the super-global variable $_FILES. Open
public function isMandatorySave()
{
return parent::isMandatorySave() || $_FILES;
}
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
saveToDb accesses the super-global variable $_FILES. Open
public function saveToDb()
{
$db = \App\Db::getInstance();
$fileNameByField = 'filename';
if ('I' === $this->get('filelocationtype')) {
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
The class Documents_Record_Model has an overall complexity of 68 which is very high. The configured complexity threshold is 50. Open
class Documents_Record_Model extends Vtiger_Record_Model
{
/** @var string[] Types included in the preview of the file. */
public $filePreview = [
'application/pdf', 'image/png', 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/bmp', 'image/vnd.microsoft.icon', 'image/tiff', 'image/tiff'
- Exclude checks
Function saveToDb
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function saveToDb()
{
$db = \App\Db::getInstance();
$fileNameByField = 'filename';
if ('I' === $this->get('filelocationtype')) {
- Read upRead up
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
File Record.php
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/* +***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
Function downloadFiles
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static function downloadFiles($recordsIds)
{
$zip = new ZipArchive();
$postfix = time() . '_' . random_int(0, 1000);
$zipPath = ROOT_DIRECTORY . '/cache/';
- Read upRead up
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 saveToDb
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function saveToDb()
{
$db = \App\Db::getInstance();
$fileNameByField = 'filename';
if ('I' === $this->get('filelocationtype')) {
Method downloadFiles
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function downloadFiles($recordsIds)
{
$zip = new ZipArchive();
$postfix = time() . '_' . random_int(0, 1000);
$zipPath = ROOT_DIRECTORY . '/cache/';
Method uploadAndSaveFile
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function uploadAndSaveFile($fileDetails)
{
$id = $this->getId();
$moduleName = $this->getModuleName();
$result = false;
Function getFilePath
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getFilePath(): string
{
$path = '';
if ($fileDetails = $this->getFileDetails()) {
$fileName = $fileDetails['name'];
- Read upRead up
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 downloadFile
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function downloadFile()
{
$fileContent = false;
if ($path = $this->getFilePath()) {
$fileDetails = $this->getFileDetails();
Function downloadFile
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function downloadFile()
{
$fileContent = false;
if ($path = $this->getFilePath()) {
$fileDetails = $this->getFileDetails();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function delete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function delete()
{
parent::delete();
$dbCommand = \App\Db::getInstance()->createCommand();
$attachmentsIds = (new \App\Db\Query())->select(['attachmentsid'])->from('vtiger_seattachmentsrel')->where(['crmid' => $this->getId()])->column();
- Read upRead up
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 saveToDb() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10. Open
public function saveToDb()
{
$db = \App\Db::getInstance();
$fileNameByField = 'filename';
if ('I' === $this->get('filelocationtype')) {
- Read upRead up
- Exclude checks
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 16 to the 15 allowed. Open
public static function downloadFiles($recordsIds)
- Read upRead up
- Exclude checks
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
Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed. Open
public function saveToDb()
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '104', column '30'). Open
$this->fileDetails = (new \App\Db\Query())->from('vtiger_attachments')
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '178', column '14'). Open
$zip = new ZipArchive();
- Read upRead up
- Exclude checks
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 '382', column '26'). Open
$attachmentsIds = (new \App\Db\Query())->select(['attachmentsid'])->from('vtiger_seattachmentsrel')->where(['crmid' => $this->getId()])->column();
- Read upRead up
- Exclude checks
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 '25'). Open
$downloadCount = (new \App\Db\Query())->select(['filedownloadcount'])->from('vtiger_notes')->where(['notesid' => $notesId])->scalar();
- Read upRead up
- Exclude checks
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 '253', column '15'). Open
return (new App\Db\Query())->select(['vtiger_crmentity.setype'])->from('vtiger_crmentity')->innerJoin('vtiger_senotesrel', 'vtiger_senotesrel.crmid = vtiger_crmentity.crmid')->where(['vtiger_crmentity.deleted' => 0, 'vtiger_senotesrel.notesid' => $record])->distinct()->column();
- Read upRead up
- Exclude checks
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 '384', column '23'). Open
$dataReader = (new \App\Db\Query())->select(['path', 'attachmentsid'])->from('vtiger_attachments')->where(['attachmentsid' => $attachmentsIds])->createCommand()->query();
- Read upRead up
- Exclude checks
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 '184', column '14'). Open
throw new \App\Exceptions\NoPermitted("cannot open <$fileName>");
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\App\Fields\File' in method 'downloadFile'. Open
return \App\Fields\File::loadFromInfo([
'path' => $filePath,
'name' => $fileDetails['name'],
'mimeType' => $fileDetails['type'],
]);
- Read upRead up
- Exclude checks
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 downloadFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
header("content-disposition: attachment; filename=\"$fileName\"");
}
- Read upRead up
- Exclude checks
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\Layout\Icon' in method 'getFileIconByFileType'. Open
return \App\Layout\Icon::getIconByFileType($fileType);
- Read upRead up
- Exclude checks
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 'saveToDb'. Open
if (UPLOAD_ERR_OK === $file['error'] && ($fileInstance = \App\Fields\File::loadFromRequest($file)) && $fileInstance->validateAndSecure()) {
- Read upRead up
- Exclude checks
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 saveToDb uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$db->createCommand()->delete('vtiger_seattachmentsrel', ['crmid' => $this->getId()])->execute();
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Log' in method 'uploadAndSaveFile'. Open
\App\Log::trace('Exiting uploadAndSaveFile');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'checkFileIntegrity'. Open
$fileName = html_entity_decode($fileDetails['name'], ENT_QUOTES, \App\Config::main('default_charset'));
- Read upRead up
- Exclude checks
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 assigning values to variables in if clauses and the like (line '189', column '8'). Open
public static function downloadFiles($recordsIds)
{
$zip = new ZipArchive();
$postfix = time() . '_' . random_int(0, 1000);
$zipPath = ROOT_DIRECTORY . '/cache/';
- Read upRead up
- Exclude checks
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 '\App\Log' in method 'uploadAndSaveFile'. Open
\App\Log::trace("Entering into uploadAndSaveFile($id,$moduleName) method.");
- Read upRead up
- Exclude checks
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 getFilePath uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$savedFile = $fileDetails['attachmentsid'] . '_' . $fileName;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'Vtiger_Link_Model' in method 'getRecordListViewLinksLeftSide'. Open
$links['LBL_PREVIEW_FILE'] = Vtiger_Link_Model::getInstanceFromValues([
'linklabel' => 'LBL_PREVIEW_FILE',
'linkhref' => true,
'linkurl' => $this->getDownloadFileURL() . '&show=1',
'linkicon' => 'fas fa-binoculars',
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'getFilePath'. Open
$fileName = html_entity_decode($fileName, ENT_QUOTES, \App\Config::main('default_charset'));
- Read upRead up
- Exclude checks
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 assigning values to variables in if clauses and the like (line '154', column '7'). Open
public function getFilePath(): string
{
$path = '';
if ($fileDetails = $this->getFileDetails()) {
$fileName = $fileDetails['name'];
- Read upRead up
- Exclude checks
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 '\App\Fields\File' in method 'uploadAndSaveFile'. Open
$fileInstance = \App\Fields\File::loadFromRequest($fileDetails);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'uploadAndSaveFile'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
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 'uploadAndSaveFile'. Open
$uploadFilePath = \App\Fields\File::initStorageFileDirectory($moduleName);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'uploadAndSaveFile'. Open
if (\App\Config::module($this->getModuleName(), 'storagePath')) {
- Read upRead up
- Exclude checks
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 'saveToDb'. Open
\App\Log::error("Error while saving a file, saving failed. | ID: {$this->getId()} | File: {$file['name']} | Error: " . \App\Fields\File::getErrorMessage($file['error']));
- Read upRead up
- Exclude checks
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 uploadAndSaveFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$db->createCommand()->delete('vtiger_attachments', ['attachmentsid' => $currentId])->execute();
}
- Read upRead up
- Exclude checks
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 downloadFiles uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$savedFile = $fileDetails['attachmentsid'] . '_' . html_entity_decode($fileDetails['name'], ENT_QUOTES, \App\Config::main('default_charset'));
}
- Read upRead up
- Exclude checks
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\Purifier' in method 'saveToDb'. Open
$this->setFieldValue('filename', \App\Purifier::decodeHtml(App\Purifier::purify($file['name'])))
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Vtiger_Link_Model' in method 'getRecordRelatedListViewLinksLeftSide'. Open
$links['LBL_PREVIEW_FILE'] = Vtiger_Link_Model::getInstanceFromValues([
'linklabel' => 'LBL_PREVIEW_FILE',
'linkhref' => true,
'linkurl' => $this->getDownloadFileURL() . '&show=1',
'linkicon' => 'fas fa-binoculars',
- Read upRead up
- Exclude checks
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 assigning values to variables in if clauses and the like (line '299', column '46'). Open
public function saveToDb()
{
$db = \App\Db::getInstance();
$fileNameByField = 'filename';
if ('I' === $this->get('filelocationtype')) {
- Read upRead up
- Exclude checks
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 assigning values to variables in if clauses and the like (line '88', column '50'). Open
public function checkFileIntegrity()
{
$returnValue = false;
if ('I' === $this->get('filelocationtype') && ($fileDetails = $this->getFileDetails())) {
$fileName = html_entity_decode($fileDetails['name'], ENT_QUOTES, \App\Config::main('default_charset'));
- Read upRead up
- Exclude checks
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
The method saveToDb uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$file = $_FILES[$fileNameByField] ?? [];
}
- Read upRead up
- Exclude checks
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\Config' in method 'downloadFiles'. Open
$savedFile = $fileDetails['attachmentsid'] . '_' . html_entity_decode($fileDetails['name'], ENT_QUOTES, \App\Config::main('default_charset'));
- Read upRead up
- Exclude checks
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 uploadAndSaveFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$destinyFilePath = ROOT_DIRECTORY . DIRECTORY_SEPARATOR . $uploadFilePath . $currentId;
}
- Read upRead up
- Exclude checks
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\Request' in method 'saveToDb'. Open
$file['original_name'] = \App\Request::_get('0_hidden');
- Read upRead up
- Exclude checks
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 'downloadFiles'. Open
header('content-type: ' . \App\Fields\File::getMimeContentType($fileName));
- Read upRead up
- Exclude checks
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 saveToDb uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
\App\Log::error("Error while saving a file, saving failed. | ID: {$this->getId()} | File: {$file['name']} | Error: " . \App\Fields\File::getErrorMessage($file['error']));
$file = [];
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Log' in method 'saveToDb'. Open
\App\Log::error("Error while saving a file, saving failed. | ID: {$this->getId()} | File: {$file['name']} | Error: " . \App\Fields\File::getErrorMessage($file['error']));
- Read upRead up
- Exclude checks
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 assigning values to variables in if clauses and the like (line '118', column '7'). Open
public function downloadFile()
{
$fileContent = false;
if ($path = $this->getFilePath()) {
$fileDetails = $this->getFileDetails();
- Read upRead up
- Exclude checks
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 assigning values to variables in if clauses and the like (line '30', column '62'). Open
public function getDownloadFileURL()
{
if ('I' === $this->getValueByField('filelocationtype') && ($fileDetails = $this->getFileDetails())) {
return 'file.php?module=' . $this->getModuleName() . '&action=DownloadFile&record=' . $this->getId() . '&fileid=' . $fileDetails['attachmentsid'];
}
- Read upRead up
- Exclude checks
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 '\App\Log' in method 'downloadFiles'. Open
\App\Log::error("cannot open <$fileName>\n");
- Read upRead up
- Exclude checks
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\Purifier' in method 'uploadAndSaveFile'. Open
'name' => ltrim(App\Purifier::purify($fileName)),
- Read upRead up
- Exclude checks
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\Purifier' in method 'saveToDb'. Open
$this->setFieldValue('filename', \App\Purifier::decodeHtml(App\Purifier::purify($file['name'])))
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Db' in method 'saveToDb'. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
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 saveToDb uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$file = [];
}
- Read upRead up
- Exclude checks
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
Define a constant instead of duplicating this literal "notesid" 3 times. Open
App\Db::getInstance()->createCommand()->update('vtiger_notes', ['filestatus' => $status], ['notesid' => $this->get('id')])->execute();
- Read upRead up
- Exclude checks
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 "error" 3 times. Open
if (!empty($file['name']) && isset($file['error']) && $file['size'] > 0) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "LBL_PREVIEW_FILE" 4 times. Open
$links['LBL_PREVIEW_FILE'] = Vtiger_Link_Model::getInstanceFromValues([
- Read upRead up
- Exclude checks
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 "filelocationtype" 7 times. Open
if ('I' === $this->getValueByField('filelocationtype') && ($fileDetails = $this->getFileDetails())) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "vtiger_seattachmentsrel" 5 times. Open
->innerJoin('vtiger_seattachmentsrel', 'vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid')
- Read upRead up
- Exclude checks
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 "filetype" 4 times. Open
if (!$this->isReadOnly() && \in_array($this->getValueByField('filetype'), $this->filePreview)) {
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "crmid" 5 times. Open
->where(['crmid' => $this->get('id')])
- Read upRead up
- Exclude checks
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 "filedownloadcount" 4 times. Open
$downloadCount = (new \App\Db\Query())->select(['filedownloadcount'])->from('vtiger_notes')->where(['notesid' => $notesId])->scalar();
- Read upRead up
- Exclude checks
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 "image/jpeg" 3 times. Open
'application/pdf', 'image/png', 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/bmp', 'image/vnd.microsoft.icon', 'image/tiff', 'image/tiff'
- Read upRead up
- Exclude checks
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 "default_charset" 3 times. Open
$fileName = html_entity_decode($fileDetails['name'], ENT_QUOTES, \App\Config::main('default_charset'));
- Read upRead up
- Exclude checks
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 "filename" 6 times. Open
return $this->get('filename');
- Read upRead up
- Exclude checks
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 "attachmentsid" 15 times. Open
return 'file.php?module=' . $this->getModuleName() . '&action=DownloadFile&record=' . $this->getId() . '&fileid=' . $fileDetails['attachmentsid'];
- Read upRead up
- Exclude checks
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 "original_name" 3 times. Open
$file['original_name'] = \App\Request::_get('0_hidden');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "vtiger_notes" 3 times. Open
App\Db::getInstance()->createCommand()->update('vtiger_notes', ['filestatus' => $status], ['notesid' => $this->get('id')])->execute();
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "vtiger_attachments" 5 times. Open
$this->fileDetails = (new \App\Db\Query())->from('vtiger_attachments')
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Avoid unused local variables such as '$match'. Open
if (!empty($fileName) && !preg_match('/^\w{1,5}:\/\/|^\w{0,3}:?\\\\\\\\/', trim($fileName), $match)) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Call to undeclared method \App\Db\Query::select
Open
$downloadCount = (new \App\Db\Query())->select(['filedownloadcount'])->from('vtiger_notes')->where(['notesid' => $notesId])->scalar();
- Exclude checks
Reference to undeclared property \Documents_Record_Model->file
(Did you mean $file) Open
$this->file = [];
- Exclude checks
Reference to undeclared property \Documents_Record_Model->file
Open
if (isset($this->file)) {
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
App\Db::getInstance()->createCommand()->update('vtiger_notes', ['filestatus' => $status], ['notesid' => $this->get('id')])->execute();
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error("Error while saving a file, saving failed. | ID: {$this->getId()} | File: {$file['name']} | Error: " . \App\Fields\File::getErrorMessage($file['error']));
- Exclude checks
Reference to undeclared property \Documents_Record_Model->file
(Did you mean $file) Open
if ($this->uploadAndSaveFile($file) && isset($this->file)) {
- Exclude checks
Reference to undeclared property \Documents_Record_Model->fileDetails
Open
return $this->fileDetails;
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error("cannot open <$fileName>\n");
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_seattachmentsrel', ['crmid' => $id])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new \App\Db\Query())->select(['path', 'attachmentsid'])->from('vtiger_attachments')->where(['attachmentsid' => $attachmentsIds])->createCommand()->query();
- Exclude checks
Reference to undeclared property \Documents_Record_Model->file
Open
$file = $this->file;
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_attachments', ['attachmentsid' => $currentId])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$attachmentsIds = (new \App\Db\Query())->select(['attachmentsid'])->from('vtiger_seattachmentsrel')->where(['crmid' => $this->getId()])->column();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->fileDetails = (new \App\Db\Query())->from('vtiger_attachments')
- Exclude checks
Reference to undeclared property \Documents_Record_Model->fileDetails
Open
$this->fileDetails = (new \App\Db\Query())->from('vtiger_attachments')
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->update('vtiger_notes', ['filedownloadcount' => ++$downloadCount], ['notesid' => $notesId])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new App\Db\Query())->select(['vtiger_crmentity.setype'])->from('vtiger_crmentity')->innerJoin('vtiger_senotesrel', 'vtiger_senotesrel.crmid = vtiger_crmentity.crmid')->where(['vtiger_crmentity.deleted' => 0, 'vtiger_senotesrel.notesid' => $record])->distinct()->column();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('vtiger_seattachmentsrel', ['crmid' => $id, 'attachmentsid' => $currentId])->execute();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Exiting uploadAndSaveFile');
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Reference to undeclared property \Documents_Record_Model->fileDetails
Open
if (!isset($this->fileDetails)) {
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_seattachmentsrel', ['crmid' => $this->getId()])->execute();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Entering into uploadAndSaveFile($id,$moduleName) method.");
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('vtiger_attachments', [
- Exclude checks
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!$this->isReadOnly() && \in_array($this->getValueByField('filetype'), $this->filePreview)) {
$links['LBL_PREVIEW_FILE'] = Vtiger_Link_Model::getInstanceFromValues([
'linklabel' => 'LBL_PREVIEW_FILE',
'linkhref' => true,
'linkurl' => $this->getDownloadFileURL() . '&show=1',
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 91.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (!$this->isReadOnly() && \in_array($this->getValueByField('filetype'), $this->filePreview)) {
$links['LBL_PREVIEW_FILE'] = Vtiger_Link_Model::getInstanceFromValues([
'linklabel' => 'LBL_PREVIEW_FILE',
'linkhref' => true,
'linkurl' => $this->getDownloadFileURL() . '&show=1',
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 91.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Documents_Record_Model extends Vtiger_Record_Model
- Exclude checks
The class Documents_Record_Model is not named in CamelCase. Open
class Documents_Record_Model extends Vtiger_Record_Model
{
/** @var string[] Types included in the preview of the file. */
public $filePreview = [
'application/pdf', 'image/png', 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/bmp', 'image/vnd.microsoft.icon', 'image/tiff', 'image/tiff'
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $id. Configured minimum length is 3. Open
$id = $this->getId();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = \App\Db::getInstance();
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get download file url.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string[] Types included in the preview of the file. */
- Exclude checks
Line exceeds 120 characters; contains 158 characters Open
return 'file.php?module=' . $this->getModuleName() . '&action=DownloadFile&record=' . $this->getId() . '&fileid=' . $fileDetails['attachmentsid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getRecordListViewLinksLeftSide()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'file.php?module=' . $this->getModuleName() . '&action=DownloadFile&record=' . $this->getId() . '&fileid=' . $fileDetails['attachmentsid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDownloadFileURL()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('filename');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'application/pdf', 'image/png', 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/bmp', 'image/vnd.microsoft.icon', 'image/tiff', 'image/tiff'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('I' === $this->getValueByField('filelocationtype') && ($fileDetails = $this->getFileDetails())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $this->getDownloadFileURL() . '&show=1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check file integrity.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = html_entity_decode($fileDetails['name'], ENT_QUOTES, \App\Config::main('default_charset'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFileDetails()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => $fileDetails['name'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (fopen($filePath, 'r')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('content-disposition: inline');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$filePath = $fileDetails['path'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => 'fas fa-binoculars',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_merge($links, parent::getRecordListViewLinksLeftSide());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkhref' => true,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$returnValue = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Download file.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Fields\File::loadFromInfo([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error("cannot open <$fileName>\n");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->isReadOnly() && \in_array($this->getValueByField('filetype'), $this->filePreview)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkFileIntegrity()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$returnValue = (file_exists($savedFile) && fopen($savedFile, 'r')) || (file_exists("{$savedFile}_{$fileName}") && fopen("{$savedFile}_{$fileName}", 'r'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->fileDetails)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileContent = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFilePath(): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = html_entity_decode($fileName, ENT_QUOTES, \App\Config::main('default_charset'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$savedFile = $fileDetails['attachmentsid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip = new ZipArchive();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($recordsIds as $recordId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('I' === $documentModel->get('filelocationtype')) {
- Exclude checks
Line exceeds 120 characters; contains 162 characters Open
'application/pdf', 'image/png', 'image/jpeg', 'image/jpeg', 'image/jpeg', 'image/gif', 'image/bmp', 'image/vnd.microsoft.icon', 'image/tiff', 'image/tiff'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->isReadOnly() && \in_array($this->getValueByField('filetype'), $this->filePreview)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links['LBL_PREVIEW_FILE'] = Vtiger_Link_Model::getInstanceFromValues([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $this->getDownloadFileURL() . '&show=1',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkclass' => 'btn-sm btn-light',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getRecordRelatedListViewLinksLeftSide(Vtiger_RelationListView_Model $viewModel)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_PREVIEW_FILE',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function checkFileIntegrityURL()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($path = $this->getFilePath()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
if (file_exists(ROOT_DIRECTORY . DIRECTORY_SEPARATOR . $fileDetails['path'] . $fileDetails['attachmentsid'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $filePreview = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 166 characters Open
$returnValue = (file_exists($savedFile) && fopen($savedFile, 'r')) || (file_exists("{$savedFile}_{$fileName}") && fopen("{$savedFile}_{$fileName}", 'r'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function downloadFile()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileContent = fread(fopen($filePath, 'r'), $fileSize);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->get('show')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header("content-disposition: attachment; filename=\"$fileName\"");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Download files.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zipPath = ROOT_DIRECTORY . '/cache/';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_seattachmentsrel', 'vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get file path.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $path;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (true !== $zip->open($fileName, ZIPARCHIVE::CREATE)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkhref' => true,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_merge($links, parent::getRecordRelatedListViewLinksLeftSide($viewModel));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileSize = $fileSize + ($fileSize % 1024);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('content-type: ' . $fileDetails['type']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('cache-control: private');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
echo $fileContent;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists(ROOT_DIRECTORY . DIRECTORY_SEPARATOR . $fileDetails['path'] . $fileDetails['attachmentsid'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$documentModel = self::getInstanceById($recordId);
- Exclude checks
Line exceeds 120 characters; contains 174 characters Open
return "javascript:Documents_Detail_Js.checkFileIntegrity('index.php?module=" . $this->getModuleName() . '&action=CheckFileIntegrity&record=' . $this->getId() . "')";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->fileDetails = (new \App\Db\Query())->from('vtiger_attachments')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->fileDetails;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkclass' => 'btn-sm btn-light',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int[] $recordsIds
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\NoPermitted("cannot open <$fileName>");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktarget' => '_blank',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('I' === $this->get('filelocationtype') && ($fileDetails = $this->getFileDetails())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['crmid' => $this->get('id')])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$path = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function downloadFiles($recordsIds)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = $zipPath . "documentsZipFile_{$postfix}.zip";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check file integrity url.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$filePath = ROOT_DIRECTORY . DIRECTORY_SEPARATOR . $path;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = $this->get('filename');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('I' === $this->get('filelocationtype')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links['LBL_PREVIEW_FILE'] = Vtiger_Link_Model::getInstanceFromValues([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$savedFile = $fileDetails['path'] . $fileDetails['attachmentsid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $returnValue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists(ROOT_DIRECTORY . DIRECTORY_SEPARATOR . $fileDetails['path'] . $savedFile)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$postfix = time() . '_' . random_int(0, 1000);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktarget' => '_blank'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->get('return')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = $fileDetails['name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_PREVIEW_FILE',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return "javascript:Documents_Detail_Js.checkFileIntegrity('index.php?module=" . $this->getModuleName() . '&action=CheckFileIntegrity&record=' . $this->getId() . "')";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
->innerJoin('vtiger_seattachmentsrel', 'vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileDetails = $this->getFileDetails();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mimeType' => $fileDetails['type'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fileDetails = $this->getFileDetails()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get file details.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('pragma: public');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$savedFile = $fileDetails['attachmentsid'] . '_' . $fileName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => 'fas fa-binoculars',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'path' => $filePath,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?module=Documents&action=UpdateDownloadCount&record=' . $this->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileSize = filesize($filePath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $fieldName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$path = $fileDetails['path'] . $savedFile;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('I' === $this->get('filelocationtype')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fileDetails = $documentModel->getFileDetails()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($filePath . $fileDetails['attachmentsid'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// If filename does not has the protocol prefix, default it to http://
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function updateFileStatus($status)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $record
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setFieldValue('filedownloadcount', 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$savedFile = $fileDetails['attachmentsid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$documentModel->updateDownloadCount();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('content-type: ' . \App\Fields\File::getMimeContentType($fileName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('accept-ranges: bytes');
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
\App\Db::getInstance()->createCommand()->update('vtiger_notes', ['filedownloadcount' => ++$downloadCount], ['notesid' => $notesId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set($fieldModel->getName(), $value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getReferenceModuleByDocId($record)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function isMandatorySave()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($this->file)) {
- Exclude checks
Line exceeds 120 characters; contains 155 characters Open
if (UPLOAD_ERR_OK === $file['error'] && ($fileInstance = \App\Fields\File::loadFromRequest($file)) && $fileInstance->validateAndSecure()) {
- Exclude checks
Line exceeds 120 characters; contains 190 characters Open
\App\Log::error("Error while saving a file, saving failed. | ID: {$this->getId()} | File: {$file['name']} | Error: " . \App\Fields\File::getErrorMessage($file['error']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setFieldValue('filetype', '')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file['original_name'] = \App\Request::_get('0_hidden');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileInstance = \App\Fields\File::loadFromRequest($fileDetails);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'type' => $fileDetails['type'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new \App\Db\Query())->select(['path', 'attachmentsid'])->from('vtiger_attachments')->where(['attachmentsid' => $attachmentsIds])->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function updateDownloadCount()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Layout\Icon::getIconByFileType($fileType);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fieldModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($file['name']) && isset($file['error']) && $file['size'] > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('I' === $this->get('filelocationtype')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_attachments', ['attachmentsid' => $currentId])->execute();
- Exclude checks
Line exceeds 120 characters; contains 182 characters Open
$dataReader = (new \App\Db\Query())->select(['path', 'attachmentsid'])->from('vtiger_attachments')->where(['attachmentsid' => $attachmentsIds])->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($fileName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->delete('vtiger_attachments', ['attachmentsid' => $attachmentsIds])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
readfile($fileName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unlink($fileName);
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
$downloadCount = (new \App\Db\Query())->select(['filedownloadcount'])->from('vtiger_notes')->where(['notesid' => $notesId])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function saveToDb()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setFieldValue('filesize', 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::saveToDb();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* This function is used to upload the attachment in the server and save that attachment information in db.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->ext['attachmentsName'] = $fileName = empty($fileDetails['original_name']) ? $fileDetails['name'] : $fileDetails['original_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('Exiting uploadAndSaveFile');
- Exclude checks
Line exceeds 120 characters; contains 287 characters Open
return (new App\Db\Query())->select(['vtiger_crmentity.setype'])->from('vtiger_crmentity')->innerJoin('vtiger_senotesrel', 'vtiger_senotesrel.crmid = vtiger_crmentity.crmid')->where(['vtiger_crmentity.deleted' => 0, 'vtiger_senotesrel.notesid' => $record])->distinct()->column();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return parent::isMandatorySave() || $_FILES;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Sets field value for save.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (UPLOAD_ERR_OK === $file['error'] && ($fileInstance = \App\Fields\File::loadFromRequest($file)) && $fileInstance->validateAndSecure()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = "http://$fileName";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($file) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\App\Config::module($this->getModuleName(), 'storagePath')) {
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
$attachmentsIds = (new \App\Db\Query())->select(['attachmentsid'])->from('vtiger_seattachmentsrel')->where(['crmid' => $this->getId()])->column();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$savedFile = $fileDetails['attachmentsid'] . '_' . html_entity_decode($fileDetails['name'], ENT_QUOTES, \App\Config::main('default_charset'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists($filePath . $savedFile)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Update file status.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $value
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error("Error while saving a file, saving failed. | ID: {$this->getId()} | File: {$file['name']} | Error: " . \App\Fields\File::getErrorMessage($file['error']));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->file = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_seattachmentsrel', ['crmid' => $this->getId()])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unlink($fileName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert('vtiger_seattachmentsrel', ['crmid' => $id, 'attachmentsid' => $currentId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->ext['attachmentsId'] = $currentId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('content-disposition: attachment; filename="' . basename($fileName) . '";');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
App\Db::getInstance()->createCommand()->update('vtiger_notes', ['filestatus' => $status], ['notesid' => $this->get('id')])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileNameByField = 'filename';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file = $this->file;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setFieldValue('filesize', $fileInstance->getSize())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function uploadAndSaveFile($fileDetails)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Entering into uploadAndSaveFile($id,$moduleName) method.");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->addFile($filePath . $savedFile, basename($documentModel->get('filename')));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
App\Db::getInstance()->createCommand()->update('vtiger_notes', ['filestatus' => $status], ['notesid' => $this->get('id')])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->update('vtiger_notes', ['filedownloadcount' => ++$downloadCount], ['notesid' => $notesId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return $this
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setFieldValue('filetype', $fileInstance->getMimeType())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$uploadFilePath = \App\Fields\File::initStorageFileDirectory($moduleName);
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$db->createCommand()->insert('vtiger_seattachmentsrel', ['crmid' => $id, 'attachmentsid' => $currentId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$notesId = $this->get('id');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setFieldValue(string $fieldName, $value)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$downloadCount = (new \App\Db\Query())->select(['filedownloadcount'])->from('vtiger_notes')->where(['notesid' => $notesId])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Protocol prefix could be like (https://, smb://, file://, \\, smb:\\,...)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file = $_FILES[$fileNameByField] ?? [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->setFieldValue('filedownloadcount', null);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($fileName) && !preg_match('/^\w{1,5}:\/\/|^\w{0,3}:?\\\\\\\\/', trim($fileName), $match)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setFieldValue('filename', $fileName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$id = $this->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentId = $db->getLastInsertID('vtiger_attachments_attachmentsid_seq');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function delete()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($attachmentsIds)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($fileInstance->moveFile($destinyFilePath)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_seattachmentsrel', ['crmid' => $id])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = true;
- Exclude checks
Line exceeds 120 characters; contains 166 characters Open
$savedFile = $fileDetails['attachmentsid'] . '_' . html_entity_decode($fileDetails['name'], ENT_QUOTES, \App\Config::main('default_charset'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getFileIconByFileType($fileType)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setFieldValue('filename', \App\Purifier::decodeHtml(App\Purifier::purify($file['name'])))
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('E' === $this->get('filelocationtype')) {
- Exclude checks
Line exceeds 120 characters; contains 144 characters Open
$this->ext['attachmentsName'] = $fileName = empty($fileDetails['original_name']) ? $fileDetails['name'] : $fileDetails['original_name'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get download count update url.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get reference module by doc id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to save record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $this->getModuleName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'path' => $uploadFilePath
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $result;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
header('content-length: ' . filesize($fileName));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $status
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDownloadCountUpdateUrl()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new App\Db\Query())->select(['vtiger_crmentity.setype'])->from('vtiger_crmentity')->innerJoin('vtiger_senotesrel', 'vtiger_senotesrel.crmid = vtiger_crmentity.crmid')->where(['vtiger_crmentity.deleted' => 0, 'vtiger_senotesrel.notesid' => $record])->distinct()->column();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = $this->get($fileNameByField);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Update download count.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $this->getField($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setDataForSave([$fieldModel->getTableName() => [$fieldModel->getColumnName() => $value]]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Inserting into attachments table
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->uploadAndSaveFile($file) && isset($this->file)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $fileDetails - array which contains the file information(name, type, size, tmp_name and error)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert('vtiger_attachments', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => ltrim(App\Purifier::purify($fileName)),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$attachmentsIds = (new \App\Db\Query())->select(['attachmentsid'])->from('vtiger_seattachmentsrel')->where(['crmid' => $this->getId()])->column();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$destinyFilePath = $uploadFilePath . $currentId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$destinyFilePath = ROOT_DIRECTORY . DIRECTORY_SEPARATOR . $uploadFilePath . $currentId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::delete();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = $row['path'] . $row['attachmentsid'];
- Exclude checks
Class name "Documents_Record_Model" is not in camel caps format Open
class Documents_Record_Model extends Vtiger_Record_Model
- Exclude checks