Add a new twig function for checking if a user is an organisation registrant (the only one able to cancel a register request)

This commit is contained in:
2022-02-15 17:57:36 +00:00
parent 108a34481e
commit 2ba0257b6e

View File

@@ -57,6 +57,7 @@ class OrganisationsExtension extends AbstractExtension implements GlobalsInterfa
return Capsule::table('organisation_members')
->where('user_id', $currentUser->id)
->where('organisation_id', $organisation->id)
->where('flag_approved', true)
->count() > 0;
}),
new TwigFunction('isOrganisationAdmin', function ($organisation) {
@@ -66,8 +67,13 @@ class OrganisationsExtension extends AbstractExtension implements GlobalsInterfa
->where('user_id', $currentUser->id)
->where('organisation_id', $organisation->id)
->where('flag_admin', true)
->where('flag_approved', true)
->count() > 0;
}),
new TwigFunction('isOrganisationRegistrant', function ($organisation) {
$currentUser = $this->services->currentUser;
return $organisation->registrant_id == $currentUser->id;
}),
new TwigFunction('hasRole', function ($roleSlug) {
$currentUser = $this->services->currentUser;
return $currentUser->roles()->where('slug', $roleSlug)->count() > 0;