RecommendationPolicy
extends BasePolicy
in package
Authorization policy for Recommendation entities in the Awards plugin.
Implements state machine management, workflow authorization, and dynamic approval level validation. Supports dynamic canApproveLevel* methods based on award levels.
Tags
Table of Contents
Methods
- __call() : bool
- Handle dynamic approval authority methods (canApproveLevel*).
- before() : bool|null
- Check if $user is a super user and can skip auth with an auto True
- canAdd() : bool
- Check if user can add new recommendations.
- canAddNote() : bool
- Check if user can add notes to recommendations.
- canDelete() : bool
- Check if $user can delete RolesPermissions
- canEdit() : bool
- Check if $user can edit RolesPermissions
- canExport() : bool
- Check if user can export recommendation data.
- canGridData() : bool
- Check if $user can view role
- canIndex() : bool
- Check if $user can view role
- canUpdateStates() : bool
- Check if user can update recommendation states in bulk.
- canUseBoard() : bool
- Check if user can access the recommendation board interface.
- canView() : bool
- Check if $user can view RolesPermissions
- canViewEventRecommendations() : bool
- Check if user can view recommendations for a specific event.
- canViewGatheringRecommendations() : bool
- Check if user can view recommendations for a specific gathering.
- canViewHidden() : bool
- Check if user can view hidden recommendations.
- canViewPrivateNotes() : bool
- Check if user can view private notes on recommendations.
- canViewSubmittedByMember() : bool
- Check if user can view recommendations they submitted.
- canViewSubmittedForMember() : bool
- Check if user can view recommendations submitted for a specific member.
- getDynamicMethods() : array<string|int, mixed>
- Get names of dynamically generated approval methods.
- scopeIndex() : mixed
- Apply scope for index action.
- _getBranchIdsForPolicy() : array<string|int, mixed>|null
- Check if $user can view hidden
- _getPermissions() : bool
- Check if $user can view hidden
- _getPolicies() : bool
- Check if $user can view hidden
- _hasPolicy() : bool
- Check if $user can view hidden
- _hasPolicyForUrl() : bool
- Check if $user can view hidden
- _isSuperUser() : bool
- Check if $user is a super user
- canManageRecommendationMember() : bool
- Determine whether the user can manage recommendation actions for a member.
Methods
__call()
Handle dynamic approval authority methods (canApproveLevel*).
public
__call(string $name, array<string|int, mixed> $arguments) : bool
Resolves level-specific approval methods dynamically based on award levels.
Parameters
- $name : string
-
The method name (e.g., 'canApproveLevelAoA')
- $arguments : array<string|int, mixed>
-
[$user, $entity, ...args]
Tags
Return values
bool —True if user has approval authority for the level
before()
Check if $user is a super user and can skip auth with an auto True
public
before(KmpIdentityInterface $user, mixed $resource, string $action) : bool|null
Parameters
- $user : KmpIdentityInterface
-
The user.
- $resource : mixed
-
The resource.
- $action : string
-
The action.
Return values
bool|nullcanAdd()
Check if user can add new recommendations.
public
canAdd(KmpIdentityInterface $user, BaseEntity|Table $entity, mixed ...$optionalArgs) : bool
Open authorization - any authenticated user can submit recommendations.
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity|Table
-
The recommendation context
- $optionalArgs : mixed
-
Additional authorization context
Return values
bool —Always true for open submission
canAddNote()
Check if user can add notes to recommendations.
public
canAddNote(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $optionalArgs : mixed
-
Additional authorization context
Return values
bool —True if authorized
canDelete()
Check if $user can delete RolesPermissions
public
canDelete(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity
- $optionalArgs : mixed
Return values
boolcanEdit()
Check if $user can edit RolesPermissions
public
canEdit(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity
- $optionalArgs : mixed
Return values
boolcanExport()
Check if user can export recommendation data.
public
canExport(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$args) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $args : mixed
-
Additional authorization context
Return values
bool —True if authorized
canGridData()
Check if $user can view role
public
canGridData(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity
- $optionalArgs : mixed
Return values
boolcanIndex()
Check if $user can view role
public
canIndex(KmpIdentityInterface $user, BaseEntity|Table $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity|Table
- $optionalArgs : mixed
Return values
boolcanUpdateStates()
Check if user can update recommendation states in bulk.
public
canUpdateStates(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $optionalArgs : mixed
-
Additional authorization context
Return values
bool —True if authorized
canUseBoard()
Check if user can access the recommendation board interface.
public
canUseBoard(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$args) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $args : mixed
-
Additional authorization context
Return values
bool —True if authorized
canView()
Check if $user can view RolesPermissions
public
canView(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $entity : BaseEntity
- $optionalArgs : mixed
Return values
boolcanViewEventRecommendations()
Check if user can view recommendations for a specific event.
public
canViewEventRecommendations(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$args) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $args : mixed
-
Additional authorization context
Return values
bool —True if authorized
canViewGatheringRecommendations()
Check if user can view recommendations for a specific gathering.
public
canViewGatheringRecommendations(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$args) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $args : mixed
-
Additional authorization context (typically gathering entity)
Return values
bool —True if authorized
canViewHidden()
Check if user can view hidden recommendations.
public
canViewHidden(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $optionalArgs : mixed
-
Additional authorization context
Return values
bool —True if authorized
canViewPrivateNotes()
Check if user can view private notes on recommendations.
public
canViewPrivateNotes(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$optionalArgs) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $optionalArgs : mixed
-
Additional authorization context
Return values
bool —True if authorized
canViewSubmittedByMember()
Check if user can view recommendations they submitted.
public
canViewSubmittedByMember(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$args) : bool
Grants direct access if user is the requester, otherwise delegates to permission check.
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $args : mixed
-
Additional authorization context
Return values
bool —True if authorized
canViewSubmittedForMember()
Check if user can view recommendations submitted for a specific member.
public
canViewSubmittedForMember(KmpIdentityInterface $user, BaseEntity $entity, mixed ...$args) : bool
Parameters
- $user : KmpIdentityInterface
-
The authenticated user
- $entity : BaseEntity
-
The recommendation entity
- $args : mixed
-
Additional authorization context
Return values
bool —True if authorized
getDynamicMethods()
Get names of dynamically generated approval methods.
public
static getDynamicMethods() : array<string|int, mixed>
Returns canApproveLevel* method names based on current award levels.
Return values
array<string|int, mixed> —List of dynamic method names
scopeIndex()
Apply scope for index action.
public
scopeIndex(KmpIdentityInterface $user, mixed $query) : mixed
Parameters
- $user : KmpIdentityInterface
- $query : mixed
_getBranchIdsForPolicy()
Check if $user can view hidden
protected
_getBranchIdsForPolicy(KmpIdentityInterface $user, string $policyMethod) : array<string|int, mixed>|null
Parameters
- $user : KmpIdentityInterface
-
The user.
- $policyMethod : string
Return values
array<string|int, mixed>|null_getPermissions()
Check if $user can view hidden
protected
_getPermissions(KmpIdentityInterface $user) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
Return values
bool_getPolicies()
Check if $user can view hidden
protected
_getPolicies(KmpIdentityInterface $user) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
Return values
bool_hasPolicy()
Check if $user can view hidden
protected
_hasPolicy(KmpIdentityInterface $user, string $policyMethod, BaseEntity|Table $entity[, int|null $branchId = null ][, mixed $grantSource = null ]) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $policyMethod : string
- $entity : BaseEntity|Table
- $branchId : int|null = null
- $grantSource : mixed = null
Return values
bool_hasPolicyForUrl()
Check if $user can view hidden
protected
_hasPolicyForUrl(KmpIdentityInterface $user, string $policyMethod, array<string|int, mixed> $urlProps[, int|null $branchId = null ][, mixed $grantSource = null ]) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
- $policyMethod : string
- $urlProps : array<string|int, mixed>
- $branchId : int|null = null
- $grantSource : mixed = null
Return values
bool_isSuperUser()
Check if $user is a super user
protected
_isSuperUser(KmpIdentityInterface $user) : bool
Parameters
- $user : KmpIdentityInterface
-
The user.
Return values
boolcanManageRecommendationMember()
Determine whether the user can manage recommendation actions for a member.
protected
canManageRecommendationMember(KmpIdentityInterface $user, int $memberId) : bool
Allows self or parent-of-minor access.
Parameters
- $user : KmpIdentityInterface
- $memberId : int