| Total Complexity | 12 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | trait CMSNicetiesTraitForCanMethods |
||
| 10 | { |
||
| 11 | public function canCreate($member = null, $context = []) |
||
| 12 | { |
||
| 13 | if (! $member) { |
||
| 14 | $member = Security::getCurrentUser(); |
||
| 15 | } |
||
| 16 | |||
| 17 | if ($this->hasMethod('canEditingOwnerObject')) { |
||
|
|
|||
| 18 | $obj = $this->canEditingOwnerObject(); |
||
| 19 | if ($obj instanceof ArrayList) { |
||
| 20 | $outcome = true; |
||
| 21 | foreach ($obj as $item) { |
||
| 22 | if (! $item->canCreate($member, $context)) { |
||
| 23 | $outcome = false; |
||
| 24 | |||
| 25 | break; |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($outcome) { |
||
| 30 | return parent::canCreate($member, $context); |
||
| 31 | } |
||
| 32 | |||
| 33 | return false; |
||
| 34 | } |
||
| 35 | |||
| 36 | return $obj->canCreate($member, $context); |
||
| 37 | } |
||
| 38 | |||
| 39 | $groupCodes = $this->hasMethod('canEditingGroupsCodes') ? $this->canEditingGroupsCodes() : [ |
||
| 40 | 'CMS_ACCESS_CMSMain', |
||
| 41 | ]; |
||
| 42 | $groupCodes = array_merge(['ADMIN'], $groupCodes); |
||
| 43 | |||
| 44 | foreach ($groupCodes as $groupCode) { |
||
| 45 | if (Permission::checkMember($member, $groupCode)) { |
||
| 46 | return parent::canCreate($member, $context); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | return false; |
||
| 51 | } |
||
| 52 | |||
| 53 | public function canEdit($member = null) |
||
| 54 | { |
||
| 55 | return $this->canCreate($member); |
||
| 56 | } |
||
| 57 | |||
| 58 | public function canDelete($member = null) |
||
| 61 | } |
||
| 62 | } |
||
| 63 |