ACLPermissionTrait
Trait Civi\Test\ACLPermissionTrait.
Trait for working with ACLs in tests
Table of Contents
Properties
- $allowedContactId : int
- ContactID of allowed Contact
- $allowedContacts : array<string|int, mixed>
- Array of allowed contactIds
- $scenarioIDs : array<string|int, mixed>
- Ids created for the scenario in use.
Methods
- aclWhereGreaterThan() : void
- Results after the allowedContact are returned.
- aclWhereHookAllResults() : void
- All results returned.
- aclWhereHookNoResults() : void
- No results returned.
- aclWhereMultipleContacts() : mixed
- Only specified contact returned.
- aclWhereOnlyOne() : void
- Only specified contact returned.
- aclWhereOnlySecond() : void
- All but first results returned.
- setupCoreACLPermittedAcl() : void
- Set up a core ACL.
- setupScenarioCoreACLEveryonePermittedToEvent() : void
- Set up a scenario where everyone can access the permissioned group.
- setupScenarioCoreACLEveryonePermittedToGroup() : void
- Set up a scenario where everyone can access the permissioned group.
- cleanupCachedPermissions() : void
- Clean up places where permissions get cached.
Properties
$allowedContactId
ContactID of allowed Contact
protected
int
$allowedContactId
= 0
$allowedContacts
Array of allowed contactIds
protected
array<string|int, mixed>
$allowedContacts
= []
$scenarioIDs
Ids created for the scenario in use.
protected
array<string|int, mixed>
$scenarioIDs
= []
Methods
aclWhereGreaterThan()
Results after the allowedContact are returned.
public
aclWhereGreaterThan(string $type, array<string|int, mixed> &$tables, array<string|int, mixed> &$whereTables, int &$contactID, string|null &$where) : void
Parameters
- $type : string
- $tables : array<string|int, mixed>
- $whereTables : array<string|int, mixed>
- $contactID : int
- $where : string|null
Tags
aclWhereHookAllResults()
All results returned.
public
aclWhereHookAllResults(string $type, array<string|int, mixed> &$tables, array<string|int, mixed> &$whereTables, int &$contactID, string|null &$where) : void
Parameters
- $type : string
- $tables : array<string|int, mixed>
- $whereTables : array<string|int, mixed>
- $contactID : int
- $where : string|null
Tags
aclWhereHookNoResults()
No results returned.
public
aclWhereHookNoResults(string $type, array<string|int, mixed> &$tables, array<string|int, mixed> &$whereTables, int &$contactID, string|null &$where) : void
Parameters
- $type : string
- $tables : array<string|int, mixed>
- $whereTables : array<string|int, mixed>
- $contactID : int
- $where : string|null
Tags
aclWhereMultipleContacts()
Only specified contact returned.
public
aclWhereMultipleContacts(mixed $type, mixed &$tables, mixed &$whereTables, mixed &$contactID, mixed &$where) : mixed
Parameters
- $type : mixed
- $tables : mixed
- $whereTables : mixed
- $contactID : mixed
- $where : mixed
Tags
aclWhereOnlyOne()
Only specified contact returned.
public
aclWhereOnlyOne(string $type, array<string|int, mixed> &$tables, array<string|int, mixed> &$whereTables, int &$contactID, string|null &$where) : void
Parameters
- $type : string
- $tables : array<string|int, mixed>
- $whereTables : array<string|int, mixed>
- $contactID : int
- $where : string|null
Tags
aclWhereOnlySecond()
All but first results returned.
public
aclWhereOnlySecond(string $type, array<string|int, mixed> &$tables, array<string|int, mixed> &$whereTables, int &$contactID, string|null &$where) : void
Parameters
- $type : string
- $tables : array<string|int, mixed>
- $whereTables : array<string|int, mixed>
- $contactID : int
- $where : string|null
Tags
setupCoreACLPermittedAcl()
Set up a core ACL.
public
setupCoreACLPermittedAcl([array<string|int, mixed> $permissionedEntities = [] ][, string|int $groupAllowedAccess = 'Everyone' ][, string $operation = 'View' ][, string $entity = 'Group' ]) : void
It is recommended that this helper function is accessed through a scenario function.
Parameters
- $permissionedEntities : array<string|int, mixed> = []
-
Array of groups for whom ACLs enable access.
- $groupAllowedAccess : string|int = 'Everyone'
-
Group permitted to access the permissioned Group An ID of 0 means that 'Everyone' can access the group.
- $operation : string = 'View'
-
View|Edit|Create|Delete|Search|All
- $entity : string = 'Group'
-
Group|CustomGroup|Profile|Event
setupScenarioCoreACLEveryonePermittedToEvent()
Set up a scenario where everyone can access the permissioned group.
public
setupScenarioCoreACLEveryonePermittedToEvent() : void
A scenario in this class involves multiple defined assets. In this case we create
- a group to which the everyone has permission
- a contact in the group
- a contact not in the group
These are arrayed as follows $this->scenarioIDs['Contact'] = ['permitted_contact' => x, 'non_permitted_contact' => y] $this->scenarioIDs['Group'] = ['permitted_group' => x]
setupScenarioCoreACLEveryonePermittedToGroup()
Set up a scenario where everyone can access the permissioned group.
public
setupScenarioCoreACLEveryonePermittedToGroup() : void
A scenario in this class involves multiple defined assets. In this case we create
- a group to which the everyone has permission
- a contact in the group
- a contact not in the group
These are arrayed as follows $this->scenarioIDs['Contact'] = ['permitted_contact' => x, 'non_permitted_contact' => y] $this->scenarioIDs['Group'] = ['permitted_group' => x]
cleanupCachedPermissions()
Clean up places where permissions get cached.
protected
cleanupCachedPermissions() : void