File Record.php
has 395 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/* +***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
Method save
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save()
{
$db = App\Db::getInstance();
$roleId = $this->getId();
$mode = 'edit';
The class Settings_Roles_Record_Model has an overall complexity of 75 which is very high. The configured complexity threshold is 50. Open
class Settings_Roles_Record_Model extends Settings_Vtiger_Record_Model
{
/**
* Function to get the Id.
*
- Exclude checks
Settings_Roles_Record_Model
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class Settings_Roles_Record_Model extends Settings_Vtiger_Record_Model
{
/**
* Function to get the Id.
*
Function save
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function save()
{
$db = App\Db::getInstance();
$roleId = $this->getId();
$mode = '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
Method delete
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function delete($transferToRole)
{
$db = App\Db::getInstance();
$roleId = $this->getId();
$transferRoleId = $transferToRole->getId();
Consider simplifying this complex logical expression. Open
if ($rolePreviousData['listrelatedrecord'] != $this->get('listrelatedrecord')
|| $rolePreviousData['previewrelatedrecord'] != $this->get('previewrelatedrecord')
|| $rolePreviousData['editrelatedrecord'] != $this->get('editrelatedrecord')
|| $rolePreviousData['permissionsrelatedfield'] != $permissionsRelatedField
|| $rolePreviousData['searchunpriv'] != $searchunpriv
Function getSameLevelRoles
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getSameLevelRoles()
{
if (!isset($this->children)) {
$parentRoles = \App\PrivilegeUtil::getParentRole($this->getId());
$currentRoleDepth = $this->getDepth();
- 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 18432. The configured NPath complexity threshold is 200. Open
public function save()
{
$db = App\Db::getInstance();
$roleId = $this->getId();
$mode = '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 22. The configured cyclomatic complexity threshold is 10. Open
public function save()
{
$db = App\Db::getInstance();
$roleId = $this->getId();
$mode = '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
Class "Settings_Roles_Record_Model" has 27 methods, which is greater than 20 authorized. Split it into smaller classes. Open
class Settings_Roles_Record_Model extends Settings_Vtiger_Record_Model
- Read upRead up
- Exclude checks
A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.
Refactor this function to reduce its Cognitive Complexity from 23 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
Missing class import via use statement (line '346', column '25'). Open
$insertedData = (new App\Db\Query())
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '469', column '17'). Open
$query = (new App\Db\Query())->from('vtiger_role');
- 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 '155', column '22'). Open
$dataReader = (new App\Db\Query())->from('vtiger_role')
- 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 '176', column '15'). Open
return (new App\Db\Query())->select(['profileid'])->from('vtiger_role2profile')->where(['roleid' => $this->getId()])->column();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '552', column '15'). Open
return (new App\Db\Query())->select(['userid'])
- 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 '580', column '15'). Open
return (new App\Db\Query())->select(['multicompanyid', 'company_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
Missing class import via use statement (line '102', column '23'). Open
$dataReader = (new \App\Db\Query())->from('vtiger_role')
- 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 '531', column '17'). Open
$query = (new App\Db\Query())->from('vtiger_role')->where(['rolename' => $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
Missing class import via use statement (line '347', column '19'). Open
->select([new \yii\db\Expression($db->quoteValue($roleId)), 'picklistvalueid', 'picklistid', 'sortid'])
- 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 '513', column '15'). Open
$row = (new App\Db\Query())->from('vtiger_role')->where(['depth' => 0])->one();
- 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 getAll has a boolean flag argument $baseRole, which is a certain sign of a Single Responsibility Principle violation. Open
public static function getAll($baseRole = 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 '131', column '23'). Open
$dataReader = (new \App\Db\Query())->from('vtiger_role')
- 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 '190', column '15'). Open
$row = (new App\Db\Query())->select(['directly_related_to_role', 'vtiger_profile.profileid'])
- 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\Privilege' in method 'save'. Open
\App\Privilege::setAllUpdater();
- 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\Privilege' in method 'delete'. Open
\App\Privilege::setAllUpdater();
- 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 getParent uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$this->parent = null;
}
- 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 'Settings_Profiles_Record_Model' in method 'getProfiles'. Open
$this->profiles = Settings_Profiles_Record_Model::getAllByRole($this->getId());
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'save'. Open
\App\Cache::delete('getCompanyRoles', '');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'save'. Open
\App\Cache::delete('getUsersByCompany', $rolePreviousData['company']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'save'. Open
\App\Cache::delete('RoleDetail', $roleId);
- 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 {
$values['roleid'] = $roleId;
$db->createCommand()->insert('vtiger_role', $values)->execute();
$insertedData = (new App\Db\Query())
->select([new \yii\db\Expression($db->quoteValue($roleId)), 'picklistvalueid', 'picklistid', 'sortid'])
- 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\Cache' in method 'save'. Open
\App\Cache::delete('getUsersByCompany', '');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'save'. Open
\App\Cache::delete('getUsersByCompany', $this->get('company'));
- 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\UserPrivilegesFile' in method 'delete'. Open
\App\UserPrivilegesFile::createUserPrivilegesfile($userid);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'save'. Open
\App\Cache::delete(__CLASS__, $roleId);
- 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\PrivilegeUtil' in method 'delete'. Open
\App\PrivilegeUtil::deleteRelatedSharingRules($roleId, 'Roles');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'getInstanceById'. Open
return \App\Cache::staticGet(__CLASS__, $roleId);
- 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 getSameLevelRoles uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$parentRoleString = $parentRoleString . '::' . $role;
}
- 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 '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 'Vtiger_Link_Model' in method 'getRecordLinks'. Open
$links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink);
- 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\PrivilegeUtil' in method 'save'. Open
$rolePreviousData = App\PrivilegeUtil::getRoleDetail($roleId);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'getInstanceById'. Open
if (!\App\Cache::staticHas(__CLASS__, $roleId)) {
- 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\UserPrivilegesFile' in method 'delete'. Open
\App\UserPrivilegesFile::createUserSharingPrivilegesfile($userid);
- 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\PrivilegeUtil' in method 'getInstanceById'. Open
$row = \App\PrivilegeUtil::getRoleDetail($roleId);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Cache' in method 'getInstanceById'. Open
\App\Cache::staticSave(__CLASS__, $roleId, $instance);
- 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\PrivilegeUtil' in method 'getSameLevelRoles'. Open
$parentRoles = \App\PrivilegeUtil::getParentRole($this->getId());
- 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_Record_Model' in method 'getUsers'. Open
$usersList[$userId] = Users_Record_Model::getInstanceById($userId, 'Users');
- 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 'delete'. 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
Define a constant instead of duplicating this literal "previewrelatedrecord" 4 times. Open
'previewrelatedrecord' => $this->get('previewrelatedrecord'),
- 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 "roleid" 16 times. Open
return $this->get('roleid');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "vtiger_role" 10 times. Open
$dataReader = (new \App\Db\Query())->from('vtiger_role')
- 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 "allowassignedrecordsto" 6 times. Open
$this->set('allowassignedrecordsto', $this->get('allowassignedrecordsto'));
- 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 "rolename" 3 times. Open
return $this->get('rolename');
- 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 "profileid" 3 times. Open
return (new App\Db\Query())->select(['profileid'])->from('vtiger_role2profile')->where(['roleid' => $this->getId()])->column();
- 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 "parentrole" 10 times. Open
return $this->get('parentrole');
- 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 "company" 6 times. Open
'company' => (int) $this->get('company'),
- 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 "listrelatedrecord" 4 times. Open
'listrelatedrecord' => $this->get('listrelatedrecord'),
- 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 "depth" 10 times. Open
return $this->get('depth');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "vtiger_role2profile" 5 times. Open
return (new App\Db\Query())->select(['profileid'])->from('vtiger_role2profile')->where(['roleid' => $this->getId()])->column();
- 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 "getUsersByCompany" 3 times. Open
\App\Cache::delete('getUsersByCompany', '');
- 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 "permissionsrelatedfield" 3 times. Open
$permissionsRelatedField = $this->get('permissionsrelatedfield');
- 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 "searchunpriv" 3 times. Open
$searchunpriv = $this->get('searchunpriv');
- 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 "editrelatedrecord" 4 times. Open
'editrelatedrecord' => (int) $this->get('editrelatedrecord'),
- 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.
Saw unextractable annotation for comment '* @return <array> - List of Settings_Roles_Record_Model instances'</array>
Open
* @return <Array> - List of Settings_Roles_Record_Model instances
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_role', ['roleid' => $roleId])->execute();
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::staticSave()
takes string
defined at /code/app/Cache.php:156
Open
\App\Cache::staticSave(__CLASS__, $roleId, $instance);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new App\Db\Query())->select(['multicompanyid', 'company_name'])
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->parent
Open
return $this->parent;
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->profiles
Open
if (!isset($this->profiles)) {
- Exclude checks
Call to method __construct
from undeclared class \yii\db\Expression
Open
->select([new \yii\db\Expression($db->quoteValue($roleId)), 'picklistvalueid', 'picklistid', 'sortid'])
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_role2profile', ['roleid' => $roleId])->execute();
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::staticHas()
takes string
defined at /code/app/Cache.php:141
Open
if (!\App\Cache::staticHas(__CLASS__, $roleId)) {
- Exclude checks
Returning type null
but getBaseRole()
is declared to return \Settings_Roles_Record_Model
Open
return null;
- Exclude checks
Parameter $name
has undeclared type \type
Open
public static function getInstanceByName($name, $excludedRecordId = [])
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->parent
Open
$this->parent = $parentRole;
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->update('vtiger_user2role', ['roleid' => $transferRoleId], ['roleid' => $roleId])->execute();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$row = (new App\Db\Query())->select(['directly_related_to_role', 'vtiger_profile.profileid'])
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('vtiger_role', $values)->execute();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_group2role', ['roleid' => $roleId])->execute();
- Exclude checks
Saw a token Phan may have failed to parse after '* @return null/role instance':
after null,
saw '/'
Open
* @return null/role instance
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->insert('vtiger_role2profile', ['roleid' => $roleId, 'profileid' => $profileIds[$i]])
- Exclude checks
Saw unextractable annotation for comment '* @return <number> Role Id'</number>
Open
* @return <Number> Role Id
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->children
Open
return $this->children;
- Exclude checks
Returning type false
but getDirectlyRelatedProfileId()
is declared to return \id
Open
return false;
- Exclude checks
Saw unextractable annotation for comment '* @return <array> Settings_Profiles_Record_Model instances'</array>
Open
* @return <Array> Settings_Profiles_Record_Model instances
- Exclude checks
Saw unextractable annotation for comment '* @param <settings_roles_record_model> $transferToRole'</settings_roles_record_model>
Open
* @param <Settings_Roles_Record_Model> $transferToRole
- Exclude checks
Argument 1 (roleId)
is string
but \Settings_Roles_Record_Model::getInstanceById()
takes int
defined at /code/modules/Settings/Roles/models/Record.php:493
Open
$this->parent = self::getInstanceById($parentComponents[$noOfRoles - 2]);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_role2profile', ['roleid' => $roleId])->execute();
- Exclude checks
Argument 2 (key)
is int
but \App\Cache::staticGet()
takes string
defined at /code/app/Cache.php:128
Open
return \App\Cache::staticGet(__CLASS__, $roleId);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new App\Db\Query())->from('vtiger_role')->where(['depth' => 0])->one();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new \App\Db\Query())->from('vtiger_role')
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->children
Open
$this->children = $roles;
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->children
Open
return $this->children;
- Exclude checks
Returning type false
but getDirectlyRelatedProfileId()
is declared to return \id
Open
return false;
- Exclude checks
Call to undeclared method \App\Db::quoteValue
Open
->select([new \yii\db\Expression($db->quoteValue($roleId)), 'picklistvalueid', 'picklistid', 'sortid'])
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->batchInsert('vtiger_role2picklist', ['roleid', 'picklistvalueid', 'picklistid', 'sortid'], $insertedData)->execute();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->delete('vtiger_group2rs', ['roleandsubid' => $roleId])->execute();
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->parent
Open
if (!isset($this->parent)) {
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->parent
Open
$this->parent = self::getInstanceById($parentComponents[$noOfRoles - 2]);
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->children
Open
if (!isset($this->children)) {
- Exclude checks
Argument 1 (roleId)
is int
but \Settings_Profiles_Record_Model::getAllByRole()
takes string
defined at /code/modules/Settings/Profiles/models/Record.php:836
Open
$this->profiles = Settings_Profiles_Record_Model::getAllByRole($this->getId());
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->profiles
Open
$this->profiles = Settings_Profiles_Record_Model::getAllByRole($this->getId());
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query = (new App\Db\Query())->from('vtiger_role');
- Exclude checks
Saw unextractable annotation for comment '* @return <array> list of Role models <settings_roles_record_model>'</settings_roles_record_model></array>
Open
* @return <Array> list of Role models <Settings_Roles_Record_Model>
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->children
Open
if (!isset($this->children)) {
- Exclude checks
Saw unextractable annotation for comment '* @param <settings_roles_record_model> $newParentRole'</settings_roles_record_model>
Open
* @param <Settings_Roles_Record_Model> $newParentRole
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$query = (new App\Db\Query())->from('vtiger_role')->where(['rolename' => $name]);
- Exclude checks
Saw unextractable annotation for comment '* @param <settings_roles_record_model> $role'</settings_roles_record_model>
Open
* @param <Settings_Roles_Record_Model> $role
- Exclude checks
Return type of getDirectlyRelatedProfileId()
is undeclared type \id
Open
public function getDirectlyRelatedProfileId()
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$db->createCommand()->update('vtiger_role', $values, ['roleid' => $roleId])
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new App\Db\Query())->select(['userid'])
- Exclude checks
Saw unextractable annotation for comment '* @return <settings_roles_record_model> instance'</settings_roles_record_model>
Open
* @return <Settings_Roles_Record_Model> instance
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->parent
Open
$this->parent = null;
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->children
Open
$this->children = $roles;
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new App\Db\Query())->from('vtiger_role')
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new App\Db\Query())->select(['profileid'])->from('vtiger_role2profile')->where(['roleid' => $this->getId()])->column();
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$insertedData = (new App\Db\Query())
- Exclude checks
Call to method getId
on non-class type null
Open
->where(['roleid' => $parentRole->getId()])
- Exclude checks
Saw unextractable annotation for comment '* @return <number>'</number>
Open
* @return <Number>
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new \App\Db\Query())->from('vtiger_role')
- Exclude checks
Reference to undeclared property \Settings_Roles_Record_Model->profiles
Open
return $this->profiles;
- Exclude checks
Returning type \Settings_Roles_Record_Model
but getInstanceByName()
is declared to return null
Open
return $instance;
- Exclude checks
Saw unextractable annotation for comment '* @return <settings_roles_record_model> instance'</settings_roles_record_model>
Open
* @return <Settings_Roles_Record_Model> instance
- Exclude checks
Avoid excessively long variable names like $currentParentRoleString. Keep variable name length under 20. Open
$currentParentRoleString = $this->getParentRoleString();
- 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 $transferParentRoleSequence. Keep variable name length under 20. Open
$transferParentRoleSequence = $transferToRole->getParentRoleString();
- 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 $oldChildParentRoleString. Keep variable name length under 20. Open
$oldChildParentRoleString = $roleModel->getParentRoleString();
- 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 $oldChildParentRoleString. Keep variable name length under 20. Open
$oldChildParentRoleString = $roleModel->getParentRoleString();
- 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 $newChildParentRoleString. Keep variable name length under 20. Open
$newChildParentRoleString = str_replace($currentParentRoleSequence, $transferParentRoleSequence, $oldChildParentRoleString);
- 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 $permissionsRelatedField. Keep variable name length under 20. Open
$permissionsRelatedField = $this->get('permissionsrelatedfield');
- 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 $newChildParentRoleString. Keep variable name length under 20. Open
$newChildParentRoleString = str_replace($currentParentRoleString, $newParentRoleString, $oldChildParentRoleString);
- 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 $currentParentRoleSequence. Keep variable name length under 20. Open
$currentParentRoleSequence = $this->getParentRoleString();
- 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
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_Roles_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
The class Settings_Roles_Record_Model is not named in CamelCase. Open
class Settings_Roles_Record_Model extends Settings_Vtiger_Record_Model
{
/**
* Function to get the Id.
*
- 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
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getId()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the Role 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
* @return <Number> Role 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
* Function to get the 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
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('roleid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get Parent Role hierarchy as a string.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($noOfRoles > 1) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->parent = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRoleString = '';
- 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
* Function to get all the children roles.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function returns profiles related to the current role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the profile id if profile is directly related to role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDepth()
- Exclude checks
Spaces must 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->parent = self::getInstanceById($parentComponents[$noOfRoles - 2]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentRoleDepth = $this->getDepth();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new \App\Db\Query())->from('vtiger_role')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->andWhere(['depth' => $currentRoleDepth + 1])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRoleString = $parentRoleString . '::' . $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
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->children)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->children = $roles;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array - profile ids
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Array> - List of Settings_Roles_Record_Model instances
- Exclude checks
Spaces must 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->children;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()->query();
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
return (new App\Db\Query())->select(['profileid'])->from('vtiger_role2profile')->where(['roleid' => $this->getId()])->column();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new App\Db\Query())->select(['profileid'])->from('vtiger_role2profile')->where(['roleid' => $this->getId()])->column();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleId = $this->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
public function getParentRoleString()
- Exclude checks
Spaces must 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(['like', 'parentrole', $parentRoleString . '::%', false])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roles[$role->getId()] = $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
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['like', 'parentrole', $this->getParentRoleString() . '::%', false])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->innerJoin('vtiger_profile', 'vtiger_profile.profileid = vtiger_role2profile.profileid')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('rolename');
- Exclude checks
Spaces must 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 to get the depth of the role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('parentrole');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->parent)) {
- Exclude checks
Spaces must 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->children = $roles;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($parentRoleString)) {
- Exclude checks
Spaces must 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 getAllChildren()
- 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDirectlyRelatedProfileId()
- Exclude checks
Spaces must 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 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentComponents = explode('::', $parentRoleString);
- Exclude checks
Spaces must 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentRoleDepth = $this->getDepth();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$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 getProfileIdList()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_role2profile')
- Exclude checks
Spaces must 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 <Number>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('depth');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRoleString = $this->getParentRoleString();
- 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
return false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new App\Db\Query())->select(['directly_related_to_role', 'vtiger_profile.profileid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$noOfRoles = \count($parentComponents);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->parent;
- Exclude checks
Spaces must 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
->andWhere(['depth' => $currentRoleDepth])
- 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
$role = 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
$roles[$role->getId()] = $role;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($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
* Function to get the immediate parent 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
->where(['like', 'parentrole', $parentRoleString . '::%', false])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roles[$role->getId()] = $role;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->children;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $parentRole
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Settings_Roles_Record_Model> instance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setParent($parentRole)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->parent = $parentRole;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getParent()
- Exclude checks
Spaces must 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 = (new \App\Db\Query())->from('vtiger_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
return $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
*
- Exclude checks
Spaces must 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
* Function to set the immediate parent role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roles = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($parentRoles as $role) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRoleString = $role;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roles = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$role = 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
}
- Exclude checks
Spaces must 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($this->children)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRoles = \App\PrivilegeUtil::getParentRole($this->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
* @return 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Settings_Roles_Record_Model[] List of Settings_Roles_Record_Model instances
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return <Settings_Roles_Record_Model> instance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRoleString = $this->getParentRoleString();
- 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
* Function to get the immediate children roles.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$role = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getSameLevelRoles()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new App\Db\Query())->from('vtiger_role')
- 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
$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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getChildren()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$role->setData($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
$role->setData($row);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$role->setData($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 ($row && 1 === (int) $row['directly_related_to_role']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the Edit View Url for the Role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$role->setParent($this);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRole = $this->getParent();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'depth' => $this->getDepth(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$insertedData = (new App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->select([new \yii\db\Expression($db->quoteValue($roleId)), 'picklistvalueid', 'picklistid', 'sortid'])
- 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
*
- Exclude checks
Spaces must 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->profiles;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('allowassignedrecordsto', $this->get('allowassignedrecordsto'));
- Exclude checks
Spaces must 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($permissionsRelatedField)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'parentrole' => $this->getParentRoleString(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$values['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
* Function to get all the profiles associated with the current 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
$currentDepth = $this->getDepth();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$oldChildParentRoleString = $roleModel->getParentRoleString();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleModel->set('parentrole', $newChildParentRoleString);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->all();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['vtiger_role2profile.roleid' => $this->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
return '?module=Roles&parent=Settings&view=DeleteAjax&record=' . $this->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
public function getProfiles()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $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
$mode = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$searchunpriv = implode(',', $searchunpriv);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'allowassignedrecordsto' => $this->get('allowassignedrecordsto'),
- Exclude checks
Spaces must 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
$allChildren = $this->getAllChildren();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newChildDepth = $oldChildDepth + $depthDifference;
- Exclude checks
Spaces must 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
$mode = '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
$rolePreviousData = App\PrivilegeUtil::getRoleDetail($roleId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$profileIds = $this->get('profileIds');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return '?module=Roles&parent=Settings&view=Edit&parent_roleid=' . $this->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Settings_Roles_Record_Model instance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to move the current role and all its children nodes to the new parent role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$oldChildDepth = $roleModel->getDepth();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleId = 'H' . $roleIdNumber;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$permissionsRelatedField = implode(',', $permissionsRelatedField);
- Exclude checks
Spaces must 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
* Function to add a child role to the current 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
public function addChildRole($role)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function moveTo($newParentRole)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('depth', $newDepth);
- 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
->one();
- Exclude checks
Spaces must 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> Settings_Profiles_Record_Model instances
- Exclude checks
Spaces must 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 <Settings_Roles_Record_Model> $newParentRole
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$depthDifference = $newDepth - $currentDepth;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('parentrole', $newParentRoleString);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleModel->set('allowassignedrecordsto', $roleModel->get('allowassignedrecordsto'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$searchunpriv = $this->get('searchunpriv');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'changeowner' => (int) $this->get('changeowner'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'editrelatedrecord' => (int) $this->get('editrelatedrecord'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return 'index.php?module=Roles&parent=Settings&view=Edit&record=' . $this->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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentParentRoleString = $this->getParentRoleString();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newParentRoleString = $newParentRole->getParentRoleString() . '::' . $this->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleModel->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
$permissionsRelatedField = $this->get('permissionsrelatedfield');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'listrelatedrecord' => $this->get('listrelatedrecord'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'permissionsrelatedfield' => $permissionsRelatedField,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('edit' === $mode) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert('vtiger_role', $values)->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_role2picklist')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $row['profileid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the Create Child Role Url for the current role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getCreateChildUrl()
- Exclude checks
Spaces must 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
$roleIdNumber = $db->getUniqueId('vtiger_role');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('depth', $parentRole->getDepth() + 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'assignedmultiowner' => $this->get('assignedmultiowner'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'globalsearchadv' => (int) $this->get('globalsearchadv'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['roleid' => $parentRole->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
$role->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
foreach ($allChildren as $roleModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newChildParentRoleString = str_replace($currentParentRoleString, $newParentRoleString, $oldChildParentRoleString);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (null !== $parentRole) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'searchunpriv' => $searchunpriv,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->update('vtiger_role', $values, ['roleid' => $roleId])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->batchInsert('vtiger_role2picklist', ['roleid', 'picklistvalueid', 'picklistid', 'sortid'], $insertedData)->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('roleid', $roleId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getEditViewUrl()
- Exclude checks
Spaces must 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
$newDepth = $newParentRole->getDepth() + 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to save the role.
- 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
* Function to get the Delete Action Url for the current role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->profiles)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->profiles = Settings_Profiles_Record_Model::getAllByRole($this->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
$this->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$values = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'rolename' => $this->getName(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'clendarallorecords' => $this->get('clendarallorecords'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'company' => (int) $this->get('company'),
- Exclude checks
Line exceeds 120 characters; contains 151 characters Open
$db->createCommand()->batchInsert('vtiger_role2picklist', ['roleid', 'picklistvalueid', 'picklistid', 'sortid'], $insertedData)->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getDeleteActionUrl()
- Exclude checks
Spaces must 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 <Settings_Roles_Record_Model> $role
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleModel->set('depth', $newChildDepth);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleId = $this->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
$this->set('parentrole', $parentRole->getParentRoleString() . '::' . $roleId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($searchunpriv)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'previewrelatedrecord' => $this->get('previewrelatedrecord'),
- Exclude checks
Spaces must 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
Line exceeds 120 characters; contains 127 characters Open
$newChildParentRoleString = str_replace($currentParentRoleString, $newParentRoleString, $oldChildParentRoleString);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rolePreviousData = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($roleId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'auto_assign' => (int) $this->get('auto_assign'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($rolePreviousData) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| $rolePreviousData['searchunpriv'] != $searchunpriv
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_group2rs', ['roleandsubid' => $roleId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\UserPrivilegesFile::createUserSharingPrivilegesfile($userid);
- Exclude checks
Spaces must 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
$query = (new App\Db\Query())->from('vtiger_role');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$baseRole) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->get('company')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('getUsersByCompany', $rolePreviousData['company']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$oldChildParentRoleString = $roleModel->getParentRoleString();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\is_array($usersInRole)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->getParent()) {
- Exclude checks
Spaces must 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 to get all the roles.
- 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
$role = new self();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_role2profile', ['roleid' => $roleId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleId = $this->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->update('vtiger_user2role', ['roleid' => $transferRoleId], ['roleid' => $roleId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$currentParentRoleSequence = $this->getParentRoleString();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Privilege::setAllUpdater();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => 'fas fa-trash-alt',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roles[$role->getId()] = $role;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db = App\Db::getInstance();
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$db->createCommand()->update('vtiger_user2role', ['roleid' => $transferRoleId], ['roleid' => $roleId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//delete handling for sharing rules
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must 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 self|null
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| ($profileIds && !empty(array_merge(array_diff($profileIds, $oldProfileIds), array_diff($oldProfileIds, $profileIds))))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('getUsersByCompany', $this->get('company'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($usersInRole as $userid) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getRecordLinks(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'LISTVIEWRECORD',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_DELETE_RECORD',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
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
for ($i = 0; $i < $noOfProfiles; ++$i) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('getUsersByCompany', '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$usersInRole = $this->getUsersIds();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordLinks = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $this->getEditViewUrl(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkurl' => $this->getDeleteActionUrl(),
- Exclude checks
Spaces must 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->orderBy(['parentrole' => SORT_DESC])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getInstanceById($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
|| $rolePreviousData['editrelatedrecord'] != $this->get('editrelatedrecord')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_role2profile', ['roleid' => $roleId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$newChildDepth = \count(explode('::', $newChildParentRoleString)) - 1;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getAll($baseRole = 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
if ($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
if (!empty($profileIds)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($noOfProfiles > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete('RoleDetail', $roleId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($rolePreviousData['company'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param <Settings_Roles_Record_Model> $transferToRole
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleModel->set('depth', $newChildDepth);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink);
- Exclude checks
Spaces must 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> list of Role models <Settings_Roles_Record_Model>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roles = [];
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
|| ($profileIds && !empty(array_merge(array_diff($profileIds, $oldProfileIds), array_diff($oldProfileIds, $profileIds))))) {
- Exclude checks
Spaces must 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\Cache::delete('getCompanyRoles', '');
- Exclude checks
Spaces must 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 delete($transferToRole)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allChildren = $this->getAllChildren();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\UserPrivilegesFile::createUserPrivilegesfile($userid);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\App\Cache::staticHas(__CLASS__, $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
$newChildParentRoleString = str_replace($currentParentRoleSequence, $transferParentRoleSequence, $oldChildParentRoleString);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleModel->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
$row = \App\PrivilegeUtil::getRoleDetail($roleId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = (new self())->setData($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
->column();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($row) {
- 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
* Get multi company.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->all();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$oldProfileIds = $this->getProfileIdList();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$noOfProfiles = \count($profileIds);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_group2role', ['roleid' => $roleId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\PrivilegeUtil::deleteRelatedSharingRules($roleId, '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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the instance of Base Role model.
- 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
* @param type $name -- name of the role
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($row) {
- 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
->where(['roleid' => $this->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
if (!empty($profiles) && \count($profiles) > 0) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($rolePreviousData['listrelatedrecord'] != $this->get('listrelatedrecord')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
|| $rolePreviousData['previewrelatedrecord'] != $this->get('previewrelatedrecord')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->delete('vtiger_role', ['roleid' => $roleId])->execute();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transferParentRoleSequence = $transferToRole->getParentRoleString();
- Exclude checks
Line exceeds 120 characters; contains 136 characters Open
$newChildParentRoleString = str_replace($currentParentRoleSequence, $transferParentRoleSequence, $oldChildParentRoleString);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linklabel' => 'LBL_EDIT_RECORD',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($recordLinks as $recordLink) {
- 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
|| $rolePreviousData['permissionsrelatedfield'] != $permissionsRelatedField
- 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
\App\Privilege::setAllUpdater();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getMultiCompany()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$profileIds = array_keys($profiles);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to delete the role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($allChildren as $roleId => $roleModel) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linkicon' => 'yfi yfi-full-editing-view',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $links;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$role->setData($row);
- 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
* Function to get the instance of Role model, given role id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::staticSave(__CLASS__, $roleId, $instance);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return \App\Cache::staticGet(__CLASS__, $roleId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new App\Db\Query())->from('vtiger_role')->where(['depth' => 0])->one();
- Exclude checks
Spaces must 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 getUsersIds()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $excludedRecordId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return Users_Record_Model[] User record models list Users_Record_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($profileIds)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$profiles = $this->getProfiles();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$db->createCommand()->insert('vtiger_role2profile', ['roleid' => $roleId, 'profileid' => $profileIds[$i]])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transferRoleId = $transferToRole->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$roleModel->set('parentrole', $newChildParentRoleString);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'linktype' => 'LISTVIEWRECORD',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->where(['<>', 'depth', 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
/** Function to get the instance of the role by Name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return null/role 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
{
- Exclude checks
Spaces must 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
Line exceeds 120 characters; contains 126 characters Open
$db->createCommand()->insert('vtiger_role2profile', ['roleid' => $roleId, 'profileid' => $profileIds[$i]])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Cache::delete(__CLASS__, $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
* @param bool $baseRole
- Exclude checks
Spaces must 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 Settings_Roles_Record_Model instance, if exists. Null otherwise
- Exclude checks
Spaces must 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->setData($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 (new App\Db\Query())->select(['userid'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $usersList;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$usersList = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['mulcomp_status' => 'PLL_ACTIVE'])
- 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
public static function getInstanceByName($name, $excludedRecordId = [])
- 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
* @return 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
return (new App\Db\Query())->select(['multicompanyid', 'company_name'])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('u_#__multicompany')
- Exclude checks
Spaces must 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($excludedRecordId)) {
- Exclude checks
Spaces must 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 to get Users who are from this role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$usersList[$userId] = Users_Record_Model::getInstanceById($userId, 'Users');
- 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
public static function getBaseRole()
- Exclude checks
Spaces must 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 null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getUsers()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->andWhere(['NOT IN', 'roleid', $excludedRecordId]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($userIds as $userId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new App\Db\Query())->from('vtiger_role')->where(['rolename' => $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
* Function to get ids users in this role.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_user2role')
- Exclude checks
Spaces must 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 null;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$userIds = $this->getUsersIds();
- Exclude checks
Class name "Settings_Roles_Record_Model" is not in camel caps format Open
class Settings_Roles_Record_Model extends Settings_Vtiger_Record_Model
- Exclude checks