Documentation

CRM_Contact_Form_Task_EmailTrait

This class provides the common functionality for tasks that send emails.

Table of Contents

Properties

$_allContactIds  : array<string|int, mixed>
Store all selected contact id's, that includes to, cc and bcc contacts
$_caseId  : mixed
$_contactDetails  : mixed
$_context  : mixed
$_entityTagValues  : mixed
$_single  : bool
Are we operating in "single mode", i.e. sending email to one specific contact?
$_templates  : array<string|int, mixed>
All the existing templates in the system.
$_toContactDetails  : array<string|int, mixed>
Store "to" contact details.
$_toContactIds  : array<string|int, mixed>
Store only "to" contact ids.
$contactEmails  : mixed
$isSearchContext  : bool
Is the form being loaded from a search action.
$emails  : array<string|int, mixed>
Email addresses to send to.
$suppressedEmails  : array<string|int, mixed>
Contacts form whom emails could not be sent.

Methods

buildQuickForm()  : mixed
Build the form object.
deprecatedTokensFormRule()  : bool|array<string|int, string>
Prevent submission of deprecated tokens.
isSearchContext()  : bool
Getter for isSearchContext.
postProcess()  : mixed
Process the form after the input has been submitted and validated.
preProcess()  : mixed
Build all the data structures needed to build the form.
saveTemplateFormRule()  : bool|array<string|int, mixed>
Form rule.
setDefaultValues()  : array<string|int, mixed>
Set relevant default values.
setIsSearchContext()  : mixed
Setter for isSearchContext.
submit()  : void
Submit the form values.
bounceIfSimpleMailLimitExceeded()  : void
Bounce if there are more emails than permitted.
createEmailActivity()  : int
createFollowUpActivities()  : string
Create any follow up activities.
getAttachments()  : array<string|int, mixed>
Get any attachments.
getBcc()  : string
getBccArray()  : array<string|int, mixed>
getCaseID()  : int|null
Get case ID - if any.
getCc()  : string
getCcArray()  : array<string|int, mixed>
getContributionIDs()  : array<string|int, mixed>
Get selected contribution IDs.
getEmail()  : string
Get the relevant emails.
getEmails()  : array<string|int, mixed>
Get the emails from the added element.
getEmailString()  : string
Get the string for the email IDs.
getEmailUrlString()  : string
Get the url string.
getFromEmails()  : array<string|int, mixed>
getMessageTokens()  : array<string|int, mixed>
Get the tokens in the submitted message.
getRedirectUrl()  : string
Get the url to redirect the user's browser to.
getRowsForEmails()  : array<string|int, mixed>
Get the result rows to email.
getSubject()  : string
Get the subject for the message.
isGroupByContact()  : bool
Only send one email per contact.
saveMessageTemplate()  : mixed
Save the template if update selected.
sendMessage()  : bool
Send message - under refactor.
setSuppressedEmail()  : mixed
Set the emails that are not to be sent out.
traitPreProcess()  : void
Call trait preProcess function.

Properties

$_allContactIds

Store all selected contact id's, that includes to, cc and bcc contacts

public array<string|int, mixed> $_allContactIds = []

$_contactDetails

public mixed $_contactDetails = []

$_entityTagValues

public mixed $_entityTagValues

$_single

Are we operating in "single mode", i.e. sending email to one specific contact?

public bool $_single = \FALSE

$_templates

All the existing templates in the system.

public array<string|int, mixed> $_templates

$_toContactDetails

Store "to" contact details.

public array<string|int, mixed> $_toContactDetails = []

$_toContactIds

Store only "to" contact ids.

public array<string|int, mixed> $_toContactIds = []

$isSearchContext

Is the form being loaded from a search action.

public bool $isSearchContext = \TRUE

$emails

Email addresses to send to.

protected array<string|int, mixed> $emails = []

$suppressedEmails

Contacts form whom emails could not be sent.

protected array<string|int, mixed> $suppressedEmails = []

An array of contact ids and the relevant message details.

Methods

deprecatedTokensFormRule()

Prevent submission of deprecated tokens.

public static deprecatedTokensFormRule(array<string|int, mixed> $fields) : bool|array<string|int, string>

Note this rule can be removed after a transition period. It's mostly to help to ensure users don't get missing tokens or unexpected output after the 5.43 upgrade until any old templates have aged out.

Parameters
$fields : array<string|int, mixed>
Return values
bool|array<string|int, string>

isSearchContext()

Getter for isSearchContext.

public isSearchContext() : bool
Return values
bool

saveTemplateFormRule()

Form rule.

public static saveTemplateFormRule(array<string|int, mixed> $fields) : bool|array<string|int, mixed>
Parameters
$fields : array<string|int, mixed>

The input form values.

Return values
bool|array<string|int, mixed>

true if no errors, else array of errors

setDefaultValues()

Set relevant default values.

public setDefaultValues() : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

setIsSearchContext()

Setter for isSearchContext.

public setIsSearchContext(bool $isSearchContext) : mixed
Parameters
$isSearchContext : bool

bounceIfSimpleMailLimitExceeded()

Bounce if there are more emails than permitted.

protected bounceIfSimpleMailLimitExceeded(int $count) : void
Parameters
$count : int

The number of emails the user is attempting to send

createEmailActivity()

protected createEmailActivity(int $sourceContactID, string $subject, string $html, string $text, string $additionalDetails, int $campaignID, array<string|int, mixed> $attachments, int $caseID) : int
Parameters
$sourceContactID : int

The contact ID of the email "from".

$subject : string
$html : string
$text : string
$additionalDetails : string

The additional information of CC and BCC appended to the activity details.

$campaignID : int
$attachments : array<string|int, mixed>
$caseID : int
Tags
throws
CRM_Core_Exception
Return values
int

The created activity ID

createFollowUpActivities()

Create any follow up activities.

protected createFollowUpActivities(array<string|int, mixed> $formValues, int $activityId) : string
Parameters
$formValues : array<string|int, mixed>
$activityId : int
Tags
throws
CRM_Core_Exception
Return values
string

getAttachments()

Get any attachments.

protected getAttachments(array<string|int, mixed> $formValues) : array<string|int, mixed>
Parameters
$formValues : array<string|int, mixed>
Return values
array<string|int, mixed>

getBccArray()

protected getBccArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCcArray()

protected getCcArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

getContributionIDs()

Get selected contribution IDs.

protected getContributionIDs() : array<string|int, mixed>
Return values
array<string|int, mixed>

getEmail()

Get the relevant emails.

protected getEmail(int $index) : string
Parameters
$index : int
Return values
string

getEmails()

Get the emails from the added element.

protected getEmails() : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getEmailUrlString()

Get the url string.

protected getEmailUrlString(array<string|int, mixed> $emailIDs) : string

This is called after the contacts have been retrieved so we don't need to re-retrieve.

Parameters
$emailIDs : array<string|int, mixed>
Return values
string

e.g. Bob Smith'

getFromEmails()

protected getFromEmails() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMessageTokens()

Get the tokens in the submitted message.

protected getMessageTokens() : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getRedirectUrl()

Get the url to redirect the user's browser to.

protected getRedirectUrl() : string
Tags
throws
CRM_Core_Exception
Return values
string

getRowsForEmails()

Get the result rows to email.

protected getRowsForEmails() : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getSubject()

Get the subject for the message.

protected getSubject() : string
Return values
string

isGroupByContact()

Only send one email per contact.

protected isGroupByContact() : bool

This has historically been done for contributions & makes sense if no entity specific tokens are in use.

Return values
bool

saveMessageTemplate()

Save the template if update selected.

protected saveMessageTemplate(array<string|int, mixed> $formValues) : mixed
Parameters
$formValues : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
throws
UnauthorizedException

sendMessage()

Send message - under refactor.

protected sendMessage(mixed $from, mixed $toID, mixed $subject, mixed $text_message, mixed $html_message, mixed $emailAddress, mixed $activityID[, null $attachments = NULL ][, null $cc = NULL ][, null $bcc = NULL ]) : bool
Parameters
$from : mixed
$toID : mixed
$subject : mixed
$text_message : mixed
$html_message : mixed
$emailAddress : mixed
$activityID : mixed
$attachments : null = NULL
$cc : null = NULL
$bcc : null = NULL
Tags
throws
CRM_Core_Exception
throws
PEAR_Exception
Return values
bool

setSuppressedEmail()

Set the emails that are not to be sent out.

protected setSuppressedEmail(int $contactID, array<string|int, mixed> $values) : mixed
Parameters
$contactID : int
$values : array<string|int, mixed>

traitPreProcess()

Call trait preProcess function.

protected traitPreProcess() : void

This function exists as a transitional arrangement so classes overriding preProcess can still call it. Ideally it will be melded into preProcess later.

Tags
throws
CRM_Core_Exception

        
On this page

Search results