ACLPermissionTrait uses trait:short
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.
- addDiscountPriceSet() : void
- Add a discount price set to the given event.
- eventCreate() : array<string|int, mixed>
- Create an Event.
- 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.
- eventCreatePaid() : array<string|int, mixed>
- Create a paid event.
- eventCreateUnpaid() : array<string|int, mixed>
- Create an unpaid event.
- getEvent() : array<string|int, mixed>
- This retrieves the values used to create the event.
- getEventExampleData() : array<string|int, mixed>
- Get example data with which to create the event.
- getEventID() : int
- Get the event id of the event created in set up.
- getEventValue() : mixed|null
- Get a value from an event used in setup.
- getPriceFieldOptions() : array<string|int, array<string|int, mixed>>
- Get the options for the price set.
- updateEvent() : void
- Update an event.
- addProfilesToEvent() : void
- Add profiles to the event.
- createEventProfile() : void
- Create a profile attached to an event.
- eventCreatePriceSet() : void
- Create a price set for an event.
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
addDiscountPriceSet()
Add a discount price set to the given event.
public
addDiscountPriceSet([string $eventIdentifier = 'PaidEvent' ][, array<string|int, mixed> $discountParameters = [] ][, array<string|int, mixed> $priceSetParameters = [] ][, string $identifier = 'discount' ][, float $fraction = 0.5 ]) : void
Parameters
- $eventIdentifier : string = 'PaidEvent'
- $discountParameters : array<string|int, mixed> = []
- $priceSetParameters : array<string|int, mixed> = []
- $identifier : string = 'discount'
- $fraction : float = 0.5
Tags
eventCreate()
Create an Event.
public
eventCreate([array<string|int, mixed> $params = [] ][, string $identifier = 'event' ]) : array<string|int, mixed>
Note this is not expected to be called directly - call
- eventCreatePaid
- eventCreateUnpaid
Parameters
- $params : array<string|int, mixed> = []
-
Name-value pair for an event.
- $identifier : string = 'event'
Return values
array<string|int, mixed>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
Tags
eventCreatePaid()
Create a paid event.
protected
eventCreatePaid([array<string|int, mixed> $eventParameters = [] ][, array<string|int, mixed> $priceSetParameters = [] ][, string $identifier = 'PaidEvent' ]) : array<string|int, mixed>
Parameters
- $eventParameters : array<string|int, mixed> = []
-
Values to
- $priceSetParameters : array<string|int, mixed> = []
- $identifier : string = 'PaidEvent'
-
Index for storing event ID in ids array.
Return values
array<string|int, mixed>eventCreateUnpaid()
Create an unpaid event.
protected
eventCreateUnpaid([array<string|int, mixed> $eventParameters = [] ][, string $identifier = 'event' ]) : array<string|int, mixed>
Parameters
- $eventParameters : array<string|int, mixed> = []
-
Values to
- $identifier : string = 'event'
-
Index for storing event ID in ids array.
Return values
array<string|int, mixed>getEvent()
This retrieves the values used to create the event.
protected
getEvent(string $identifier) : array<string|int, mixed>
Note this does not actually retrieve the event from the database although it arguably might be more useful.
Parameters
- $identifier : string
Return values
array<string|int, mixed>getEventExampleData()
Get example data with which to create the event.
protected
getEventExampleData([string $name = 'PaidEvent' ]) : array<string|int, mixed>
Parameters
- $name : string = 'PaidEvent'
Return values
array<string|int, mixed>getEventID()
Get the event id of the event created in set up.
protected
getEventID([string $identifier = 'event' ]) : int
If only one has been created it will be selected. Otherwise you should pass in the appropriate identifier.
Parameters
- $identifier : string = 'event'
Return values
intgetEventValue()
Get a value from an event used in setup.
protected
getEventValue(string $value, string $identifier) : mixed|null
Parameters
- $value : string
- $identifier : string
Return values
mixed|nullgetPriceFieldOptions()
Get the options for the price set.
protected
getPriceFieldOptions([string $identifier = 'PaidEvent' ]) : array<string|int, array<string|int, mixed>>
Parameters
- $identifier : string = 'PaidEvent'
-
Optional string if we want to specify different options. This is not currently used but is consistent with our other functions and would allow over-riding.
Return values
array<string|int, array<string|int, mixed>>updateEvent()
Update an event.
protected
updateEvent([array<string|int, mixed> $eventParameters = [] ][, string $identifier = 'event' ]) : void
Parameters
- $eventParameters : array<string|int, mixed> = []
-
Values to
- $identifier : string = 'event'
-
Index for storing event ID in ids array.
addProfilesToEvent()
Add profiles to the event.
private
addProfilesToEvent([string $identifier = 'event' ]) : void
This function is designed to reflect the normal use case where events do have profiles.
Note if any classes do not want profiles, or want something different, the thinking is they should override this. Once that arises we can review making it protected rather than private & checking we are happy with the signature.
Parameters
- $identifier : string = 'event'
Tags
createEventProfile()
Create a profile attached to an event.
private
createEventProfile(array<string|int, mixed> $profile, string $identifier[, bool $isAdditional = false ]) : void
Parameters
- $profile : array<string|int, mixed>
- $identifier : string
- $isAdditional : bool = false
Tags
eventCreatePriceSet()
Create a price set for an event.
private
eventCreatePriceSet(array<string|int, mixed> $priceSetParameters, string $identifier) : void
Parameters
- $priceSetParameters : array<string|int, mixed>
- $identifier : string