Passed
Push — master ( 604a65...860698 )
by Jonathan
23:05
created

User::scopeWithRoleInDomain()   B

Complexity

Conditions 7
Paths 4

Size

Total Lines 35
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
c 0
b 0
f 0
dl 0
loc 35
rs 8.8333
cc 7
nc 4
nop 3
1
<?php
2
3
namespace Uccello\Core\Models;
4
5
use Illuminate\Notifications\Notifiable;
6
use Illuminate\Foundation\Auth\User as Authenticatable;
7
use Illuminate\Database\Eloquent\SoftDeletes;
8
use Illuminate\Support\Collection;
9
use Illuminate\Support\Facades\Auth;
10
use Illuminate\Support\Facades\Cache;
11
use Spatie\Searchable\Searchable;
0 ignored issues
show
Bug introduced by
The type Spatie\Searchable\Searchable was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Spatie\Searchable\SearchResult;
0 ignored issues
show
Bug introduced by
The type Spatie\Searchable\SearchResult was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Uccello\Core\Support\Traits\UccelloModule;
14
use Uccello\Core\Models\Group;
15
16
class User extends Authenticatable implements Searchable
17
{
18
    use SoftDeletes;
19
    use Notifiable;
20
    use UccelloModule;
21
22
    /**
23
     * The table associated with the model.
24
     *
25
     * @var string
26
     */
27
    protected $table = 'users';
28
29
    /**
30
     * The attributes that should be mutated to dates.
31
     *
32
     * @var array
33
     */
34
    protected $dates = [ 'deleted_at' ];
35
36
    /**
37
     * The attributes that should be casted to native types.
38
     *
39
     * @var array
40
     */
41
    protected $casts = [
42
        'avatar' => 'object',
43
    ];
44
45
    /**
46
     * The attributes that are mass assignable.
47
     *
48
     * @var array
49
     */
50
    protected $fillable = [
51
        'username',
52
        'name',
53
        'email',
54
        'password',
55
        'is_admin',
56
        'domain_id'
57
    ];
58
59
    /**
60
     * The attributes that should be hidden for arrays.
61
     *
62
     * @var array
63
     */
64
    protected $hidden = [
65
        'password', 'remember_token',
66
    ];
67
68
    /**
69
     * The accessors to append to the model's array form.
70
     *
71
     * @var array
72
     */
73
    protected $appends = [
74
        'recordLabel',
75
        'uuid',
76
    ];
77
78
    public $searchableType = 'user';
79
80
    public $searchableColumns = [
81
        'username',
82
        'name',
83
        'email'
84
    ];
85
86
    public function getSearchResult(): SearchResult
87
    {
88
        return new SearchResult(
89
            $this,
90
            $this->recordLabel
91
        );
92
    }
93
94
    /**
95
     * Scope a query to only include users with role in domain.
96
     *
97
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
98
     * @param  \Uccello\Core\Models\Domain|null $domain
99
     *
100
     *
101
     * @return \Illuminate\Database\Eloquent\Builder
102
     */
103
    public function scopeWithRoleInDomain($builder, ?Domain $domain, $withDescendants = false)
104
    {
105
        if (!$domain) {
106
            $domain = Domain::first();
107
        }
108
109
        // Check if user is admin or if he has at least a role on the domain
110
        // or on descendants domains if withDescendants option is on
111
        $builder->where('domain_id', $domain->id)
112
            ->orWhereIn($this->getKeyName(), function ($query) use ($domain, $withDescendants) {
113
                $privilegesTable = env('UCCELLO_TABLE_PREFIX', 'uccello_').'privileges';
114
115
                $query->select('user_id')
116
                    ->from($privilegesTable);
117
118
                // If necessary display all users with role defined in an ancestor domain
119
                $domainParentIds = $domain->findAncestors()->pluck('id');
120
                if (config('uccello.users.display_all_users_with_role')) {
121
                    $query->whereIn('domain_id', $domainParentIds);
122
                } else {
123
                    $query->where('domain_id', $domain->id);
124
                }
125
126
                if (Auth::user() && Auth::user()->canSeeDescendantsRecords($domain) && $withDescendants) {
0 ignored issues
show
Bug introduced by
The method canSeeDescendantsRecords() does not exist on Illuminate\Contracts\Auth\Authenticatable. It seems like you code against a sub-type of Illuminate\Contracts\Auth\Authenticatable such as Illuminate\Foundation\Auth\User. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

126
                if (Auth::user() && Auth::user()->/** @scrutinizer ignore-call */ canSeeDescendantsRecords($domain) && $withDescendants) {
Loading history...
127
                    $domainsIds = $domain->findDescendants()->pluck('id');
128
                    $query->orWhereIn('domain_id', $domainsIds);
129
                }
130
            });
131
132
        // If necessary display also all admin users
133
        if (config('uccello.users.display_all_admin_users')) {
134
            $builder->orWhere('is_admin', true);
135
        }
136
137
        return $builder;
138
    }
139
140
    public function domain()
141
    {
142
        return $this->belongsTo(Domain::class);
143
    }
144
145
    public function lastDomain()
146
    {
147
        return $this->belongsTo(Domain::class);
148
    }
149
150
    public function privileges()
151
    {
152
        return $this->hasMany(Privilege::class);
153
    }
154
155
    public function menus()
156
    {
157
        return $this->hasMany(Menu::class);
158
    }
159
160
    public function groups()
161
    {
162
        return $this->belongsToMany(Group::class, 'uccello_rl_groups_users');
163
    }
164
165
    public function userSettings()
166
    {
167
        return $this->hasOne(UserSettings::class, 'user_id');
168
    }
169
170
    /**
171
     * Returns record label
172
     *
173
     * @return string
174
     */
175
    public function getRecordLabelAttribute() : string
176
    {
177
        return trim($this->name) ?? $this->username;
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on Uccello\Core\Models\User. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
178
    }
179
180
    /**
181
     * Get avatar type
182
     *
183
     * @return string
184
     */
185
    public function getAvatarTypeAttribute() : string
186
    {
187
        return $this->avatar->type ?? 'initials';
0 ignored issues
show
Bug introduced by
The property type does not exist on string.
Loading history...
188
    }
189
190
    /**
191
     * Returns initals generated from the user name
192
     *
193
     * @return string
194
     */
195
    public function getInitialsAttribute() : string
196
    {
197
        $initials = "";
198
199
        $words = explode(" ", strtoupper($this->name));
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on Uccello\Core\Models\User. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
200
201
        $i = 0;
202
        foreach ($words as $w) {
203
            $initials .= $w[0];
204
            $i++;
205
206
            if ($i === 3) { // Maximum: 3 letters
207
                break;
208
            }
209
        }
210
211
        return $initials;
212
    }
213
214
    /**
215
     * Returns the image to use as the user avatar
216
     *
217
     * @return string
218
     */
219
    public function getImageAttribute() : string
220
    {
221
        $image = 'vendor/uccello/uccello/images/user-no-image.png';
222
223
        if ($this->avatarType === 'gravatar') {
224
            $image = 'https://www.gravatar.com/avatar/' . md5($this->email) . '?d=mm';
0 ignored issues
show
Bug introduced by
The property email does not seem to exist on Uccello\Core\Models\User. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
225
226
        } elseif ($this->avatarType === 'image' && !empty($this->avatar->path)) {
0 ignored issues
show
Bug introduced by
The property path does not exist on string.
Loading history...
227
            $image = $this->avatar->path;
228
        }
229
230
        return $image;
231
    }
232
233
    /**
234
     * Returns user settings
235
     *
236
     * @return \stdClass;
237
     */
238
    public function getSettingsAttribute()
239
    {
240
        return $this->userSettings->data ?? new \stdClass;
0 ignored issues
show
Bug introduced by
The property data does not seem to exist on Uccello\Core\Models\UserSettings. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
241
    }
242
243
    /**
244
     * Searches a settings by key and returns the current value
245
     *
246
     * @param string $key
247
     * @param mixed $defaultValue
248
     * @return \stdClass|null;
249
     */
250
    public function getSettings($key, $defaultValue=null) {
251
        return $this->userSettings->data->{$key} ?? $defaultValue;
0 ignored issues
show
Bug introduced by
The property data does not seem to exist on Uccello\Core\Models\UserSettings. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
252
    }
253
254
    /**
255
     * Returns user's roles on a domain
256
     *
257
     * @param \Uccello\Core\Models\Domain $domain
258
     * @param bool $withAncestors
259
     * @return \Illuminate\Support\Collection
260
     */
261
    public function rolesOnDomain($domain, $withAncestors = true) : Collection
262
    {
263
        // return Cache::remember('user_'.$this->id.'_domain_'.$domain->slug.'_roles', 600, function () use($domain) {
264
            $roles = collect();
265
266
            // Display all user's roles on ancestor domains
267
            if ($withAncestors && config('uccello.roles.display_ancestors_roles')) {
268
                $treeDomainsIds = $domain->findAncestors()->pluck('id');
269
            } else {
270
                $treeDomainsIds = collect([ $domain->id ]);
271
            }
272
273
            foreach ($treeDomainsIds as $treeDomainId) {
274
                $_domain = Domain::find($treeDomainId);
275
                foreach ($this->privileges->where('domain_id', $_domain->id) as $privilege) {
276
                    if (!$roles->contains($privilege->role)) {
277
                        $roles[ ] = $privilege->role;
278
                    }
279
                }
280
            }
281
282
            return $roles;
283
        // });
284
285
    }
286
287
    /**
288
     * Returns user's privileges on a domain
289
     *
290
     * @param \Uccello\Core\Models\Domain $domain
291
     * @param bool $withAncestors
292
     * @return \Illuminate\Support\Collection
293
     */
294
    public function privilegesOnDomain($domain, $withAncestors = true) : Collection
295
    {
296
        $privileges = collect();
297
298
        // Display all user's roles on ancestor domains
299
        if ($withAncestors) {
300
            $treeDomainsIds = $domain->findAncestors()->pluck('id');
301
        } else {
302
            $treeDomainsIds = collect([ $domain->id ]);
303
        }
304
305
        foreach ($treeDomainsIds as $treeDomainId) {
306
            $_domain = Domain::find($treeDomainId);
307
308
            $_privileges = $this->privileges()
309
                ->where('domain_id', $_domain->id)
310
                ->with('role')
311
                ->with('domain')
312
                ->get();
313
314
            foreach ($_privileges as $privilege) {
315
                if (!$privileges->contains($privilege)) {
316
                    $privileges[ ] = $privilege;
317
                }
318
            }
319
        }
320
321
        return $privileges;
322
    }
323
324
    /**
325
     * Returns ids of user's roles on a domain
326
     *
327
     * @param \Uccello\Core\Models\Domain $domain
328
     * @return \Illuminate\Support\Collection
329
     */
330
    public function subordonateRolesIdsOnDomain($domain) : Collection
331
    {
332
        $roles = $this->rolesOnDomain($domain);
333
334
        $subordonateRoles = collect();
335
        foreach ($roles as $role) {
336
            $subordonateRoles = $subordonateRoles->merge($role->findDescendants()->pluck('id'));
337
        }
338
339
        return $subordonateRoles;
340
    }
341
342
    /**
343
     * Check if the user has at least a role on a domain
344
     *
345
     * @param \Uccello\Core\Models\Domain $domain
346
     * @return boolean
347
     */
348
    public function hasRoleOnDomain($domain) : bool {
349
        if ($this->is_admin) {
350
            return true;
351
        }
352
353
        return $this->rolesOnDomain($domain)->count() > 0;
354
    }
355
356
    /**
357
     * Check if the user has at least a role on a domain or its descendants
358
     *
359
     * @param \Uccello\Core\Models\Domain $domain
360
     * @return boolean
361
     */
362
    public function hasRoleOnDescendantDomain(Domain $domain) : bool {
363
        if ($this->is_admin) {
364
            return true;
365
        }
366
367
        $hasRole = false;
368
369
        $descendants = Cache::remember('domain_'.$domain->slug.'_descendants', 600, function () use($domain) {
370
            return $domain->findDescendants()->get();
371
        });
372
373
        foreach ($descendants as $descendant) {
374
            if ($this->hasRoleOnDomain($descendant)) {
375
                $hasRole = true;
376
                break;
377
            }
378
        }
379
380
        return $hasRole;
381
    }
382
383
    /**
384
     * Returns all user capabilities on a module in a domain.
385
     * If the user has a capability in one of the parents of a domain, he also has it in that domain.
386
     *
387
     * @param \Uccello\Core\Models\Domain $domain
388
     * @param \Uccello\Core\Models\Module $module
389
     * @return \Illuminate\Support\Collection
390
     */
391
    public function capabilitiesOnModule(Domain $domain, Module $module) : Collection
392
    {
393
        $keyName = 'user_'.$this->id.'_'.$domain->slug.'_'.$module->name.'_capabilities';
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on Uccello\Core\Models\Module. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
394
395
        return Cache::remember($keyName, 600, function () use($domain, $module) {
396
            $capabilities = collect();
397
398
            // Get the domain and all its parents
399
            $domainParents = $domain->findAncestors()->get();
400
401
            // Get user privileges on each domain
402
            foreach ($domainParents as $_domain) {
403
                $privileges = $this->privileges->where('domain_id', $_domain->id);
404
405
                foreach ($privileges as $privilege) {
406
407
                    foreach ($privilege->role->profiles as $profile) {
408
                        $capabilities = $capabilities->merge($profile->capabilitiesOnModule($module));
409
                    }
410
                }
411
            }
412
413
            return $capabilities;
414
        });
415
    }
416
417
    /**
418
     * Checks if the user has a capability on a module in a domain.
419
     *
420
     * @param string $capabilityName
421
     * @param \Uccello\Core\Models\Domain $domain
422
     * @param \Uccello\Core\Models\Module $module
423
     * @return boolean
424
     */
425
    public function hasCapabilityOnModule(string $capabilityName, Domain $domain, Module $module) : bool
426
    {
427
        $capability = capability($capabilityName);
428
429
        $userCapabilities = $this->capabilitiesOnModule($domain, $module);
430
431
        return $this->is_admin || $userCapabilities->contains($capability);
432
    }
433
434
    /**
435
     * Checks if the user can access to settings panel.
436
     * Checks if the user has at least one admin capability on admin modules in a domain.
437
     *
438
     * @param \Uccello\Core\Models\Domain|null $domain
439
     * @return boolean
440
     */
441
    public function canAccessToSettingsPanel(?Domain $domain) : bool
442
    {
443
        if (empty($domain)) {
444
            $domain = Domain::first();
445
        }
446
447
        $keyName = 'user_'.$this->id.'_'.$domain->slug.'_can_access_to_settings_panel';
448
449
        return Cache::remember($keyName, 600, function () use($domain) {
450
451
            $hasCapability = false;
452
453
            foreach (Module::all() as $module) {
454
                if ($module->isAdminModule() === true && $this->canAdmin($domain, $module)) {
455
                    $hasCapability = true;
456
                    break;
457
                }
458
            }
459
460
            return $hasCapability;
461
        });
462
    }
463
464
    /**
465
     * Checks if the user can admin a module in a domain.
466
     *
467
     * @param \Uccello\Core\Models\Domain $domain
468
     * @param \Uccello\Core\Models\Module $module
469
     * @return boolean
470
     */
471
    public function canAdmin(Domain $domain, Module $module) : bool
472
    {
473
        return $this->hasCapabilityOnModule('admin', $domain, $module);
474
    }
475
476
    /**
477
     * Checks if the user can create a module in a domain.
478
     *
479
     * @param \Uccello\Core\Models\Domain $domain
480
     * @param \Uccello\Core\Models\Module $module
481
     * @return boolean
482
     */
483
    public function canCreate(Domain $domain, Module $module) : bool
484
    {
485
        return $this->hasCapabilityOnModule('create', $domain, $module) || ($module->isAdminModule() && $this->canAdmin($domain, $module));
486
    }
487
488
    /**
489
     * Checks if the user can retrieve a module in a domain.
490
     *
491
     * @param \Uccello\Core\Models\Domain $domain
492
     * @param \Uccello\Core\Models\Module $module
493
     * @return boolean
494
     */
495
    public function canRetrieve(Domain $domain, Module $module) : bool
496
    {
497
        return $this->hasCapabilityOnModule('retrieve', $domain, $module) || ($module->isAdminModule() && $this->canAdmin($domain, $module));
498
    }
499
500
    /**
501
     * Checks if the user can update a module in a domain.
502
     *
503
     * @param \Uccello\Core\Models\Domain $domain
504
     * @param \Uccello\Core\Models\Module $module
505
     * @return boolean
506
     */
507
    public function canUpdate(Domain $domain, Module $module) : bool
508
    {
509
        return $this->hasCapabilityOnModule('update', $domain, $module) || ($module->isAdminModule() && $this->canAdmin($domain, $module));
510
    }
511
512
    /**
513
     * Checks if the user can delete a module in a domain.
514
     *
515
     * @param \Uccello\Core\Models\Domain $domain
516
     * @param \Uccello\Core\Models\Module $module
517
     * @return boolean
518
     */
519
    public function canDelete(Domain $domain, Module $module) : bool
520
    {
521
        return $this->hasCapabilityOnModule('delete', $domain, $module) || ($module->isAdminModule() && $this->canAdmin($domain, $module));
522
    }
523
524
    /**
525
     * Checks if the user can create by API a module in a domain.
526
     *
527
     * @param \Uccello\Core\Models\Domain $domain
528
     * @param \Uccello\Core\Models\Module $module
529
     * @return boolean
530
     */
531
    public function canCreateByApi(Domain $domain, Module $module) : bool
532
    {
533
        return $this->hasCapabilityOnModule('api-create', $domain, $module) || ($module->isAdminModule() && $this->canAdmin($domain, $module));
534
    }
535
536
    /**
537
     * Checks if the user can retrieve by API a module in a domain.
538
     *
539
     * @param \Uccello\Core\Models\Domain $domain
540
     * @param \Uccello\Core\Models\Module $module
541
     * @return boolean
542
     */
543
    public function canRetrieveByApi(Domain $domain, Module $module) : bool
544
    {
545
        return $this->hasCapabilityOnModule('api-retrieve', $domain, $module) || ($module->isAdminModule() && $this->canAdmin($domain, $module));
546
    }
547
548
    /**
549
     * Checks if the user can update by API a module in a domain.
550
     *
551
     * @param \Uccello\Core\Models\Domain $domain
552
     * @param \Uccello\Core\Models\Module $module
553
     * @return boolean
554
     */
555
    public function canUpdateByApi(Domain $domain, Module $module) : bool
556
    {
557
        return $this->hasCapabilityOnModule('api-update', $domain, $module) || ($module->isAdminModule() && $this->canAdmin($domain, $module));
558
    }
559
560
    /**
561
     * Checks if the user can delete by API a module in a domain.
562
     *
563
     * @param \Uccello\Core\Models\Domain $domain
564
     * @param \Uccello\Core\Models\Module $module
565
     * @return boolean
566
     */
567
    public function canDeleteByApi(Domain $domain, Module $module) : bool
568
    {
569
        return $this->hasCapabilityOnModule('api-delete', $domain, $module) || ($module->isAdminModule() && $this->canAdmin($domain, $module));
570
    }
571
572
    /**
573
     * Checks if the user has almost a role allowing to view data transversally
574
     *
575
     * @param \Uccello\Core\Models\Domain $domain
576
     * @return boolean
577
     */
578
    public function canSeeDescendantsRecords(Domain $domain) : bool
579
    {
580
        $allowed = false;
581
582
        if ($this->is_admin) {
583
            $allowed = true;
584
        } else {
585
            $roles = $this->rolesOnDomain($domain);
586
            foreach ($roles as $role) {
587
                if ($role->see_descendants_records) {
588
                    $allowed = true;
589
                    break;
590
                }
591
            }
592
        }
593
594
        return $allowed;
595
    }
596
597
    public function getAllowedGroupUuids()
598
    {
599
        // Use cache
600
        $allowedGroups = Cache::rememberForever(
601
            'allowed_groups_for_' . ($this->is_admin ? 'admin' : $this->getKey()),
602
            function () {
603
                return $this->getAllowedGroupUuidsProcess();
604
            }
605
        );
606
607
        return $allowedGroups;
608
    }
609
610
    public function getAllowedGroupsAndUsers($addUsers = true)
611
    {
612
        // Use cache
613
        $allowedGroupsAndUsers = Cache::rememberForever(
614
            'allowed_group_users_for_' . ($addUsers ? 'u_' : '') . ($this->is_admin ? 'admin' : $this->getKey()),
615
            function () use ($addUsers) {
616
                return $this->getAllowedGroupsAndUsersProcess($addUsers);
617
            }
618
        );
619
620
        return $allowedGroupsAndUsers;
621
    }
622
623
    protected function getAllowedGroupUuidsProcess()
624
    {
625
        $allowedUserUuids = collect([$this->uuid]);
626
627
        if ($this->is_admin) {
628
            $groups = Group::all();
629
        } else {
630
            $groups = [];
631
            $users = [];
632
633
            foreach ($this->groups as $group) {
634
                $groups[$group->uuid] = $group;
635
            };
636
637
            $this->addRecursiveChildrenGroups($groups, $users, $groups, false);
638
639
            $groups = collect($groups);
640
        }
641
642
        foreach ($groups as $uuid => $group) {
643
            $allowedUserUuids[] = $uuid;
644
        }
645
646
        return $allowedUserUuids;
647
    }
648
649
    protected function addRecursiveChildrenGroups(&$groups, &$users, $searchGroups, $addUsers = false)
650
    {
651
        foreach ($searchGroups as $uuid => $searchGroup) {
652
            $searchChildrenGroups = [];
653
654
            foreach ($searchGroup->childrenGroups as $childrenGroup) {
655
                if (empty($groups[$childrenGroup->uuid])) {
656
                    $groups[$childrenGroup->uuid] = $childrenGroup;
657
                    $searchChildrenGroups[$childrenGroup->uuid] = $childrenGroup;
658
                }
659
660
                if($addUsers)
661
                {
662
                    foreach ($childrenGroup->users as $user) {
663
                        if (empty($users[$user->uuid])) {
664
                            $users[$user->uuid] = $user;
665
                        }
666
                    }
667
                }
668
            }
669
670
            $this->addRecursiveChildrenGroups($groups, $users, $searchChildrenGroups, $addUsers);
671
        }
672
    }
673
674
    protected function getAllowedGroupsAndUsersProcess($addUsers = true)
675
    {
676
        $allowedUserUuids = collect([[
677
            'uuid' => $this->uuid,
678
            'recordLabel' => uctrans('me', $this->module)
679
        ]]);
680
681
        // if ($this->is_admin) {
682
            $groups = Group::orderBy('name')->get();
683
            $users  = \App\User::orderBy('name')->get();
0 ignored issues
show
Bug introduced by
The type App\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
684
        // } else {
685
        //     $groups = [];
686
        //     $users = [];
687
688
        //     foreach ($this->groups as $group) {
689
        //         $groups[$group->uuid] = $group;
690
691
        //         if($addUsers)
692
        //         {
693
        //             foreach ($group->users as $user) {
694
        //                 if (empty($users[$user->uuid])) {
695
        //                     $users[$user->uuid] = $user;
696
        //                 }
697
        //             }
698
        //         }
699
        //     };
700
701
        //     $this->addRecursiveChildrenGroups($groups, $users, $groups, $addUsers);
702
703
        //     $groups = collect($groups)->sortBy('name');
704
        //     $users  = collect($users)->sortBy('name');
705
        // }
706
707
        foreach ($groups as $uuid => $group) {
708
            $allowedUserUuids[] = [
709
                'uuid' => $group->uuid,
710
                'recordLabel' => $group->recordLabel
711
            ];
712
        }
713
714
        foreach ($users as $uuid => $user) {
715
            if($user->getKey() != $this->getKey()) {
716
                $allowedUserUuids[] = [
717
                    'uuid' => $user->uuid,
718
                    'recordLabel' => $user->recordLabel
719
                ];
720
            }
721
        }
722
723
        return $allowedUserUuids;
724
    }
725
}
726