Function davSync
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function davSync(): int
{
$create = $updates = 0;
foreach ($this->davUsers as $userId => $user) {
$this->calendarId = $user->get('calendarsid');
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File CalDAV.php
has 267 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Api CalDAV Model Class.
*
Function recordSync
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
public function recordSync(): int
{
\App\Log::trace('Start', __METHOD__);
$query = (new \App\Db\Query())->select([
'dav_calendarobjects.*',
- 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 recordSync
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function recordSync(): int
{
\App\Log::trace('Start', __METHOD__);
$query = (new \App\Db\Query())->select([
'dav_calendarobjects.*',
Method davSync
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function davSync(): int
{
$create = $updates = 0;
foreach ($this->davUsers as $userId => $user) {
$this->calendarId = $user->get('calendarsid');
Function recordCreate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function recordCreate($cal)
{
\App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);
$calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata']);
foreach ($calendar->getRecordInstance() as $recordModel) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function recordUpdate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function recordUpdate(Vtiger_Record_Model $record, $cal)
{
\App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);
$calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata'], $record, $cal['uid']);
foreach ($calendar->getRecordInstance() as $recordModel) {
- 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 recordCreate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function recordCreate($cal)
{
\App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);
$calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata']);
foreach ($calendar->getRecordInstance() as $recordModel) {
Method davCreate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function davCreate()
{
\App\Log::trace(__METHOD__ . ' | Start CRM ID:' . $this->record['id']);
$instance = \App\Integrations\Dav\Calendar::createEmptyInstance();
$instance->loadFromArray($this->record);
Method recordUpdate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function recordUpdate(Vtiger_Record_Model $record, $cal)
{
\App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);
$calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata'], $record, $cal['uid']);
foreach ($calendar->getRecordInstance() as $recordModel) {
Function toDelete
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function toDelete($cal)
{
if ('' === $cal['assigned_user_id'] || 0 !== (int) $cal['deleted']) {
return true;
}
- 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 davSync() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function davSync(): int
{
$create = $updates = 0;
foreach ($this->davUsers as $userId => $user) {
$this->calendarId = $user->get('calendarsid');
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method toDelete() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
protected function toDelete($cal)
{
if ('' === $cal['assigned_user_id'] || 0 !== (int) $cal['deleted']) {
return true;
}
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 24 to the 15 allowed. Open
public function davSync(): int
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed. Open
public function recordSync(): int
- 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 '15'). Open
return (new \App\Db\Query())->from('dav_calendarobjects')->where(['calendarid' => $this->calendarId, 'crmid' => $this->record['id']])->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
Missing class import via use statement (line '228', column '17'). Open
$query = (new \App\Db\Query())->select([
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '75', column '25'). Open
$queryGenerator = new \App\QueryGenerator('Calendar');
- 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\Log' in method 'davCreate'. Open
\App\Log::trace(__METHOD__ . ' | Start CRM ID:' . $this->record['id']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Integrations\Dav\Calendar' in method 'davCreate'. Open
\App\Integrations\Dav\Calendar::addChange($this->calendarId, $calUri, 1);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'dav2Crm'. Open
\App\Log::trace(__METHOD__ . ' | End');
- 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 recordSync uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
++$skipped;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Log' in method 'recordCreate'. Open
\App\Log::info(__METHOD__ . ' | End exclusion');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'davCreate'. Open
\App\Log::trace(__METHOD__ . ' | End');
- 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 recordSync uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
++$skipped;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Fields\SharedOwner' in method 'toDelete'. Open
$isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($userId, \App\Fields\SharedOwner::getById($cal['id']));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Integrations\Dav\Calendar' in method 'recordUpdate'. Open
$calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata'], $record, $cal['uid']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'recordUpdate'. Open
\App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'recordUpdate'. Open
\App\Log::trace(__METHOD__ . ' | End');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Fields\SharedOwner' in method 'toDelete'. Open
$shownerIds = \App\Fields\SharedOwner::getById($cal['id']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'davSync'. Open
$exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_TO_DAV');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'dav2Crm'. Open
\App\Log::trace(__METHOD__ . ' | Start');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\User' in method 'davSync'. Open
App\User::setCurrentUserId($orgUserId);
- 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\Integrations\Dav\Calendar' in method 'recordCreate'. Open
$calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata']);
- 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\Integrations\Dav\Calendar' in method 'davUpdate'. Open
$instance = \App\Integrations\Dav\Calendar::loadFromDav($dav['calendardata']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'davUpdate'. Open
\App\Log::trace(__METHOD__ . ' | End');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'recordCreate'. Open
\App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'recordUpdate'. Open
$exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_FROM_DAV');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'recordUpdate'. Open
\App\Log::info(__METHOD__ . ' | End exclusion');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\User' in method 'davSync'. Open
$orgUserId = App\User::getCurrentUserId();
- 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\Integrations\Dav\Calendar' in method 'davCreate'. Open
$instance = \App\Integrations\Dav\Calendar::createEmptyInstance();
- 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 recordSync uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (strtotime($row['modifiedtime']) < $row['lastmodified']) { // Updating
if ($this->recordUpdate(Vtiger_Record_Model::getInstanceById($row['crmid'], $row['setype']), $row)) {
++$updates;
} else {
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class '\App\Log' in method 'recordSync'. Open
\App\Log::trace("Calendar end - DAV >> CRM | create: $create | deletes: $deletes | updates: $updates | skipped: $skipped", __METHOD__);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\User' in method 'davSync'. Open
App\User::setCurrentUserId($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 'Vtiger_Record_Model' in method 'recordSync'. Open
if ($this->recordUpdate(Vtiger_Record_Model::getInstanceById($row['crmid'], $row['setype']), $row)) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'recordCreate'. Open
$exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_FROM_DAV');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'recordCreate'. Open
\App\Log::trace(__METHOD__ . ' | End');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'davSync'. Open
\App\Log::trace("Calendar end - CRM >> DAV | create: $create | updates: $updates", __METHOD__);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Integrations\Dav\Calendar' in method 'davUpdate'. Open
\App\Integrations\Dav\Calendar::addChange($this->calendarId, $dav['uri'], 2);
- 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\Integrations\Dav\Calendar' in method 'recordSync'. Open
\App\Integrations\Dav\Calendar::delete($row);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'crm2Dav'. Open
\App\Log::trace(__METHOD__ . ' | Start');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'crm2Dav'. Open
\App\Log::trace(__METHOD__ . ' | End');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'recordSync'. Open
\App\Log::trace('Start', __METHOD__);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "vtiger_crmentity.deleted" 3 times. Open
$queryGenerator->setCustomColumn(['vtiger_crmentity.deleted']);
- 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 "lastmodified" 6 times. Open
} elseif (strtotime($this->record['modifiedtime']) > $event['lastmodified']) { // Updating
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "crmid" 11 times. Open
'crmid' => $this->record['id'],
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "calendarid" 3 times. Open
'calendarid' => $this->calendarId,
- 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_crmentity" 3 times. Open
->leftJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = dav_calendarobjects.crmid')
- 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 "dav_calendarobjects" 6 times. Open
\App\Db::getInstance()->createCommand()->insert('dav_calendarobjects', [
- 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 "calendardata" 5 times. Open
'calendardata' => $calendarData,
- 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 "assigned_user_id" 8 times. Open
$queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);
- 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 " | End" 6 times. Open
\App\Log::trace(__METHOD__ . ' | End');
- 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 "modifiedtime" 7 times. Open
$queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call to method setCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
App\User::setCurrentUserId($orgUserId);
- Exclude checks
Call to method serialize
from undeclared class \Sabre\VObject\Component\VCalendar
Open
$calendarData = $calendar->serialize();
- Exclude checks
Call to method createQuery
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$query = $queryGenerator->createQuery();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | Start CRM ID:' . $this->record['id']);
- Exclude checks
Call to method info
from undeclared class \App\Log
Open
\App\Log::info(__METHOD__ . ' | End exclusion');
- Exclude checks
Assigning false
to property but \API_CalDAV_Model->calendarId
is int
Open
public $calendarId = false;
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);
- Exclude checks
Reference to instance property name
from undeclared class \Sabre\VObject\Component
Open
if ('VEVENT' === (string) $component->name) {
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Reference to instance property name
from undeclared class \Sabre\VObject\Component
Open
if ('VEVENT' === (string) $component->name) {
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Call to method setCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
App\User::setCurrentUserId($userId);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->update('dav_calendarobjects', [
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Call to method info
from undeclared class \App\Log
Open
\App\Log::info(__METHOD__ . ' | End exclusion');
- Exclude checks
Reference to instance property permissions
from undeclared class \App\QueryGenerator
Open
$queryGenerator->permissions = false;
- Exclude checks
Reference to instance property UID
from undeclared class \Sabre\VObject\Component
Open
$uid = (string) $component->UID;
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace('Start', __METHOD__);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Call to method __construct
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = new \App\QueryGenerator('Calendar');
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
App\Db::getInstance()->createCommand()->update('vtiger_activity', [
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | Start');
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
return (new \App\Db\Query())->from('dav_calendarobjects')->where(['calendarid' => $this->calendarId, 'crmid' => $this->record['id']])->one();
- Exclude checks
Call to method setCustomColumn
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator->setCustomColumn(['vtiger_crmentity.deleted']);
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Calendar end - CRM >> DAV | create: $create | updates: $updates", __METHOD__);
- Exclude checks
Call to method serialize
from undeclared class \Sabre\VObject\Component\VCalendar
Open
$calendarData = $calendar->serialize();
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace("Calendar end - DAV >> CRM | create: $create | deletes: $deletes | updates: $updates | skipped: $skipped", __METHOD__);
- Exclude checks
Assigning false
to property but \API_CalDAV_Model->record
is array
Open
public $record = false;
- Exclude checks
Call to method trace
from undeclared class \App\Log
Open
\App\Log::trace(__METHOD__ . ' | Start');
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$query = (new \App\Db\Query())->select([
- Exclude checks
Call to method getCurrentUserId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
$orgUserId = App\User::getCurrentUserId();
- Exclude checks
Call to undeclared method \App\Db::createCommand
Open
\App\Db::getInstance()->createCommand()->insert('dav_calendarobjects', [
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
case 'PLL_OWNER_PERSON_GROUP':
$shownerIds = \App\Fields\SharedOwner::getById($cal['id']);
$isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($cal['assigned_user_id'], $this->user->get('groups')) || \in_array($userId, $shownerIds) || \count(array_intersect($shownerIds, $this->user->get('groups'))) > 0;
break;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 113.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class API_CalDAV_Model
- Exclude checks
The class API_CalDAV_Model is not named in CamelCase. Open
class API_CalDAV_Model
{
/**
* Prod 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 $i. Configured minimum length is 3. Open
$i = 0;
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = 0;
- 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 for alignment; tabs are not allowed Open
->where(['calendarid' => $this->calendarId]);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Log::trace("Calendar end - DAV >> CRM | create: $create | deletes: $deletes | updates: $updates | skipped: $skipped", __METHOD__);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Record create.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->update('dav_calendarobjects', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->update('vtiger_crmentity', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$calendar->recordSaveAttendee($recordModel);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$skipped = $create = $deletes = $updates = 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Log::info(__METHOD__ . ' | End exclusion');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordModel->save();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
)->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Record update.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->leftJoin('vtiger_crmentity', 'vtiger_crmentity.crmid = dav_calendarobjects.crmid')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Integrations\Dav\Calendar::delete($row);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$row['crmid']) { //Creating
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function recordCreate($cal)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
], ['crmid' => $recordModel->getId()]
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
)->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Log::trace(__METHOD__ . ' | Start Cal ID:' . $cal['crmid']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->update('vtiger_crmentity', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'crmid' => $recordModel->getId(),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
++$create;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return $create + $updates + $deletes;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param array $cal
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($exclusion as $key => $value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_crmentity.modifiedtime', 'vtiger_crmentity.setype', 'assigned_user_id' => 'vtiger_crmentity.smownerid',
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
->leftJoin('vtiger_activity', 'vtiger_crmentity.crmid = vtiger_activity.activityid')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Log::info(__METHOD__ . ' | End exclusion');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
)->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
])->from('dav_calendarobjects')
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($this->recordUpdate(Vtiger_Record_Model::getInstanceById($row['crmid'], $row['setype']), $row)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param array $cal
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (\is_array($exclusion)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'modifiedtime' => date('Y-m-d H:i:s', $cal['lastmodified']),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} elseif ($this->toDelete(array_merge($row, ['id' => $row['crmid']]))) { // Deleting
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
++$deletes;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordModel->save();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($calendar->getRecordInstance() as $recordModel) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
], ['id' => $cal['id']]
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$calendar = \App\Integrations\Dav\Calendar::loadFromContent($cal['calendardata'], $record, $cal['uid']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand->update('dav_calendarobjects', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
], ['id' => $cal['id']]
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($this->recordCreate($row)) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (strtotime($row['modifiedtime']) < $row['lastmodified']) { // Updating
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$recordModel->set('assigned_user_id', $this->user->get('id'));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_FROM_DAV');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($exclusion as $key => $value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$dbCommand = \App\Db::getInstance()->createCommand();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'crmid' => $recordModel->getId(),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param Vtiger_Record_Model $record
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
foreach ($calendar->getRecordInstance() as $recordModel) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_FROM_DAV');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Log::trace(__METHOD__ . ' | Start Cal ID' . $cal['id']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($recordModel->get($key) == $value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'vtiger_crmentity.crmid', 'vtiger_crmentity.deleted', 'vtiger_activity.visibility'
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
++$updates;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ($recordModel->get($key) == $value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
++$skipped;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (false !== $exclusion) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
while ($row = $dataReader->read()) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
++$skipped;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function recordUpdate(Vtiger_Record_Model $record, $cal)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
protected function recordMarkComplete()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
protected function toDelete($cal)
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if (!$isPermitted && 'Public' !== $cal['visibility']) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'modifiedtime' => date('Y-m-d H:i:s', $cal['lastmodified']),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
], ['crmid' => $recordModel->getId()]
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
public function getDavDetail()
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
)->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return array|bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Record mark complete.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$userId = (int) $this->user->getId();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
case 'PLL_OWNER_PERSON_GROUP':
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
App\Db::getInstance()->createCommand()->update('vtiger_activity', [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($userId, \App\Fields\SharedOwner::getById($cal['id']));
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* To delete.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @param array $cal
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
if ('' === $cal['assigned_user_id'] || 0 !== (int) $cal['deleted']) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return true;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
case 'PLL_OWNER':
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$isPermitted = (int) $cal['assigned_user_id'] === $userId;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return (new \App\Db\Query())->from('dav_calendarobjects')->where(['calendarid' => $this->calendarId, 'crmid' => $this->record['id']])->one();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
], ['activityid' => $this->record['id']]
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
switch ($this->user->get('sync_caldav')) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$shownerIds = \App\Fields\SharedOwner::getById($cal['id']);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* Get dav detail.
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
*
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($cal['assigned_user_id'], $this->user->get('groups')) || \in_array($userId, $shownerIds) || \count(array_intersect($shownerIds, $this->user->get('groups'))) > 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
return false;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$calendar->recordSaveAttendee($recordModel);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
'dav_status' => 0,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
)->execute();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
case 'PLL_OWNER_PERSON':
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Calendar name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const PRODID = 'YetiForce';
- Exclude checks
Spaces must 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
* Prod 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
const CALENDAR_NAME = 'YFCalendar';
- Exclude checks
Spaces must 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 $record = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = $queryGenerator->createQuery();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i = 0;
- 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
'calendarid' => $this->calendarId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'crmid' => $this->record['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
public $user = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function davSync(): int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$create = $updates = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->calendarId = $user->get('calendarsid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Creating
- Exclude checks
Spaces must 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\Integrations\Dav\Calendar::addChange($this->calendarId, $calUri, 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must 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 ($exclusion as $key => $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$calendar = $instance->getVCalendar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$uid = (string) $component->UID;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('VEVENT' === (string) $component->name) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$calendarData = $calendar->serialize();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'lastmodified' => strtotime($this->record['modifiedtime']),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected static $cache = [];
- 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
$this->user = $user;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->davUpdate($event);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function davCreate()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->insert('dav_calendarobjects', [
- 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
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Calendar id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->permissions = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i += $this->davSync();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$orgUserId = App\User::getCurrentUserId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$cache[$userId][$this->record['id']] = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Dav create.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$calUri = $uid . '.ics';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'uri' => $calUri,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'lastoccurence' => $extraData['lastOccurence'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->loadFromArray($this->record);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $calendarId = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = $query->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($isPermitted) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
App\User::setCurrentUserId($userId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$event = $this->getDavDetail();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'calendardata' => $calendarData,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $dav
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const COMPONENTS = 'VEVENT,VTODO';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $davUsers = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== $exclusion) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false === $event) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace("Calendar end - CRM >> DAV | create: $create | updates: $updates", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'etag' => $extraData['etag'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function davUpdate($dav)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = \App\Integrations\Dav\Calendar::loadFromDav($dav['calendardata']);
- Exclude checks
Spaces must 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
$instance->davSaveAttendee($this->record);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var bool|mixed
- Exclude checks
Spaces must 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
$queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->davSaveAttendee($this->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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->record = $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
$exclusion = \App\Config::component('Dav', 'CALDAV_EXCLUSION_TO_DAV');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->record[$key] == $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace(__METHOD__ . ' | Start CRM ID:' . $this->record['id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'componenttype' => $extraData['componentType'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$component = $instance->getComponent();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$updates;
- Exclude checks
Spaces must 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
'uid' => $uid,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$calendar = $instance->getVCalendar();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* User.
- Exclude checks
Spaces must 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
* Dav users.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Cache.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function crm2Dav(): 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
\App\Log::trace(__METHOD__ . ' | Start');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = new \App\QueryGenerator('Calendar');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->davUsers as $userId => $user) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$extraData = $instance->getDenormalizedData($calendarData);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Components.
- Exclude checks
Spaces must 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 278 characters Open
$queryGenerator->setFields(['id', 'subject', 'subject', 'activitytype', 'date_start', 'due_date', 'time_start', 'time_end', 'activitystatus', 'taskpriority', 'location', 'visibility', 'assigned_user_id', 'allday', 'state', 'createdtime', 'modifiedtime', 'description']);
- Exclude checks
Spaces must 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 ($isPermitted) {
- Exclude checks
Spaces must 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->loadFromArray($this->record);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'size' => $extraData['size'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Spaces must 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
* @var array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query->where(['vtiger_crmentity.deleted' => 0, 'vtiger_activity.dav_status' => 1]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$isPermitted = !isset(self::$cache[$userId][$this->record['id']]) && !$this->toDelete($this->record);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$isPermitted = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
App\User::setCurrentUserId($orgUserId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->recordMarkComplete();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = \App\Integrations\Dav\Calendar::createEmptyInstance();
- Exclude checks
Spaces must 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->updateComponent();
- Exclude checks
Spaces must 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
$queryGenerator->setCustomColumn(['vtiger_crmentity.deleted']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Dav sync.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$create;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (strtotime($this->record['modifiedtime']) > $event['lastmodified']) { // Updating
- Exclude checks
Spaces must 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 $create + $updates;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'firstoccurence' => $extraData['firstOccurence'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('VEVENT' === (string) $component->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
* Sync from CRM to DAV.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $i;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->davCreate();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$component = $instance->createComponent();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Dav update.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Integrations\Dav\Calendar::addChange($this->calendarId, $dav['uri'], 2);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $i;
- Exclude checks
Line exceeds 120 characters; contains 143 characters Open
\App\Log::trace("Calendar end - DAV >> CRM | create: $create | deletes: $deletes | updates: $updates | skipped: $skipped", __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$calendarData = $calendar->serialize();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'etag' => $extraData['etag'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'firstoccurence' => $extraData['firstOccurence'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace(__METHOD__ . ' | End');
- 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
\App\Log::trace(__METHOD__ . ' | Start');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->calendarId = $user->get('calendarsid');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Sync record.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i += $this->recordSync();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->davUsers as $user) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'lastoccurence' => $extraData['lastOccurence'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'crmid' => $this->record['id'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function recordSync(): int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$query = (new \App\Db\Query())->select([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'calendardata' => $calendarData,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace('Start', __METHOD__);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'size' => $extraData['size'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function dav2Crm(): int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->user = $user;
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
'vtiger_crmentity.modifiedtime', 'vtiger_crmentity.setype', 'assigned_user_id' => 'vtiger_crmentity.smownerid',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'componenttype' => $extraData['componentType'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$i = 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
], ['id' => $dav['id']]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
if ($this->recordUpdate(Vtiger_Record_Model::getInstanceById($row['crmid'], $row['setype']), $row)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$extraData = $instance->getDenormalizedData($calendarData);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'dav_calendarobjects.*',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->createCommand()->update('dav_calendarobjects', [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'uid' => $extraData['uid'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::trace(__METHOD__ . ' | End');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'lastmodified' => strtotime($this->record['modifiedtime']),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Sync from DAV to CRM.
- Exclude checks
Spaces must 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 int
- 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
'vtiger_crmentity.modifiedtime', 'vtiger_crmentity.setype', 'assigned_user_id' => 'vtiger_crmentity.smownerid',
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
return (new \App\Db\Query())->from('dav_calendarobjects')->where(['calendarid' => $this->calendarId, 'crmid' => $this->record['id']])->one();
- Exclude checks
Line exceeds 120 characters; contains 248 characters Open
$isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($cal['assigned_user_id'], $this->user->get('groups')) || \in_array($userId, $shownerIds) || \count(array_intersect($shownerIds, $this->user->get('groups'))) > 0;
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
$isPermitted = (int) $cal['assigned_user_id'] === $userId || \in_array($userId, \App\Fields\SharedOwner::getById($cal['id']));
- Exclude checks
Class name "API_CalDAV_Model" is not in camel caps format Open
class API_CalDAV_Model
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
$dbCommand->update('vtiger_crmentity', [
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
\App\Db::getInstance()->createCommand()->update('dav_calendarobjects', [
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
$dbCommand->update('dav_calendarobjects', [
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
$dbCommand->update('dav_calendarobjects', [
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
App\Db::getInstance()->createCommand()->update('vtiger_activity', [
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
$dbCommand->update('vtiger_crmentity', [
- Exclude checks