ActionMapping
extends MappingBase
in package
uses
SavedSearchInspectorTrait
This enables scheduled-reminders to be run based on a SavedSearch.
Table of Contents
Properties
- $_apiParams : array{select: array, where: array, having: array, orderBy: array, limit: int, offset: int, checkPermissions: bool, debug: bool}
- $savedSearch : string|array<string|int, mixed>
- Either the name of the savedSearch or an array containing the savedSearch definition (for preview mode)
- $_joinMap : array<string|int, mixed>
- $_searchEntityFields : array<string|int, mixed>
- $_selectClause : array<string|int, mixed>
- $_selectQuery : Api4SelectQuery
Methods
- applies() : bool
- checkAccess() : bool
- Check if the user has permission to create a reminder for given `entity_value`.
- createQuery() : CRM_Utils_SQL_Select
- Generate a query to locate recipients.
- getAlternateRecipients() : array<string|int, mixed>|null
- getBccRecipients() : array<string|int, mixed>|null
- getDateFields() : array<string|int, mixed>
- Get option list for `start_action_date` & `end_date` fields.
- getEntity() : string
- Deprecated ambiguously-named function.
- getEntityName() : string
- Main entity name e.g. `Activity`
- getEntityTable() : string
- Name of the table belonging to the main entity e.g. `civicrm_activity`
- getId() : string|int
- Unique identifier of this mapping type.
- getLabel() : string
- Label of this mapping type as shown in the "Entity" dropdown-select on the form.
- getLimitToOptions() : array<string|int, mixed>
- Get the option list for `limit_to` (non-associative format)
- getName() : string
- Unique name of this mapping type.
- getRecipientListing() : array<string|int, mixed>
- Get option list for `recipient_listing` field.
- getRecipientTypes() : array<string|int, mixed>
- Get option list for `recipient` field.
- getSelectClause() : array<string|int, SqlExpression, dataType: string}>
- Returns the select clause enhanced with metadata
- getStatusLabels() : array<string|int, mixed>
- Get option list for the `entity_status` field.
- getSubscribedEvents() : array<string|int, mixed>
- getValueLabels() : array<string|int, mixed>
- Get option list for the `entity_value` field.
- modifyApiSpec() : mixed
- modifySpec() : void
- onRegisterActionMappings() : void
- Register this action mapping type with CRM_Core_BAO_ActionSchedule.
- resetOnTriggerDateChange() : bool
- Determine whether a schedule based on this mapping should reset the reminder state if the trigger date changes.
- sendToAdditional() : bool
- Determine whether a schedule based on this mapping should send to additional contacts.
- applyFilter() : mixed
- checkPermissionToLoadSearch() : mixed
- Only SearchKit admins can use unsecured "preview mode" and pass an array for savedSearch or display
- getColumnLabel() : string
- getField() : array<string|int, mixed>|null
- Returns field definition for a given field or NULL if not found
- getFixedRecipients() : array<string|int, mixed>|null
- getJoin() : array{entity: string, alias: string, table: string, bridge: string|null}|null
- getJoinLabel() : string
- getJoins() : array<string|int, array{entity: string, alias: string, table: string, bridge: string|null}>
- getSelectExpression() : SqlExpression, dataType: string}|null
- getTokens() : array<string|int, mixed>
- Search a string for all square bracket tokens and return their contents (without the brackets)
- hasValue() : bool
- Checks if a filter contains a non-empty value
- loadSavedSearch() : mixed
- If SavedSearch is supplied as a string, this will load it as an array
- loadSearchDisplay() : void
- Loads display if not already an array
- canAggregate() : bool
- Determines if a column belongs to an aggregate grouping
- getEntityFields() : array<string|int, mixed>
- Used as a fallback for non-DAO entities which don't use the Query object
- getQuery() : Api4SelectQuery|bool
- Returns a Query object for the search entity, or FALSE if it doesn't have a DAO
- renameIfAggregate() : string
Properties
$_apiParams
protected
array{select: array, where: array, having: array, orderBy: array, limit: int, offset: int, checkPermissions: bool, debug: bool}
$_apiParams
$savedSearch
Either the name of the savedSearch or an array containing the savedSearch definition (for preview mode)
protected
string|array<string|int, mixed>
$savedSearch
Tags
$_joinMap
private
array<string|int, mixed>
$_joinMap
$_searchEntityFields
private
array<string|int, mixed>
$_searchEntityFields
$_selectClause
private
array<string|int, mixed>
$_selectClause
$_selectQuery
private
Api4SelectQuery
$_selectQuery
Methods
applies()
public
final applies(string $entity, string $action) : bool
Parameters
- $entity : string
- $action : string
Return values
boolcheckAccess()
Check if the user has permission to create a reminder for given `entity_value`.
public
checkAccess(array<string|int, mixed> $entityValue) : bool
This function is called by the form to escalate permissions so that less-privileged users can create a reminder for a particular entity even if they do not have 'administer CiviCRM data'.
Return FALSE and the default permission of 'administer CiviCRM data' will be enforced.
Note that entity_value
is a serialized field, so will be passed as an array, even though
more than one value doesn't make sense in the context of embedding the ScheduledReminder form
on a page belonging to a single entity.
Parameters
- $entityValue : array<string|int, mixed>
Return values
boolcreateQuery()
Generate a query to locate recipients.
public
createQuery(CRM_Core_DAO_ActionSchedule $schedule, string $phase, array<string|int, mixed> $defaultParams) : CRM_Utils_SQL_Select
Parameters
- $schedule : CRM_Core_DAO_ActionSchedule
-
The schedule as configured by the administrator.
- $phase : string
-
See, e.g., RecipientBuilder::PHASE_RELATION_FIRST.
- $defaultParams : array<string|int, mixed>
Tags
Return values
CRM_Utils_SQL_SelectgetAlternateRecipients()
public
getAlternateRecipients(CRM_Core_DAO_ActionSchedule $schedule) : array<string|int, mixed>|null
Parameters
- $schedule : CRM_Core_DAO_ActionSchedule
Return values
array<string|int, mixed>|nullgetBccRecipients()
public
getBccRecipients(CRM_Core_DAO_ActionSchedule $schedule) : array<string|int, mixed>|null
Parameters
- $schedule : CRM_Core_DAO_ActionSchedule
Return values
array<string|int, mixed>|nullgetDateFields()
Get option list for `start_action_date` & `end_date` fields.
public
getDateFields([array<string|int, mixed>|null $entityValue = NULL ]) : array<string|int, mixed>
Parameters
- $entityValue : array<string|int, mixed>|null = NULL
Return values
array<string|int, mixed>getEntity()
Deprecated ambiguously-named function.
public
getEntity() : string
Return values
stringgetEntityName()
Main entity name e.g. `Activity`
public
getEntityName() : string
Return values
stringgetEntityTable()
Name of the table belonging to the main entity e.g. `civicrm_activity`
public
getEntityTable(CRM_Core_DAO_ActionSchedule $actionSchedule) : string
Parameters
- $actionSchedule : CRM_Core_DAO_ActionSchedule
Return values
stringgetId()
Unique identifier of this mapping type.
public
getId() : string|int
Should return a "machine_name" style string (same output as getName()
)
Note: Some legacy implementations return an int. Don't follow those examples.
Return values
string|intgetLabel()
Label of this mapping type as shown in the "Entity" dropdown-select on the form.
public
getLabel() : string
Return values
stringgetLimitToOptions()
Get the option list for `limit_to` (non-associative format)
public
static getLimitToOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>getName()
Unique name of this mapping type.
public
getName() : string
Return values
stringgetRecipientListing()
Get option list for `recipient_listing` field.
public
getRecipientListing(mixed $recipientType) : array<string|int, mixed>
Parameters
- $recipientType : mixed
-
Value of
recipient
field
Return values
array<string|int, mixed> —Ex: [1 => 'Attendee', 2 => 'Volunteer', ...].
getRecipientTypes()
Get option list for `recipient` field.
public
static getRecipientTypes() : array<string|int, mixed>
Note: A single schedule may filter on zero or one recipient types. When an admin chooses a value, it's stored in $schedule->recipient.
Return values
array<string|int, mixed> —Ex: ['assignee' => 'Activity Assignee', ...].
getSelectClause()
Returns the select clause enhanced with metadata
public
getSelectClause() : array<string|int, SqlExpression, dataType: string}>
Return values
array<string|int, SqlExpression, dataType: string}>getStatusLabels()
Get option list for the `entity_status` field.
public
getStatusLabels(array<string|int, mixed>|null $entityValue) : array<string|int, mixed>
Parameters
- $entityValue : array<string|int, mixed>|null
Return values
array<string|int, mixed>getSubscribedEvents()
public
static getSubscribedEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>getValueLabels()
Get option list for the `entity_value` field.
public
getValueLabels() : array<string|int, mixed>
Return values
array<string|int, mixed>modifyApiSpec()
public
modifyApiSpec(RequestSpec $spec) : mixed
Parameters
- $spec : RequestSpec
modifySpec()
public
final modifySpec(RequestSpec $spec) : void
Parameters
- $spec : RequestSpec
onRegisterActionMappings()
Register this action mapping type with CRM_Core_BAO_ActionSchedule.
public
static onRegisterActionMappings(MappingRegisterEvent $registrations) : void
Parameters
- $registrations : MappingRegisterEvent
resetOnTriggerDateChange()
Determine whether a schedule based on this mapping should reset the reminder state if the trigger date changes.
public
resetOnTriggerDateChange(mixed $schedule) : bool
Parameters
- $schedule : mixed
Return values
boolsendToAdditional()
Determine whether a schedule based on this mapping should send to additional contacts.
public
sendToAdditional(mixed $entityId) : bool
Parameters
- $entityId : mixed
Return values
boolapplyFilter()
protected
applyFilter(string|array<string|int, mixed> $fieldName, mixed $value) : mixed
Parameters
- $fieldName : string|array<string|int, mixed>
-
If multiple field names are given they will be combined in an OR clause
- $value : mixed
checkPermissionToLoadSearch()
Only SearchKit admins can use unsecured "preview mode" and pass an array for savedSearch or display
protected
checkPermissionToLoadSearch() : mixed
Tags
getColumnLabel()
protected
getColumnLabel(SqlExpression $expr) : string
Parameters
- $expr : SqlExpression
Return values
stringgetField()
Returns field definition for a given field or NULL if not found
protected
getField(mixed $fieldName) : array<string|int, mixed>|null
Parameters
- $fieldName : mixed
Return values
array<string|int, mixed>|nullgetFixedRecipients()
protected
getFixedRecipients(CRM_Core_DAO_ActionSchedule $schedule) : array<string|int, mixed>|null
Parameters
- $schedule : CRM_Core_DAO_ActionSchedule
Return values
array<string|int, mixed>|nullgetJoin()
protected
getJoin(string $joinAlias) : array{entity: string, alias: string, table: string, bridge: string|null}|null
Parameters
- $joinAlias : string
-
Alias of the join, with or without the trailing dot
Return values
array{entity: string, alias: string, table: string, bridge: string|null}|nullgetJoinLabel()
protected
getJoinLabel(string $joinAlias) : string
Parameters
- $joinAlias : string
Return values
stringgetJoins()
protected
getJoins() : array<string|int, array{entity: string, alias: string, table: string, bridge: string|null}>
Return values
array<string|int, array{entity: string, alias: string, table: string, bridge: string|null}>getSelectExpression()
protected
getSelectExpression(string $key) : SqlExpression, dataType: string}|null
Parameters
- $key : string
Return values
SqlExpression, dataType: string}|nullgetTokens()
Search a string for all square bracket tokens and return their contents (without the brackets)
protected
getTokens(string $str) : array<string|int, mixed>
Parameters
- $str : string
Return values
array<string|int, mixed>hasValue()
Checks if a filter contains a non-empty value
protected
hasValue(mixed $value) : bool
"Empty" search values are [], '', and NULL. Also recursively checks arrays to ensure they contain at least one non-empty value.
Parameters
- $value : mixed
Return values
boolloadSavedSearch()
If SavedSearch is supplied as a string, this will load it as an array
protected
loadSavedSearch([int|null $id = NULL ]) : mixed
Parameters
- $id : int|null = NULL
Tags
loadSearchDisplay()
Loads display if not already an array
protected
loadSearchDisplay() : void
canAggregate()
Determines if a column belongs to an aggregate grouping
private
canAggregate(string $fieldPath) : bool
Parameters
- $fieldPath : string
Return values
boolgetEntityFields()
Used as a fallback for non-DAO entities which don't use the Query object
private
getEntityFields() : array<string|int, mixed>
Return values
array<string|int, mixed>getQuery()
Returns a Query object for the search entity, or FALSE if it doesn't have a DAO
private
getQuery() : Api4SelectQuery|bool
Return values
Api4SelectQuery|boolrenameIfAggregate()
private
renameIfAggregate(string $fieldPath[, bool $asSelect = FALSE ]) : string
Parameters
- $fieldPath : string
- $asSelect : bool = FALSE