Function save
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
public function save()
{
$db = \App\Db::getInstance();
$settingsModel = Settings_Menu_Module_Model::getInstance();
$edit = $this->get('edit');
- 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 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Settings menu record model class.
*
The class Settings_Menu_Record_Model has 11 public methods. Consider refactoring Settings_Menu_Record_Model to keep number of public methods under 10. Open
class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model
{
/**
* Menu for Roles.
*/
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
The class Settings_Menu_Record_Model has an overall complexity of 85 which is very high. The configured complexity threshold is 50. Open
class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model
{
/**
* Menu for Roles.
*/
- Exclude checks
Function parseToDisplay
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public static function parseToDisplay(array $menus): array
{
$userPrivilegesModel = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
$data = [];
foreach ($menus as $key => $item) {
- 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 save
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save()
{
$db = \App\Db::getInstance();
$settingsModel = Settings_Menu_Module_Model::getInstance();
$edit = $this->get('edit');
Function createContentMenu
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function createContentMenu($menu)
{
unset($menu['filters']);
$content = $menu['id'] . '=>[';
foreach ($menu as $key => $item) {
- 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 getChildMenu
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getChildMenu($roleId, $parent, int $source = 0)
{
$settingsModel = Settings_Menu_Module_Model::getInstance();
$menu = [];
$query = (new \App\Db\Query())->select(('yetiforce_menu.*, vtiger_tab.name'))
Function copyMenu
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function copyMenu($fromRole, $toRole, $roleId)
{
$db = \App\Db::getInstance();
$menuData = (new \App\Db\Query())->from('yetiforce_menu')
->where(['role' => $fromRole])
- 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 removeMenu
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function removeMenu($ids)
{
$db = \App\Db::getInstance();
if (!\is_array($ids)) {
$ids = [$ids];
- 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 save() has an NPath complexity of 260. The configured NPath complexity threshold is 200. Open
public function save()
{
$db = \App\Db::getInstance();
$settingsModel = Settings_Menu_Module_Model::getInstance();
$edit = $this->get('edit');
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method save() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10. Open
public function save()
{
$db = \App\Db::getInstance();
$settingsModel = Settings_Menu_Module_Model::getInstance();
$edit = $this->get('edit');
- 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
The method parseToDisplay() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10. Open
public static function parseToDisplay(array $menus): array
{
$userPrivilegesModel = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
$data = [];
foreach ($menus as $key => $item) {
- 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 34 to the 15 allowed. Open
public function save()
- 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 20 to the 15 allowed. Open
public static function parseToDisplay(array $menus): array
- 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
Avoid using undefined variables such as '$insertParams' which will lead to PHP notices. Open
$insertParams[$value] = $params[$key];
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$insertParams' which will lead to PHP notices. Open
$db->createCommand()->insert('yetiforce_menu', $insertParams)->execute();
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '398', column '20'). Open
$menuData = (new \App\Db\Query())->from('yetiforce_menu')
- 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 '145', column '24'). Open
$maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');
- 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 '192', column '18'). Open
$query = (new \App\Db\Query())->select(['id'])->from('yetiforce_menu')->where(['parentid' => $id]);
- 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 saveSequence has a boolean flag argument $generate, which is a certain sign of a Single Responsibility Principle violation. Open
public function saveSequence($data, $generate = false)
- 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 '76', column '17'). Open
$query = (new \App\Db\Query())->from('yetiforce_menu')->where(['id' => $id]);
- 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 '105', column '16'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);
- 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 '51', column '17'). Open
$query = (new \App\Db\Query())->select(['yetiforce_menu.*', 'vtiger_tab.name'])->from('yetiforce_menu')
- 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 '127', column '16'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);
- 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 '209', column '17'). Open
$query = (new \App\Db\Query())->select(('yetiforce_menu.*, vtiger_tab.name'))
- 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\Db' in method 'save'. 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 'Settings_Menu_Module_Model' in method 'getChildMenu'. Open
$settingsModel = Settings_Menu_Module_Model::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\Utils' in method 'generateFileMenu'. Open
\App\Utils::saveToFile($file, $content);
- 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 'Settings_Menu_Module_Model' in method 'save'. Open
$settingsModel = Settings_Menu_Module_Model::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 assigning values to variables in if clauses and the like (line '254', column '48'). Open
public static function parseToDisplay(array $menus): array
{
$userPrivilegesModel = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
$data = [];
foreach ($menus as $key => $item) {
- 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\Module' in method 'parseToDisplay'. Open
if (!\App\Module::isModuleActive($item['mod']) || (!$userPrivilegesModel->isAdminUser() && !$userPrivilegesModel->hasGlobalReadPermission() && !$userPrivilegesModel->hasModulePermission($item['tabid']))) {
- 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 '\Users_Privileges_Model' in method 'parseToDisplay'. Open
$userPrivilegesModel = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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 'Settings_Menu_Module_Model' in method 'getAll'. Open
$settingsModel = Settings_Menu_Module_Model::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 'Vtiger_Menu_Model' in method 'parseToDisplay'. Open
$item['name'] = Vtiger_Menu_Model::getLabelToDisplay($item);
- 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 save uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
foreach ($this->getData() as $key => $item) {
if (!\in_array($key, $editFields)) {
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);
}
- 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_Menu_Model' in method 'getAll'. Open
'text' => Vtiger_Menu_Model::getLabelToDisplay($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\CustomView' in method 'parseToDisplay'. Open
if ('CustomFilter' === $item['type'] && (!($cvId = vtlib\Functions::getQueryParams($item['dataurl'])['viewname'] ?? '') || !\App\CustomView::isPermitted($cvId, $item['mod']))) {
- 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 createContentMenu uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$content .= var_export($key, true) . '=>' . \App\Utils::varExport($item) . ',';
}
- 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\Db' in method 'saveSequence'. 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\Db' in method 'removeMenu'. 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\Utils' in method 'createContentMenu'. Open
$content .= var_export($key, true) . '=>' . \App\Utils::varExport($item) . ',';
- 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 '\vtlib\Functions' in method 'createFilterList'. Open
$params = \vtlib\Functions::getQueryParams($menu['dataurl']);
- 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 'copyMenu'. 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 'Settings_Roles_Record_Model' in method 'refreshMenuFiles'. Open
$allRoles = Settings_Roles_Record_Model::getAll();
- 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 'vtlib\Functions' in method 'parseToDisplay'. Open
}
- 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 'Settings_Roles_Record_Model' in method 'getRolesContainMenu'. Open
$allRoles = Settings_Roles_Record_Model::getAll();
- 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 "parentid" 14 times. Open
'parent' => 0 == $row['parentid'] ? '#' : $row['parentid'],
- 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 "yetiforce_menu" 11 times. Open
$query = (new \App\Db\Query())->select(['yetiforce_menu.*', 'vtiger_tab.name'])->from('yetiforce_menu')
- 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 "filters" 7 times. Open
if (!isset($data['filters'])) {
- 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 "childs" 9 times. Open
'childs' => $this->getChildMenu($roleId, $row['id'], $source),
- 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 "countentries" 4 times. Open
if (!isset($data['countentries'])) {
- 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 "sequence" 6 times. Open
$maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');
- 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" 4 times. Open
'tabid' => $row['module'],
- 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 "parent" 3 times. Open
'parent' => 0 == $row['parentid'] ? '#' : $row['parentid'],
- 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 "newwindow" 4 times. Open
if (!isset($data['newwindow'])) {
- 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 "CustomFilter" 3 times. Open
if (\in_array($item['type'], ['QuickCreate', 'Module', 'HomeIcon', 'CustomFilter', 'RecycleBin'])) {
- 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 "source" 5 times. Open
->leftJoin('vtiger_tab', 'vtiger_tab.tabid = yetiforce_menu.module')->where(['role' => $roleId, 'source' => $source])->orderBy('yetiforce_menu.sequence, yetiforce_menu.parentid');
- 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 "dataurl" 4 times. Open
'dataurl' => $settingsModel->getMenuUrl($row),
- 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 "label" 3 times. Open
'label' => $row['label'],
- 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 '$value'. Open
foreach ($allRoles as $roleId => $value) {
- 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
Saw unextractable annotation for comment '* @return <integer> Id'</integer>
Open
* @return <Integer> Id
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->update('yetiforce_menu', ['sequence' => $item['s'], 'parentid' => $item['p']], ['id' => $item['i']])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new \App\Db\Query())->select(['yetiforce_menu.*', 'vtiger_tab.name'])->from('yetiforce_menu')
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('yetiforce_menu', $insertParams)->execute();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('yetiforce_menu', ['id' => $id])->execute();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->update('yetiforce_menu', $params, ['id' => $this->getId()])->execute();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('yetiforce_menu', $menuItem)->execute();
- Exclude checks
Variable $insertParams
was undeclared, but array fields are being added to it. Open
$insertParams[$value] = $params[$key];
- Exclude checks
Suspicious array access to ?mixed
Open
$role = $item['r'];
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new \App\Db\Query())->select(('yetiforce_menu.*, vtiger_tab.name'))
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$menuData = (new \App\Db\Query())->from('yetiforce_menu')
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new \App\Db\Query())->select(['id'])->from('yetiforce_menu')->where(['parentid' => $id]);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query = (new \App\Db\Query())->from('yetiforce_menu')->where(['id' => $id]);
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model
- Exclude checks
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
public static function getInstanceById($id)
- 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
The class Settings_Menu_Record_Model is not named in CamelCase. Open
class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model
{
/**
* Menu for Roles.
*/
- 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 $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 $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
* @param int $source
- 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 \App\Db\Query())->from('yetiforce_menu')->where(['id' => $id]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->setData($row);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Menu for Roles.
- 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 getAll(int $roleId, int $source): 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
$settingsModel = Settings_Menu_Module_Model::getInstance();
- 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 const SRC_ROLE = 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
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getCleanInstance()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function 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
public function getId()
- 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
$menu = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row['type'] = (int) $row['type'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $instance;
- 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->get('name');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $roleId
- 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
$menu[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Menu for Api.
- 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
'parent' => 0 == $row['parentid'] ? '#' : $row['parentid'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'text' => Vtiger_Menu_Model::getLabelToDisplay($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
* @return <Integer> Id
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_tab', 'vtiger_tab.tabid = yetiforce_menu.module')->where(['role' => $roleId, 'source' => $source])->orderBy('yetiforce_menu.sequence, yetiforce_menu.parentid');
- Exclude checks
Line exceeds 120 characters; contains 191 characters Open
->leftJoin('vtiger_tab', 'vtiger_tab.tabid = yetiforce_menu.module')->where(['role' => $roleId, 'source' => $source])->orderBy('yetiforce_menu.sequence, yetiforce_menu.parentid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($edit) {
- 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
case 'role':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$maxSequence = (new \App\Db\Query())->from('yetiforce_menu')->where(['role' => $role, 'parentid' => 0])->max('sequence');
- 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
$db->createCommand()->delete('yetiforce_menu', ['id' => $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
if (!\in_array($key, $editFields)) {
- 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->generateFileMenu($role);
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'sequence' => $row['sequence'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'hotkey' => $row['hotkey'],
- 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 ($data as $key => $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($item)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->update('yetiforce_menu', $params, ['id' => $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
switch ($key) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$max = (int) $maxSequence;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sqlCol = explode(',', $sqlCol);
- 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->saveSequence($item['c'], 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
* Function removes menu items.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($childId = $dataReader->readColumn(0)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getChildMenu($roleId, $parent, int $source = 0)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->select(('yetiforce_menu.*, vtiger_tab.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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int[] $ids
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($id)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menu[] = $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 string Name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getName()
- 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
$instance = new self();
- 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 = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['newwindow'] = 0;
- 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
foreach ($this->getData() as $key => $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);
- 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::SRC_ROLE === $this->get('source')) {
- 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 ($ids as $id) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = self::getInstanceById($id);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->removeMenu($childId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'mod' => $row['name'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'parent' => $row['parentid'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'countentries' => $row['countentries'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Check permissions for display.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get Id of this record instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get Name of this record instance.
- 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
$item = implode(',', $item);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$role = $item['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
$db = \App\Db::getInstance();
- 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 removeMenu($ids)
- 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 (!\is_array($ids)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'id' => $row['id'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'tabid' => $row['module'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'childs' => $this->getChildMenu($roleId, $row['id'], $source),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->createCommand()->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
public static function parseToDisplay(array $menus): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($menus as $key => $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\App\Module::isModuleActive($item['mod']) || (!$userPrivilegesModel->isAdminUser() && !$userPrivilegesModel->hasGlobalReadPermission() && !$userPrivilegesModel->hasModulePermission($item['tabid']))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- 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 $this->get('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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$settingsModel = Settings_Menu_Module_Model::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->setData($data);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->select(['yetiforce_menu.*', 'vtiger_tab.name'])->from('yetiforce_menu')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($data['filters'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'id' => $row['id'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['filters'] = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getInstanceById($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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Returns all items for menus.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$item = $settingsModel->getMenuTypeKey($item);
- 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 (false === $row) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params[] = $item;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->update('yetiforce_menu', ['sequence' => $item['s'], 'parentid' => $item['p']], ['id' => $item['i']])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$editFields = $settingsModel->getEditFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (self::SRC_ROLE === $recordModel->get('source')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($generate) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$item = implode(',', $item);
- 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
$settingsModel = Settings_Menu_Module_Model::getInstance();
- 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 ('id' != $key && 'edit' != $key) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('yetiforce_menu')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'type' => $settingsModel->getMenuTypes($row['type']),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function saveSequence($data, $generate = 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
$query = (new \App\Db\Query())->select(['id'])->from('yetiforce_menu')->where(['parentid' => $id]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => $row['label'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userPrivilegesModel = \Users_Privileges_Model::getCurrentUserPrivilegesModel();
- 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 const SRC_API = 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
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
$row = $query->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sqlCol = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE||' . $key, 406);
- 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->generateFileMenu($this->get('role'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($data as $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->orderBy(' yetiforce_menu.sequence', 'yetiforce_menu.parentid');
- 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
'icon' => 'menu-icon-' . $settingsModel->getMenuTypes($row['type']),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function initialize($data)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$role = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($data['countentries'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sqlCol .= $key . ',';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sqlCol .= 'sequence';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($sqlCol as $key => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menu = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Line exceeds 120 characters; contains 221 characters Open
if (!\App\Module::isModuleActive($item['mod']) || (!$userPrivilegesModel->isAdminUser() && !$userPrivilegesModel->hasGlobalReadPermission() && !$userPrivilegesModel->hasModulePermission($item['tabid']))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$edit = $this->get('edit');
- 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($data['newwindow'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($key, $editFields)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($item)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params[] = $max + 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
$db = \App\Db::getInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['role' => $roleId, 'parentid' => $parent, 'source' => $source])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'newwindow' => $row['newwindow'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'filters' => $row['filters'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $menu;
- 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[$key] = $item;
- 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('yetiforce_menu', $insertParams)->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$role = 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
'dataurl' => $settingsModel->getMenuUrl($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
if (\in_array($item['type'], ['QuickCreate', 'Module', 'HomeIcon', 'CustomFilter', 'RecycleBin'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $this->getData();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params['countentries'] = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 'type':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
$db->createCommand()->update('yetiforce_menu', ['sequence' => $item['s'], 'parentid' => $item['p']], ['id' => $item['i']])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->leftJoin('vtiger_tab', 'vtiger_tab.tabid = yetiforce_menu.module')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'icon' => $row['icon'],
- 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
$data = [];
- 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
$dataReader = $query->createCommand()->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
return $menu;
- 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
$role = $item = filter_var($item, FILTER_SANITIZE_NUMBER_INT);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$insertParams[$value] = $params[$key];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($item['c'])) {
- 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
$ids = [$ids];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->generateFileMenu($recordModel->get('role'));
- 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 array $menus
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= '];' . PHP_EOL . '$filterList = [';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($menu as $key => $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menu[$counter]['roleName'] = $allRoles[$roleId]->get('rolename');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $roleId
- Exclude checks
Line exceeds 120 characters; contains 193 characters Open
if ('CustomFilter' === $item['type'] && (!($cvId = vtlib\Functions::getQueryParams($item['dataurl'])['viewname'] ?? '') || !\App\CustomView::isPermitted($cvId, $item['mod']))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$item['childs'] = self::parseToDisplay($item['childs']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data[$key] = $item;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function generateFileMenu($roleId)
- 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
$menu[$counter]['roleId'] = $roleId;
- 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
$related = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($item['childs']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($menu as $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= '];' . PHP_EOL . '$parentList = [';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$childs = var_export($key, true) . '=>[';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= trim($childs, ',');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function createParentList($menu)
- 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 (\count($menu['childs']) > 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
return $content;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* A function used to refresh menu files.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$counter = 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
$menu = $this->getChildMenu($roleId, 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($menu as $item) {
- 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 ($menuData) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menuItem['parentid'] = $related[$menuItem['parentid']] ?? $menuItem['parentid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$related[$menuId] = $db->getLastInsertID('yetiforce_menu_id_seq');
- 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->generateFileMenu($toRole);
- 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 ('CustomFilter' === $item['type'] && (!($cvId = vtlib\Functions::getQueryParams($item['dataurl'])['viewname'] ?? '') || !\App\CustomView::isPermitted($cvId, $item['mod']))) {
- 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
$roleId = filter_var($roleId, FILTER_SANITIZE_NUMBER_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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= "'parent'=>" . var_export($menu['parent'], true) . ',';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($menu['childs'] as $child) {
- 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->generateFileMenu($roleId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menu = [];
- 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
->where(['role' => $fromRole])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menuId = key($diff);
- 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
$item['name'] = Vtiger_Menu_Model::getLabelToDisplay($item);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function createContentMenu($menu)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('childs' == $key && $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$childs .= $this->createContentMenu($child);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$hasMenu = $this->getAll(filter_var($roleId, FILTER_SANITIZE_NUMBER_INT), static::SRC_ROLE);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $fromRole - Copy from role
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($related[$menuId])) {
- 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
$content .= $this->createContentMenu($item);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($allRoles as $role) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getIcons()
- 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
continue;
- 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($menu['filters'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params = \vtlib\Functions::getQueryParams($menu['dataurl']);
- 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 ($hasMenu) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function copyMenu($fromRole, $toRole, $roleId)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($menuData as $menuId => $menuItem) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menuItem['source'] = ($roleId && false === strpos($roleId, 'H')) ? self::SRC_API : self::SRC_ROLE;
- 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 ($item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($item as $child) {
- 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
$content .= "'dataurl'=>" . var_export($menu['dataurl'], 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
$content .= "'module'=>" . var_export($menu['mod'], true) . ',';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (file_exists('user_privileges/menu_' . $roleId . '.php')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- 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 getRolesContainMenu()
- 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
++$counter;
- 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 $toRole - Copy to role
- 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 ($allRoles as $roleId => $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
$menuItem['role'] = $toRole;
- 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
\App\Utils::saveToFile($file, $content);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return trim($content, ',') . '],';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= "'label'=>" . var_export($menu['label'], true) . ',';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('CustomFilter' === $menu['type']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function refreshMenuFiles()
- 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
$menuData = (new \App\Db\Query())->from('yetiforce_menu')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$diff = array_diff_key($menuData, $related);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert('yetiforce_menu', $menuItem)->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('QuickCreate' === $item['type'] && (!Vtiger_Module_Model::getInstance($item['tabid'])->isQuickCreateSupported() || !$userPrivilegesModel->hasModuleActionPermission($item['tabid'], 'CreateView'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $data;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content = '$menus = [';
- 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
$content = $menu['id'] . '=>[';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($menu['childs'] as $child) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= "'module'=>" . var_export($menu['mod'], true) . ',';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleId = str_replace('H', '', $role->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return ['yfm-VirtualDesk', 'fas fa-home', 'yfm-CompaniesAndContact', 'yfm-Campaigns', 'yfm-Support', 'yfm-Project', 'yfm-Bookkeeping', 'yfm-HumanResources', 'yfm-Secretary', 'yfm-Database', 'yfm-Sales', 'yfm-VendorsAccounts'];
- 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 $menu;
- Exclude checks
Line exceeds 120 characters; contains 217 characters Open
if ('QuickCreate' === $item['type'] && (!Vtiger_Module_Model::getInstance($item['tabid'])->isQuickCreateSupported() || !$userPrivilegesModel->hasModuleActionPermission($item['tabid'], 'CreateView'))) {
- 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
$content .= var_export($key, true) . '=>' . \App\Utils::varExport($item) . ',';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= '],';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= $this->createParentList($child);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $content;
- 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
$content = $menu['id'] . '=>[';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= "'filters'=>" . $params['viewname'] . '],';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= $this->createFilterList($child);
- 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
$allRoles = Settings_Roles_Record_Model::getAll();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function adds records to task queue that updates reviewing changes in records.
- 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
$content .= $this->createFilterList($item);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= '];' . PHP_EOL;
- 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
$childs .= '],';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= "'type'=>" . var_export($menu['type'], true) . ',';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menuItem = current($diff);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menuId = $menuItem['parentid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$menuItem = $menuData[$menuId];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$file = ROOT_DIRECTORY . '/user_privileges/menu_' . $roleId . '.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content = $menu['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
public function createFilterList($menu)
- 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
$content .= $this->createParentList($item);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($menu as $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unset($menu['filters']);
- 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
$content .= "'mod'=>" . var_export($menu['mod'], true) . ',';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\count($menu['childs']) > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content = $menu['id'] . '=>[';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$content .= "'filters'=>" . var_export($menu['filters'], 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
$allRoles = Settings_Roles_Record_Model::getAll();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->generateFileMenu(0);
- Exclude checks
Line exceeds 120 characters; contains 234 characters Open
return ['yfm-VirtualDesk', 'fas fa-home', 'yfm-CompaniesAndContact', 'yfm-Campaigns', 'yfm-Support', 'yfm-Project', 'yfm-Bookkeeping', 'yfm-HumanResources', 'yfm-Secretary', 'yfm-Database', 'yfm-Sales', 'yfm-VendorsAccounts'];
- 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
->orderBy(['parentid' => SORT_ASC, 'sequence' => SORT_ASC])->createCommand()->queryAllByGroup(1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($menuItem['parentid'] && !isset($related[$menuItem['parentid']])) {
- Exclude checks
Class name "Settings_Menu_Record_Model" is not in camel caps format Open
class Settings_Menu_Record_Model extends Settings_Vtiger_Record_Model
- Exclude checks