@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // Check if user is admin or if he has at least a role on the domain |
| 110 | 110 | // or on descendants domains if withDescendants option is on |
| 111 | - return $builder->where('is_admin',true) |
|
| 112 | - ->orWhereIn($this->getKeyName(), function ($query) use ($domain, $withDescendants) { |
|
| 111 | + return $builder->where('is_admin', true) |
|
| 112 | + ->orWhereIn($this->getKeyName(), function($query) use ($domain, $withDescendants) { |
|
| 113 | 113 | $privilegesTable = env('UCCELLO_TABLE_PREFIX', 'uccello_').'privileges'; |
| 114 | 114 | |
| 115 | 115 | $query->select('user_id') |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | $i = 0; |
| 189 | 189 | foreach ($words as $w) { |
| 190 | - $initials .= $w[0]; |
|
| 190 | + $initials .= $w[ 0 ]; |
|
| 191 | 191 | $i++; |
| 192 | 192 | |
| 193 | 193 | if ($i === 3) { // Maximum: 3 letters |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $image = 'vendor/uccello/uccello/images/user-no-image.png'; |
| 209 | 209 | |
| 210 | 210 | if ($this->avatarType === 'gravatar') { |
| 211 | - $image = 'https://www.gravatar.com/avatar/' . md5($this->email) . '?d=mm'; |
|
| 211 | + $image = 'https://www.gravatar.com/avatar/'.md5($this->email).'?d=mm'; |
|
| 212 | 212 | |
| 213 | 213 | } elseif ($this->avatarType === 'image' && !empty($this->avatar->path)) { |
| 214 | 214 | $image = $this->avatar->path; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param mixed $defaultValue |
| 235 | 235 | * @return \stdClass|null; |
| 236 | 236 | */ |
| 237 | - public function getSettings($key, $defaultValue=null) { |
|
| 237 | + public function getSettings($key, $defaultValue = null) { |
|
| 238 | 238 | return $this->userSettings->data->{$key} ?? $defaultValue; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | |
| 313 | 313 | $hasRole = false; |
| 314 | 314 | |
| 315 | - $descendants = Cache::remember('domain_'.$domain->slug.'_descendants', 600, function () use($domain) { |
|
| 315 | + $descendants = Cache::remember('domain_'.$domain->slug.'_descendants', 600, function() use($domain) { |
|
| 316 | 316 | return $domain->findDescendants()->get(); |
| 317 | 317 | }); |
| 318 | 318 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | { |
| 339 | 339 | $keyName = 'user_'.$this->id.'_'.$domain->slug.'_'.$module->name.'_capabilities'; |
| 340 | 340 | |
| 341 | - return Cache::remember($keyName, 600, function () use($domain, $module) { |
|
| 341 | + return Cache::remember($keyName, 600, function() use($domain, $module) { |
|
| 342 | 342 | $capabilities = collect(); |
| 343 | 343 | |
| 344 | 344 | // Get the domain and all its parents |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | $keyName = 'user_'.$this->id.'_'.$domain->slug.'_can_access_to_settings_panel'; |
| 394 | 394 | |
| 395 | - return Cache::remember($keyName, 600, function () use($domain) { |
|
| 395 | + return Cache::remember($keyName, 600, function() use($domain) { |
|
| 396 | 396 | |
| 397 | 397 | $hasCapability = false; |
| 398 | 398 | |
@@ -544,8 +544,8 @@ discard block |
||
| 544 | 544 | { |
| 545 | 545 | // Use cache |
| 546 | 546 | $allowedGroups = Cache::rememberForever( |
| 547 | - 'allowed_groups_for_' . ($this->is_admin ? 'admin' : $this->getKey()), |
|
| 548 | - function () { |
|
| 547 | + 'allowed_groups_for_'.($this->is_admin ? 'admin' : $this->getKey()), |
|
| 548 | + function() { |
|
| 549 | 549 | return $this->getAllowedGroupUuidsProcess(); |
| 550 | 550 | } |
| 551 | 551 | ); |
@@ -557,8 +557,8 @@ discard block |
||
| 557 | 557 | { |
| 558 | 558 | // Use cache |
| 559 | 559 | $allowedGroupsAndUsers = Cache::rememberForever( |
| 560 | - 'allowed_group_users_for_' . ($addUsers ? 'u_' : '') . ($this->is_admin ? 'admin' : $this->getKey()), |
|
| 561 | - function () use ($addUsers) { |
|
| 560 | + 'allowed_group_users_for_'.($addUsers ? 'u_' : '').($this->is_admin ? 'admin' : $this->getKey()), |
|
| 561 | + function() use ($addUsers) { |
|
| 562 | 562 | return $this->getAllowedGroupsAndUsersProcess($addUsers); |
| 563 | 563 | } |
| 564 | 564 | ); |
@@ -568,16 +568,16 @@ discard block |
||
| 568 | 568 | |
| 569 | 569 | protected function getAllowedGroupUuidsProcess() |
| 570 | 570 | { |
| 571 | - $allowedUserUuids = collect([$this->uuid]); |
|
| 571 | + $allowedUserUuids = collect([ $this->uuid ]); |
|
| 572 | 572 | |
| 573 | 573 | if ($this->is_admin) { |
| 574 | 574 | $groups = Group::all(); |
| 575 | 575 | } else { |
| 576 | - $groups = []; |
|
| 577 | - $users = []; |
|
| 576 | + $groups = [ ]; |
|
| 577 | + $users = [ ]; |
|
| 578 | 578 | |
| 579 | 579 | foreach ($this->groups as $group) { |
| 580 | - $groups[$group->uuid] = $group; |
|
| 580 | + $groups[ $group->uuid ] = $group; |
|
| 581 | 581 | }; |
| 582 | 582 | |
| 583 | 583 | $this->addRecursiveChildrenGroups($groups, $users, $groups, false); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | foreach ($groups as $uuid => $group) { |
| 589 | - $allowedUserUuids[] = $uuid; |
|
| 589 | + $allowedUserUuids[ ] = $uuid; |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | return $allowedUserUuids; |
@@ -595,19 +595,19 @@ discard block |
||
| 595 | 595 | protected function addRecursiveChildrenGroups(&$groups, &$users, $searchGroups, $addUsers = false) |
| 596 | 596 | { |
| 597 | 597 | foreach ($searchGroups as $uuid => $searchGroup) { |
| 598 | - $searchChildrenGroups = []; |
|
| 598 | + $searchChildrenGroups = [ ]; |
|
| 599 | 599 | |
| 600 | 600 | foreach ($searchGroup->childrenGroups as $childrenGroup) { |
| 601 | - if (empty($groups[$childrenGroup->uuid])) { |
|
| 602 | - $groups[$childrenGroup->uuid] = $childrenGroup; |
|
| 603 | - $searchChildrenGroups[$childrenGroup->uuid] = $childrenGroup; |
|
| 601 | + if (empty($groups[ $childrenGroup->uuid ])) { |
|
| 602 | + $groups[ $childrenGroup->uuid ] = $childrenGroup; |
|
| 603 | + $searchChildrenGroups[ $childrenGroup->uuid ] = $childrenGroup; |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - if($addUsers) |
|
| 606 | + if ($addUsers) |
|
| 607 | 607 | { |
| 608 | 608 | foreach ($childrenGroup->users as $user) { |
| 609 | - if (empty($users[$user->uuid])) { |
|
| 610 | - $users[$user->uuid] = $user; |
|
| 609 | + if (empty($users[ $user->uuid ])) { |
|
| 610 | + $users[ $user->uuid ] = $user; |
|
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | 613 | } |
@@ -619,10 +619,10 @@ discard block |
||
| 619 | 619 | |
| 620 | 620 | protected function getAllowedGroupsAndUsersProcess($addUsers = true) |
| 621 | 621 | { |
| 622 | - $allowedUserUuids = collect([[ |
|
| 622 | + $allowedUserUuids = collect([ [ |
|
| 623 | 623 | 'uuid' => $this->uuid, |
| 624 | 624 | 'recordLabel' => uctrans('me', $this->module) |
| 625 | - ]]); |
|
| 625 | + ] ]); |
|
| 626 | 626 | |
| 627 | 627 | // if ($this->is_admin) { |
| 628 | 628 | $groups = Group::orderBy('name')->get(); |
@@ -651,15 +651,15 @@ discard block |
||
| 651 | 651 | // } |
| 652 | 652 | |
| 653 | 653 | foreach ($groups as $uuid => $group) { |
| 654 | - $allowedUserUuids[] = [ |
|
| 654 | + $allowedUserUuids[ ] = [ |
|
| 655 | 655 | 'uuid' => $group->uuid, |
| 656 | 656 | 'recordLabel' => $group->recordLabel |
| 657 | 657 | ]; |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | foreach ($users as $uuid => $user) { |
| 661 | - if($user->getKey() != $this->getKey()) { |
|
| 662 | - $allowedUserUuids[] = [ |
|
| 661 | + if ($user->getKey() != $this->getKey()) { |
|
| 662 | + $allowedUserUuids[ ] = [ |
|
| 663 | 663 | 'uuid' => $user->uuid, |
| 664 | 664 | 'recordLabel' => $user->recordLabel |
| 665 | 665 | ]; |