The class RecordStatus has an overall complexity of 55 which is very high. The configured complexity threshold is 50. Open
class RecordStatus
{
/**
* Variable using in picklist record state.
*
- Exclude checks
File RecordStatus.php
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Record status service file.
*
* @package App
Method activate
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function activate(string $moduleName, string $fieldName): bool
{
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
if (!($fieldModel = $moduleModel->getFieldByName($fieldName))) {
return false;
Method deactivate
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function deactivate(string $moduleName, string $fieldName): bool
{
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
if (!($fieldModel = $moduleModel->getFieldByName($fieldName))) {
return false;
Function activate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function activate(string $moduleName, string $fieldName): bool
{
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
if (!($fieldModel = $moduleModel->getFieldByName($fieldName))) {
return false;
- 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 deactivate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function deactivate(string $moduleName, string $fieldName): bool
{
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
if (!($fieldModel = $moduleModel->getFieldByName($fieldName))) {
return false;
- 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 addFieldsAndBlock
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function addFieldsAndBlock(string $moduleName)
{
$moduleModel = \Settings_LayoutEditor_Module_Model::getInstance('Settings:LayoutEditor')->setSourceModule($moduleName);
$blockId = (new \App\Db\Query())->select(['blockid'])->from('vtiger_blocks')->where(['blocklabel' => 'BL_RECORD_STATUS_TIMES', 'tabid' => $moduleModel->getId()])->scalar();
if (!$blockId) {
- 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 getStates
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function getStates(string $moduleName, int $state = null)
{
$fieldName = static::getFieldName($moduleName);
$primaryKey = Fields\Picklist::getPickListId($fieldName);
$values = [];
- 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 class RecordStatus has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13. Open
class RecordStatus
{
/**
* Variable using in picklist record state.
*
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '195', column '19'). Open
$blockId = (new \App\Db\Query())->select(['blockid'])->from('vtiger_blocks')->where(['blocklabel' => 'BL_RECORD_STATUS_TIMES', 'tabid' => $moduleModel->getId()])->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
The method getLockStatus has a boolean flag argument $byName, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getLockStatus(string $moduleName, bool $byName = true): array
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Missing class import via use statement (line '197', column '25'). Open
$blockInstance = new \Settings_LayoutEditor_Block_Model();
- 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\Json' in method 'deactivate'. Open
$fieldModel->set('fieldparams', Json::encode($params));
- 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 '139', column '9'). Open
public static function activate(string $moduleName, string $fieldName): bool
{
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
if (!($fieldModel = $moduleModel->getFieldByName($fieldName))) {
return false;
- 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\Db' in method 'deactivate'. Open
$db = 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\Picklist' in method 'getTimeCountingValues'. Open
foreach (Fields\Picklist::getValues($fieldName) as $row) {
- 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\Json' in method 'activate'. Open
$fieldModel->set('fieldparams', Json::encode($params));
- 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\Cache' in method 'addHistory'. Open
Cache::save("RecordStatus::StateDates::{$recordModel->getId()}", $after, date('Y-m-d H:i:s'));
- 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\Picklist' in method 'deactivate'. Open
$tableName = Fields\Picklist::getPickListTableName($fieldName);
- 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\EventHandler' in method 'activate'. Open
foreach (EventHandler::getAll() as $handler) {
- 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\EventHandler' in method 'activate'. Open
EventHandler::update([
'is_active' => 1,
'include_modules' => \implode(',', $modules),
], $handler['eventhandler_id']);
- 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 getFieldName uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$result = array_column($query->all(), 'fieldname', 'tabid');
}
- 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\Fields\Picklist' in method 'getStates'. Open
$primaryKey = Fields\Picklist::getPickListId($fieldName);
- 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 '230', column '9'). Open
public static function deactivate(string $moduleName, string $fieldName): bool
{
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
if (!($fieldModel = $moduleModel->getFieldByName($fieldName))) {
return false;
- 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\Utils\ServiceContracts' in method 'update'. Open
\App\Utils\ServiceContracts::updateExpectedTimes($recordModel, ['idle']);
- 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\Cache' in method 'getFieldName'. Open
return Cache::get('RecordStatus::getFieldName', $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\Db' in method 'activate'. Open
$db = 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\Cache' in method 'getStateDate'. Open
Cache::save($cacheName, $state, $date);
- 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_Module_Model' in method 'deactivate'. Open
$moduleModel = \Vtiger_Module_Model::getInstance($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\EventHandler' in method 'deactivate'. Open
EventHandler::update([
'is_active' => $modules ? 1 : 0,
'include_modules' => \implode(',', $modules),
], $handler['eventhandler_id']);
- 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\Utils\ServiceContracts' in method 'update'. Open
$recordModel->set($key . '_range_time', $recordModel->get($key . '_range_time') + Utils\ServiceContracts::getDiff($date, $recordModel));
- 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\Picklist' in method 'getTimeCountingIds'. Open
foreach (Fields\Picklist::getValues($fieldName) as $row) {
- 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\Cache' in method 'getLockStatus'. Open
if (Cache::has($cacheName, $byName)) {
- 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\Cache' in method 'getLockStatus'. Open
return Cache::get($cacheName, $byName);
- 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\Module' in method 'getFieldName'. Open
$result = $query->andWhere(['vtiger_field.tabid' => Module::getModuleId($moduleName)])->scalar();
- 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\Cache' in method 'getFieldName'. Open
Cache::save('RecordStatus::getFieldName', $moduleName, $result);
- 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\Module' in method 'getLockStatus'. Open
$tabId = Module::getModuleId($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 assigning values to variables in if clauses and the like (line '301', column '7'). Open
public static function update(\Vtiger_Record_Model $recordModel, string $fieldName)
{
$timeCountingValues = self::getTimeCountingValues($fieldName);
$previous = $recordModel->getPreviousValue($fieldName);
$current = $recordModel->get($fieldName);
- 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\Cache' in method 'getStateDate'. Open
if (Cache::has($cacheName, $state)) {
- 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\Picklist' in method 'getTimeCountingIds'. Open
$primaryKey = Fields\Picklist::getPickListId($fieldName);
- 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\Cache' in method 'getLockStatus'. Open
Cache::save($cacheName, $byName, $values);
- 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\Picklist' in method 'getStates'. Open
foreach (Fields\Picklist::getValues($fieldName) as $value) {
- 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_Module_Model' in method 'activate'. Open
$moduleModel = \Vtiger_Module_Model::getInstance($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\Fields\Picklist' in method 'activate'. Open
$tableName = Fields\Picklist::getPickListTableName($fieldName);
- 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\Cache' in method 'getStateDate'. Open
return Cache::get($cacheName, $state);
- 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\EventHandler' in method 'deactivate'. Open
foreach (EventHandler::getAll() as $handler) {
- 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 '301', column '77'). Open
public static function update(\Vtiger_Record_Model $recordModel, string $fieldName)
{
$timeCountingValues = self::getTimeCountingValues($fieldName);
$previous = $recordModel->getPreviousValue($fieldName);
$current = $recordModel->get($fieldName);
- 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\Cache' in method 'getFieldName'. Open
if (Cache::has('RecordStatus::getFieldName', $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
Define a constant instead of duplicating this literal "_state_history" 4 times. Open
$tableStatusHistory = $moduleModel->get('basetable') . '_state_history';
- 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 "include_modules" 6 times. Open
$modules = $handler['include_modules'] ? \explode(',', $handler['include_modules']) : [];
- 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" 6 times. Open
'crmid' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_INTEGER, 11),
- 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 "after" 3 times. Open
'after' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(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 "Y-m-d H:i:s" 3 times. Open
'date' => date('Y-m-d H:i:s'),
- 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 "fieldparams" 3 times. Open
$fieldModel->set('fieldparams', Json::encode($params));
- 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 "time_counting" 8 times. Open
if (!isset($tableSchema->columns['time_counting'])) {
- 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 "RecordStatus::getFieldName" 3 times. Open
if (Cache::has('RecordStatus::getFieldName', $moduleName)) {
- 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 "record_state" 8 times. Open
if (isset($value['record_state']) && $state === $value['record_state']) {
- 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 "tabid" 3 times. Open
$blockId = (new \App\Db\Query())->select(['blockid'])->from('vtiger_blocks')->where(['blocklabel' => 'BL_RECORD_STATUS_TIMES', 'tabid' => $moduleModel->getId()])->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 "basetable" 4 times. Open
$tableStatusHistory = $moduleModel->get('basetable') . '_state_history';
- 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.
Call to undeclared method \App\Db::getSchema
Open
$schema = $db->getSchema();
- Exclude checks
Reference to constant TYPE_TINYINT
from undeclared class \yii\db\Schema
(Did you mean class \App\Db\Drivers\Mysql\Schema or class \App\Db\Drivers\Pgsql\Schema) Open
'after' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0),
- Exclude checks
Reference to constant TYPE_TIMESTAMP
from undeclared class \yii\db\Schema
(Did you mean class \App\Db\Drivers\Mysql\Schema or class \App\Db\Drivers\Pgsql\Schema) Open
'date' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TIMESTAMP)->null(),
- Exclude checks
Reference to constant TYPE_TINYINT
from undeclared class \yii\db\Schema
(Did you mean class \App\Db\Drivers\Mysql\Schema or class \App\Db\Drivers\Pgsql\Schema) Open
'before' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0),
- Exclude checks
Reference to constant TYPE_UPK
from undeclared class \yii\db\Schema
(Did you mean class \App\Db\Drivers\Mysql\Schema or class \App\Db\Drivers\Pgsql\Schema) Open
'id' => \yii\db\Schema::TYPE_UPK,
- Exclude checks
Call to undeclared method \App\Db::getTableSchema
Open
$tableSchema = $db->getTableSchema($tableName);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = $db->createCommand();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()
- Exclude checks
Argument 2 (key)
is bool
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
Cache::save($cacheName, $byName, $values);
- Exclude checks
Reference to constant TYPE_INTEGER
from undeclared class \yii\db\Schema
(Did you mean class \App\Db\Drivers\Mysql\Schema or class \App\Db\Drivers\Pgsql\Schema) Open
'crmid' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_INTEGER, 11),
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$values = (new Db\Query())->select($field)
- Exclude checks
Saw an @param annotation for value,
but it was not found in the param list of function getStateDate(\Vtiger_Record_Model $recordModel, int $state) : string
Open
* @param int $value
- Exclude checks
Argument 2 (key)
is bool
but \App\Cache::get()
takes string
defined at /code/app/Cache.php:61
Open
return Cache::get($cacheName, $byName);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new Db\Query())
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::has()
takes string
defined at /code/app/Cache.php:74
Open
if (Cache::has($cacheName, $state)) {
- Exclude checks
Call to undeclared method \App\Db::getTableSchema
Open
if (!$db->getTableSchema($tableStatusHistory)) {
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$blockId = (new \App\Db\Query())->select(['blockid'])->from('vtiger_blocks')->where(['blocklabel' => 'BL_RECORD_STATUS_TIMES', 'tabid' => $moduleModel->getId()])->scalar();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = $db->createCommand();
- Exclude checks
Call to undeclared method \App\Db::getTableSchema
Open
$tableSchema = $db->getTableSchema($tableName);
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::save()
takes string
defined at /code/app/Cache.php:89
Open
Cache::save($cacheName, $state, $date);
- Exclude checks
Argument 2 (key)
is bool
but \App\Cache::has()
takes string
defined at /code/app/Cache.php:74
Open
if (Cache::has($cacheName, $byName)) {
- Exclude checks
Reference to constant TYPE_TINYINT
from undeclared class \yii\db\Schema
(Did you mean class \App\Db\Drivers\Mysql\Schema or class \App\Db\Drivers\Pgsql\Schema) Open
$dbCommand->addColumn($tableName, 'record_state', $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0))->execute();
- Exclude checks
Reference to constant TYPE_TINYINT
from undeclared class \yii\db\Schema
(Did you mean class \App\Db\Drivers\Mysql\Schema or class \App\Db\Drivers\Pgsql\Schema) Open
$dbCommand->addColumn($tableName, 'time_counting', $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0))->execute();
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::get()
takes string
defined at /code/app/Cache.php:61
Open
return Cache::get($cacheName, $state);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$date = (new Db\Query())->select(['date'])
- Exclude checks
Avoid excessively long variable names like $previousCountingValue. Keep variable name length under 20. Open
$previousCountingValue = $timeCountingValues[$previous] ?? null;
- Read upRead up
- Exclude checks
LongVariable
Since: 0.2
Detects when a field, formal or local variable is declared with a long name.
Example
class Something {
protected $reallyLongIntName = -3; // VIOLATION - Field
public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
$otherReallyLongName = -5; // VIOLATION - Local
for ($interestingIntIndex = 0; // VIOLATION - For
$interestingIntIndex < 10;
$interestingIntIndex++ ) {
}
}
}
Source https://phpmd.org/rules/naming.html#longvariable
Avoid variables with short names like $db. Configured minimum length is 3. Open
$db = 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 $db. Configured minimum length is 3. Open
$db = 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const TIME_COUNTING_REACTION = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'idle_range_time' => 'FL_IDLE_RANGE_TIME',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- 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
'crmid' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_INTEGER, 11),
- 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
const RECORD_STATE_OPEN = 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const TIME_COUNTING_RESOLVE = 2;
- 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
* @var string[]
- 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
self::RECORD_STATE_OPEN => 'LBL_RECORD_STATE_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
'date' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TIMESTAMP)->null(),
- 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
* Variable using in picklist record state.
- 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
$values = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($value['record_state']) && $state === $value['record_state']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'id' => \yii\db\Schema::TYPE_UPK,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::TIME_COUNTING_RESOLVE => 'solution',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'solution_range_time' => 'FL_SOLUTION_RANGE_TIME',
- 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
$values[$value[$primaryKey]] = $value['picklistValue'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableStatusHistory = $moduleModel->get('basetable') . '_state_history';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$db->getTableSchema($tableStatusHistory)) {
- 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
'idle_datatime' => 'FL_IDLE_DATE_TIME',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$values[$value[$primaryKey]] = $value['record_state'];
- 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
if (!isset($tableSchema->columns['record_state'])) {
- Exclude checks
Line exceeds 120 characters; contains 170 characters Open
$dbCommand->addColumn($tableName, 'record_state', $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0))->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const RECORD_STATE_CLOSED = 2;
- 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
'response_expected' => 'FL_RESPONSE_EXPECTED',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$schema = $db->getSchema();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createTable($tableStatusHistory, [
- 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
* Fields key by state time.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'closing_range_time' => 'FL_CLOSING_RANGE_TIME',
- 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 all record states.
- 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
* State time fields.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'solution_datatime' => 'FL_SOLUTION_DATE_TIME',
- 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
* Activate of the record status mechanism.
- 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 static function activate(string $moduleName, string $fieldName): bool
- 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
$params['isProcessStatusField'] = true;
- 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
* @var int
- 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
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'DateTime' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [
- 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 string $moduleName
- 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 = Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params = $fieldModel->getFieldParams();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'after' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0),
- 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
self::TIME_COUNTING_REACTION => 'response',
- 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
'RangeTime' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::RECORD_STATE_NO_CONCERN => 'LBL_RECORD_STATE_NO_CONCERN',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int|null $state
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!($fieldModel = $moduleModel->getFieldByName($fieldName))) {
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
'before' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Variable used to count times in specified categories.
- 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
'response_datatime' => 'FL_RESPONSE_DATE_TIME',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLabels(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get record state statuses by module name.
- 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 = $db->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'before' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = Fields\Picklist::getPickListTableName($fieldName);
- 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
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Variable used to count times in specified categories.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const TIME_COUNTING_IDLE = 3;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $stateTimeFields = [
- 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
self::RECORD_STATE_CLOSED => 'LBL_RECORD_STATE_CLOSED',
- 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 false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->createIndex($tableStatusHistory . '_crmid_idx', $tableStatusHistory, 'crmid')->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const RECORD_STATE_NO_CONCERN = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Variable using in picklist record state.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $fieldsByStateTime = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::TIME_COUNTING_IDLE => 'idle',
- 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
$fieldName = static::getFieldName($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$primaryKey = Fields\Picklist::getPickListId($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (null === $state && isset($value['record_state'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->addForeignKey('fk_1_' . $tableStatusHistory, $tableStatusHistory, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT')->execute();
- Exclude checks
Line exceeds 120 characters; contains 162 characters Open
$dbCommand->addForeignKey('fk_1_' . $tableStatusHistory, $tableStatusHistory, 'crmid', 'vtiger_crmentity', 'crmid', 'CASCADE', 'RESTRICT')->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
'response_range_time' => 'FL_RESPONSE_RANGE_TIME',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'closing_datatime' => 'FL_CLOSING_DATE_TIME',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'idle_expected' => 'FL_IDLE_DATE_EXPECTED',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string[] [id=>label]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array if state is specified values are labels, if not values are record_states, key is always primary key
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getStates(string $moduleName, int $state = null)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $values;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableSchema = $db->getTableSchema($tableName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->addColumn($tableName, 'record_state', $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0))->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
* Variable using in picklist record state.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Variable used to count times in specified categories.
- 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
'solution_expected' => 'FL_SOLUTION_EXPECTED',
- 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
foreach (Fields\Picklist::getValues($fieldName) as $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
$fieldModel->set('fieldparams', Json::encode($params));
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
'after' => $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = $handler['include_modules'] ? \explode(',', $handler['include_modules']) : [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
], $handler['eventhandler_id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockInstance->set('label', 'BL_RECORD_STATUS_TIMES');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'fieldLabel' => $label,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (EventHandler::getAll() as $handler) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules = $handler['include_modules'] ? \explode(',', $handler['include_modules']) : [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$timeCountingValues = self::getTimeCountingValues($fieldName);
- 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
$previous = $recordModel->getPreviousValue($fieldName);
- 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 (self::TIME_COUNTING_IDLE === $currentCountingValue) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Utils\ServiceContracts::updateExpectedTimes($recordModel, ['idle']);
- Exclude checks
Line exceeds 120 characters; contains 171 characters Open
$dbCommand->addColumn($tableName, 'time_counting', $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0))->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (static::$stateTimeFields as $type => $fields) {
- 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
* Deactivate of the record status mechanism.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->dropColumn($tableName, 'record_state')->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'include_modules' => \implode(',', $modules),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Add date history status to table.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- 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 string $fieldName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function addHistory(\Vtiger_Record_Model $recordModel, string $fieldName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($before !== $after) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set($key . '_range_time', $recordModel->get($key . '_range_time') + Utils\ServiceContracts::getDiff($date, $recordModel));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set($key . '_datatime', date('Y-m-d H:i:s'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($moduleName, $modules)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (bool) $fieldModel;
- 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 = $db->createCommand();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($previous && $currentCountingValue !== $previousCountingValue && null !== $previousCountingValue
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
$recordModel->set($key . '_range_time', $recordModel->get($key . '_range_time') + Utils\ServiceContracts::getDiff($date, $recordModel));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 180 characters Open
$blockId = (new \App\Db\Query())->select(['blockid'])->from('vtiger_blocks')->where(['blocklabel' => 'BL_RECORD_STATUS_TIMES', 'tabid' => $moduleModel->getId()])->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
], $handler['eventhandler_id']);
- 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
$before = $timeCountingValues[$recordModel->getPreviousValue($fieldName)] ?? 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->insert($recordModel->getModule()->get('basetable') . '_state_history', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function update(\Vtiger_Record_Model $recordModel, string $fieldName)
- 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 \Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $state
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Vtiger_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->dropTable($moduleModel->get('basetable') . '_state_history')->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($tableSchema->columns['record_state'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($modules[array_search($moduleName, $modules)]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'date' => date('Y-m-d H:i:s'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Record_Model $recordModel
- Exclude checks
Line exceeds 120 characters; contains 147 characters Open
&& ($date = self::getStateDate($recordModel, $previousCountingValue)) && ($key = self::$fieldsByStateTime[$previousCountingValue] ?? '')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get date from the status change history by status.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'include_modules' => \implode(',', $modules),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- 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
'is_active' => 1,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function addFieldsAndBlock(string $moduleName)
- 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
$moduleModel = \Settings_LayoutEditor_Module_Model::getInstance('Settings:LayoutEditor')->setSourceModule($moduleName);
- 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
$allFields = $moduleModel->getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function deactivate(string $moduleName, string $fieldName): bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'fieldTypeList' => 0,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!($fieldModel = $moduleModel->getFieldByName($fieldName))) {
- 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
$tableSchema = $db->getTableSchema($tableName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($tableSchema->columns['time_counting'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tableName = Fields\Picklist::getPickListTableName($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'is_active' => $modules ? 1 : 0,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->dropColumn($tableName, 'time_counting')->execute();
- 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
$after = $timeCountingValues[$recordModel->get($fieldName)] ?? 0;
- 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
'crmid' => $recordModel->getId(),
- 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
$currentCountingValue = $timeCountingValues[$current] ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& ($date = self::getStateDate($recordModel, $previousCountingValue)) && ($key = self::$fieldsByStateTime[$previousCountingValue] ?? '')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modules[] = $moduleName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockId = (new \App\Db\Query())->select(['blockid'])->from('vtiger_blocks')->where(['blocklabel' => 'BL_RECORD_STATUS_TIMES', 'tabid' => $moduleModel->getId()])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockId = $blockInstance->save($moduleModel->getSourceModule());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($fields as $name => $label) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->addField($type, $blockId, [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params = $fieldModel->getFieldParams();
- 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
'before' => $before,
- 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
foreach (EventHandler::getAll() as $handler) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($allFields[$name])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'generatedtype' => 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
Cache::save("RecordStatus::StateDates::{$recordModel->getId()}", $after, date('Y-m-d H:i:s'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($tableSchema->columns['time_counting'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
EventHandler::update([
- 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->set('fieldparams', Json::encode($params));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'after' => $after,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$previousCountingValue = $timeCountingValues[$previous] ?? null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dbCommand->addColumn($tableName, 'time_counting', $schema->createColumnSchemaBuilder(\yii\db\Schema::TYPE_TINYINT, 1)->notNull()->defaultValue(0))->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
if (!$blockId) {
- 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
$timeCountingValues = self::getTimeCountingValues($fieldName);
- 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
$moduleModel = \Settings_LayoutEditor_Module_Model::getInstance('Settings:LayoutEditor')->setSourceModule($moduleName);
- 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
$blockInstance = new \Settings_LayoutEditor_Block_Model();
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($params['isProcessStatusField']);
- 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
$current = $recordModel->get($fieldName);
- 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 ('Vtiger_RecordStatusHistory_Handler' === $handler['handler_class']) {
- 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
'fieldName' => $name,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Vtiger_RecordStatusHistory_Handler' === $handler['handler_class']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (bool) $fieldModel;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Update status times.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::addFieldsAndBlock($moduleName);
- 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
* Add block and fields.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockInstance->set('icon', 'fas fa-business-time');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'displayType' => 2,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'helpinfo' => 'Detail',
- 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 (\in_array($moduleName, $modules)) {
- 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
EventHandler::update([
- 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 $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
public static function getTimeCountingIds(string $moduleName)
- 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
$field = $byName ? ['vtiger_field.fieldname', 'value'] : ['valueid', 'value'];
- 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
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [];
- 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
$cacheName = "RecordStatus::getLockStatus::$moduleName";
- 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 Cache::get('RecordStatus::getFieldName', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from($recordModel->getModule()->get('basetable') . '_state_history')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get time counting values grouped by id from field name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- 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
$values = (new Db\Query())->select($field)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['tabid' => $tabId, 'presence' => [0, 2]])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()->queryAllByGroup($byName ? 2 : 0);
- 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 $values;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$fieldName) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tabId = Module::getModuleId($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('u_#__picklist_close_state')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_field', 'u_#__picklist_close_state.fieldid = vtiger_field.fieldid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::save($cacheName, $byName, $values);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = array_column($query->all(), 'fieldname', 'tabid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (Cache::has($cacheName, $state)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['crmid' => $recordModel->getId(), 'after' => $state])->orderBy(['date' => SORT_DESC])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Cache::save($cacheName, $state, $date);
- 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
$values[$row[$primaryKey]] = (int) $row['time_counting'];
- 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 (Cache::has('RecordStatus::getFieldName', $moduleName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_field')
- 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get time counting values grouped by id from field name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getTimeCountingValues(string $fieldName)
- 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::get($cacheName, $byName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select(['vtiger_field.fieldname', 'vtiger_field.tabid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($moduleName) {
- 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 (isset($row['time_counting'])) {
- 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 $date;
- 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
if (Cache::has($cacheName, $byName)) {
- 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
foreach (Fields\Picklist::getValues($fieldName) as $row) {
- 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 $values;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['LIKE', 'fieldparams', '"isProcessStatusField":true'])
- 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
Cache::save('RecordStatus::getFieldName', $moduleName, $result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return Cache::get($cacheName, $state);
- 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
$fieldName = static::getFieldName($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$values = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($row['time_counting'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$cacheName = "RecordStatus::StateDates::{$recordModel->getId()}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param bool $byName
- 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
$values = [];
- 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 process status field names.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName optional if we need only one field name for specified module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getFieldName(string $moduleName = '')
- 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
->andWhere(['presence' => [0, 2]]);
- 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
public static function getStateDate(\Vtiger_Record_Model $recordModel, int $state): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$values[$row[$fieldName]] = (int) $row['time_counting'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $values;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string|string[]
- 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
$query = (new Db\Query())
- 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
foreach (Fields\Picklist::getValues($fieldName) as $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $moduleName
- 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
$result = $query->andWhere(['vtiger_field.tabid' => Module::getModuleId($moduleName)])->scalar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$date = (new Db\Query())->select(['date'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$primaryKey = Fields\Picklist::getPickListId($fieldName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get closing states for all fields in module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getLockStatus(string $moduleName, bool $byName = true): array
- Exclude checks