Function getPermittedModuleIdList
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public static function getPermittedModuleIdList()
{
$permittedModules = [];
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
include 'user_privileges/tabdata.php';
- 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 getCurrentUserEntityFieldNameDisplay
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function getCurrentUserEntityFieldNameDisplay($module, $fieldsName, $fieldValues)
{
if (false === strpos($fieldsName, ',')) {
return $fieldValues[$fieldsName];
}
- 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 getPermittedModuleIdList() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public static function getPermittedModuleIdList()
{
$permittedModules = [];
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
include 'user_privileges/tabdata.php';
- 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
Avoid using undefined variables such as '$formattedNameList' which will lead to PHP notices. Open
$formattedNameListString = implode(",'" . $glue . "',", $formattedNameList);
- 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 '$profileTabsPermission' which will lead to PHP notices. Open
if (0 === $seq_value && isset($profileTabsPermission[$tabid]) && 0 === $profileTabsPermission[$tabid]) {
- 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 '$formattedNameList' which will lead to PHP notices. Open
$formattedNameList[] = $input[$value];
- 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 '$is_admin' which will lead to PHP notices. Open
if (false === $is_admin && 1 == $profileGlobalPermission[1]
- 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 '$profileGlobalPermission' which will lead to PHP notices. Open
if (false === $is_admin && 1 == $profileGlobalPermission[1]
- 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 '$profileTabsPermission' which will lead to PHP notices. Open
if (0 === $seq_value && isset($profileTabsPermission[$tabid]) && 0 === $profileTabsPermission[$tabid]) {
- 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 '$profileGlobalPermission' which will lead to PHP notices. Open
&& 1 == $profileGlobalPermission[2]) {
- 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 '98', column '14'). Open
throw new \App\Exceptions\AppException('Sorry! Attempt to access restricted file.');
- 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 '75', column '14'). Open
throw new \App\Exceptions\AppException('Sorry! Attempt to access restricted file.');
- 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 '147', column '22'). Open
$dataReader = (new \App\Db\Query())->select(['blockid'])
- 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 '107', column '14'). Open
throw new \App\Exceptions\AppException('Sorry! Attempt to access restricted file.');
- 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\Field' in method 'getCurrentUserEntityFieldNameDisplay'. Open
if ('Users' === $module || \App\Field::getColumnPermission($module, $field)) {
- 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 'getSqlForNameInDisplayFormat'. Open
$entityFieldInfo = \App\Module::getEntityInfo($module);
- 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\Log' in method 'checkFileAccess'. Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($filepath, true));
- 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\Field' in method 'getColumnFields'. Open
foreach (\App\Field::getModuleFieldInfosByPresence($module) as $fieldInfo) {
- 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\Log' in method 'checkFileAccessForDeletion'. Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true));
- 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\Log' in method 'checkFileAccessForInclusion'. Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true));
- 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 getSqlForNameInDisplayFormat uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$formattedNameListString = $input[$fieldsName];
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getPermittedModuleIdList uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
foreach ($tab_seq_array as $tabid => $seq_value) {
if (0 === $seq_value) {
$permittedModules[] = ($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\Log' in method 'getColumnFields'. Open
\App\Log::trace('Entering getColumnFields(' . $module . ') method ...');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\User' in method 'getPermittedModuleIdList'. Open
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
- 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 'getFullNameFromArray'. Open
$entityInfo = \App\Module::getEntityInfo($module);
- 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\Log' in method 'getColumnFields'. Open
\App\Log::trace('Exiting getColumnFields method ...');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Module' in method 'getPermittedModuleIdList'. Open
$homeTabid = \App\Module::getModuleId('Home');
- 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 ") - Sorry! Attempt to access restricted file. realfilepath: " 3 times. Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true));
- 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 "Sorry! Attempt to access restricted file." 3 times. Open
throw new \App\Exceptions\AppException('Sorry! Attempt to access restricted file.');
- 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 '$is_admin'. Open
if (false === $is_admin && 1 == $profileGlobalPermission[1]
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Call to method error
from undeclared class \App\Log
Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($filepath, true));
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true));
- Exclude checks
Variable $formattedNameList
was undeclared, but array fields are being added to it. Open
$formattedNameList[] = $input[$value];
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Entering getColumnFields(' . $module . ') method ...');
- Exclude checks
Variable $tab_seq_array
is undeclared Open
foreach ($tab_seq_array as $tabid => $seq_value) {
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Exiting getColumnFields method ...');
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
- Exclude checks
Variable $profileGlobalPermission
is undeclared Open
if (false === $is_admin && 1 == $profileGlobalPermission[1]
- Exclude checks
Variable $tab_seq_array
is undeclared Open
foreach ($tab_seq_array as $tabid => $seq_value) {
- Exclude checks
Variable $profileGlobalPermission
is undeclared Open
&& 1 == $profileGlobalPermission[2]) {
- Exclude checks
Variable $is_admin
is undeclared Open
if (false === $is_admin && 1 == $profileGlobalPermission[1]
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true));
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$dataReader = (new \App\Db\Query())->select(['blockid'])
- Exclude checks
Avoid excessively long variable names like $profileTabsPermission. Keep variable name length under 20. Open
if (0 === $seq_value && isset($profileTabsPermission[$tabid]) && 0 === $profileTabsPermission[$tabid]) {
- 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 excessively long variable names like $formattedNameListString. Keep variable name length under 20. Open
$formattedNameListString = implode(",'" . $glue . "',", $formattedNameList);
- 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 excessively long variable names like $profileGlobalPermission. Keep variable name length under 20. Open
if (false === $is_admin && 1 == $profileGlobalPermission[1]
- 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
Spaces must be used to indent lines; tabs are not allowed Open
public static function getFullNameFromArray($module, $fieldValues)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param3 $fieldValues - array of fieldname and its 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
$entityInfo = \App\Module::getEntityInfo($module);
- Exclude checks
Spaces must 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 function returns the entity field name for a given module; for e.g. for Contacts module it return concat(lastname, ' ', firstname).
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string $fieldConcatName - the entity field name for the module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false === strpos($fieldsName, ',')) {
- Exclude checks
Spaces must 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 getCurrentUserEntityFieldNameDisplay($module, $fieldsName, $fieldValues)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsName = $entityInfo['fieldname'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $fieldsName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldValues[$fieldsName];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* and it exists.
- Exclude checks
Spaces must 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
->where(['label' => $label])
- Exclude checks
Spaces must 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
$accessibleFieldNames[] = $fieldValues[$field];
- Exclude checks
Spaces must 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 checkFileAccessForDeletion($filepath)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Sorry! Attempt to access restricted file.');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* This function is used to get the blockid of the settings block for a given label.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSettingsBlockId($label)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$formattedNameListString = implode(",'" . $glue . "',", $formattedNameList);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $module
- Exclude checks
Spaces must 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 getPermittedModuleIdList()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permittedModules[] = ($tabid);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param1 $module - name of the module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $fieldValues
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$realfilepath = str_replace('\\\\', '\\', $realfilepath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Function to check the file access is made within web root directory. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool true if file is a valid file within vtiger root directory, false otherwise
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 === $dataReader->count()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === $seq_value && isset($profileTabsPermission[$tabid]) && 0 === $profileTabsPermission[$tabid]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::getCurrentUserEntityFieldNameDisplay($module, $fieldsName, $fieldValues);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Function to check the file deletion within the deletable (safe) directories */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Replace all \\ with \ first */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!self::isFileAccessible($filepath)) {
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($filepath, true));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Replace all \\ with \ first */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockId = 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
include 'user_privileges/tabdata.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param2 $fieldsName - fieldname with respect to module (ex : 'Accounts' - 'accountname', 'Contacts' - 'lastname','firstname')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$realfilepath = realpath($filepath);
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$safeDirectories = ['storage', 'cache', 'test'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rootdirpath = str_replace('\\\\', '\\', ROOT_DIRECTORY . \DIRECTORY_SEPARATOR);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int
- 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
$accessibleFieldNames = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function checkFileAccess($filepath)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($filepath, 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
foreach ($fieldsName as &$value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'CONCAT(' . $formattedNameListString . ')';
- Exclude checks
Spaces must 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 getColumnFields($module)
- Exclude checks
Spaces must 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 $columnFields;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the permitted module id Array with presence as 0.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array Array of accessible tabids
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
* this function returns the entity field name for a given module; for e.g. for Contacts module it return concat(lastname, ' ', firstname).
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
* @param2 $fieldsName - fieldname with respect to module (ex : 'Accounts' - 'accountname', 'Contacts' - 'lastname','firstname')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rootdirpath = str_replace('\\\\', '\\', ROOT_DIRECTORY . \DIRECTORY_SEPARATOR);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rootdirpath = str_replace('\\\\', '\\', ROOT_DIRECTORY . \DIRECTORY_SEPARATOR);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Replace all \ with / now */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsName = $entityFieldInfo['fieldnameArr'];
- Exclude checks
Spaces must 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 (explode(',', $fieldsName) as $field) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Replace all \ with / now */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relativeFilePath = str_replace($rootdirpath, '', $realfilepath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$realfilepath = realpath($filepath);
- Exclude checks
Line exceeds 120 characters; contains 154 characters Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, 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
$realfilepath = realpath($filepath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$formattedNameListString = $input[$fieldsName];
- Exclude checks
Line exceeds 120 characters; contains 124 characters Open
/** Function to check the file access is made within web root directory and whether it is not from unsafe directories */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$filePathParts = explode('/', $relativeFilePath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Sorry! Attempt to access restricted file.');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* function to return whether the file access is made within vtiger root directory
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columnFields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function checkFileAccessForInclusion($filepath)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$realfilepath = str_replace('\\\\', '\\', $realfilepath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rootdirpath = str_replace('\\', '/', $rootdirpath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('Entering getColumnFields(' . $module . ') method ...');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Users' === $module || \App\Field::getColumnPermission($module, $field)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Function to check the file access is made within web root directory and whether it is not from unsafe directories */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Replace all \\ with \ first */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 !== stripos($realfilepath, $rootdirpath) || \in_array($filePathParts[0], $unsafeDirectories)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\AppException('Sorry! Attempt to access restricted file.');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$realfilepath = str_replace('\\', '/', $realfilepath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function isFileAccessible($filepath)
- Exclude checks
Spaces must 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 string $label
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new \App\Db\Query())->select(['blockid'])
- 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
return $blockId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getSqlForNameInDisplayFormat($input, $module, $glue = ' ')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('Exiting getColumnFields method ...');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($tab_seq_array as $tabid => $seq_value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$unsafeDirectories = ['storage', 'cache', 'test'];
- Exclude checks
Spaces must 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 (0 !== stripos($realfilepath, $rootdirpath)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_settings_blocks')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockId = $dataReader->readColumn(0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($fieldsName)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$formattedNameList[] = $input[$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
/**
- Exclude checks
Spaces must 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
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rootdirpath = str_replace('\\', '/', $rootdirpath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$realfilepath = str_replace('\\', '/', $realfilepath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Gets fields for module.
- Exclude checks
Spaces must 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($accessibleFieldNames) > 0) {
- 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
$rootdirpath = str_replace('\\', '/', $rootdirpath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 !== stripos($realfilepath, $rootdirpath) || !\in_array($filePathParts[0], $safeDirectories)) {
- Exclude checks
Spaces must 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 $filepath relative path to the file which need to be verified
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->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
$entityFieldInfo = \App\Module::getEntityInfo($module);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permittedModules = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false === $is_admin && 1 == $profileGlobalPermission[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
return implode(' ', $accessibleFieldNames);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$realfilepath = str_replace('\\', '/', $realfilepath);
- Exclude checks
Spaces must 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
* @global Users $current_user
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
&& 1 == $profileGlobalPermission[2]) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permittedModules[] = ($tabid);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$homeTabid = \App\Module::getModuleId('Home');
- Exclude checks
Spaces must 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
$filePathParts = explode('/', $relativeFilePath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error(__METHOD__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** Replace all \ with / now */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relativeFilePath = str_replace($rootdirpath, '', $realfilepath);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$realfilepath = str_replace('\\\\', '\\', $realfilepath);
- 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
foreach (\App\Field::getModuleFieldInfosByPresence($module) as $fieldInfo) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columnFields[$fieldInfo['fieldname']] = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permittedModules[] = $homeTabid;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($homeTabid, $permittedModules)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === $seq_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
foreach ($tab_seq_array as $tabid => $seq_value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $permittedModules;
- Exclude checks
The variable $seq_value is not named in camelCase. Open
public static function getPermittedModuleIdList()
{
$permittedModules = [];
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
include 'user_privileges/tabdata.php';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $is_admin is not named in camelCase. Open
public static function getPermittedModuleIdList()
{
$permittedModules = [];
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
include 'user_privileges/tabdata.php';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $seq_value is not named in camelCase. Open
public static function getPermittedModuleIdList()
{
$permittedModules = [];
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
include 'user_privileges/tabdata.php';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $seq_value is not named in camelCase. Open
public static function getPermittedModuleIdList()
{
$permittedModules = [];
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
include 'user_privileges/tabdata.php';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tab_seq_array is not named in camelCase. Open
public static function getPermittedModuleIdList()
{
$permittedModules = [];
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
include 'user_privileges/tabdata.php';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tab_seq_array is not named in camelCase. Open
public static function getPermittedModuleIdList()
{
$permittedModules = [];
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
include 'user_privileges/tabdata.php';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $seq_value is not named in camelCase. Open
public static function getPermittedModuleIdList()
{
$permittedModules = [];
require 'user_privileges/user_privileges_' . \App\User::getCurrentUserId() . '.php';
include 'user_privileges/tabdata.php';
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}