2024-11-22 07:27:11 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
Kirby::plugin('adrienpayet/pdc-authorized-projects', [
|
|
|
|
|
'userMethods' => [
|
|
|
|
|
'currentProjects' => function() {
|
2026-03-04 14:44:00 +01:00
|
|
|
$listed = page('projects')->children()->listed();
|
|
|
|
|
if ($this->role() == 'admin' && $this->hasNoAssignedProjects()) {
|
|
|
|
|
return $listed;
|
2024-11-22 07:27:11 +01:00
|
|
|
}
|
2026-03-04 14:44:00 +01:00
|
|
|
return $listed->filter(fn($project) => $project->users()->toUsers()->has($this));
|
2024-11-22 07:27:11 +01:00
|
|
|
},
|
|
|
|
|
'archivedProjects' => function() {
|
2026-03-04 14:44:00 +01:00
|
|
|
$unlisted = page('projects')->children()->unlisted();
|
|
|
|
|
if ($this->role() == 'admin' && $this->hasNoAssignedProjects()) {
|
|
|
|
|
return $unlisted;
|
2024-11-22 07:27:11 +01:00
|
|
|
}
|
2026-03-04 14:44:00 +01:00
|
|
|
return $unlisted->filter(fn($project) => $project->users()->toUsers()->has($this));
|
|
|
|
|
},
|
|
|
|
|
'hasNoAssignedProjects' => function() {
|
|
|
|
|
return page('projects')->children()->filter(fn($p) => $p->users()->toUsers()->has($this))->isEmpty();
|
2024-11-22 07:27:11 +01:00
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
]);
|