Xataface Email Module  0.3.2
Email/Mailmerge Module for Xataface
 All Data Structures Files Functions Variables Pages
Public Member Functions
ApplicationDelegate Interface Reference

A false interface used to document that methods that can be implemented in the application delegate class to affect the functioning of the Email module. More...

Public Member Functions

 decorateEmailContext (Dataface_Record $email, Dataface_Record $template, Dataface_Record $recipient)
 A hook that is called just before an email is sent. This gives you an opportunity to add or modify data that is being sent.
 getEmailOptOutMessage (Dataface_Record $recipient, $url)
 A hook that can optionally override the "opt-out" message that is added at the end of an email.
 Email__isBlackListed ($email)
 Checks whether a particular Email address is blacklisted. This will complement or supplement the existing blacklist table check depending on the return value of this method.
 Email__afterOptIn ($email)
 Trigger fired after an email address opts into the email list.
 Email__afterOptOut ($email)
 Trigger fired after an email address opts out of the email list.
 Email__onFail (Dataface_Record $recipient, Dataface_Record $email)
 Trigger fired after an email is attempted to be sent, but fails.
 Email__onSuccess (Dataface_Record $recipient, Dataface_Record $email)
 Trigger fired after an email is successfully sent.

Detailed Description

A false interface used to document that methods that can be implemented in the application delegate class to affect the functioning of the Email module.

Definition at line 6 of file ApplicationDelegate.php.

Member Function Documentation

decorateEmailContext ( Dataface_Record  $email,
Dataface_Record  $template,
Dataface_Record  $recipient 
)

A hook that is called just before an email is sent. This gives you an opportunity to add or modify data that is being sent.

It's best not to modify any information in the $email or $template since these are loaded once per batch of emails. Hence if you modify any of the information in them it will affect all subsequent emails sent in the same batch.

You may want to modify data in the $recipient, which is used to populate macros in the email body.

Parameters
Dataface_Record$emailThe email record that is being sent. This includes the email content prior to the recipient macros being filled in. This record encapsulates a single row from the xataface__email_newsletters table. This value is never null.
Dataface_Record$templateThe template record that was used as a basis for this email. If no template was used then this value will be null. You may want to use the template as a marker for you to perform custom code that affects the recipient.
Dataface_Record$recipientThe recipient record. This encapsulates a row from the entity table upon which the found set we are sending email to was formed. This record is used to draw values for the embed macros so you can affect the values of the embed macros by modifying them in this record.
Returns
void
See Also
TableDelegate::decorateEmailContext()

Example

This example looks for a particular template, and if the email uses this template, it resets the recipient's password to 'changeme'. Presumably this template draws on the 'password' field to send it to the recipient as part of the email.

function decorateEmailContext(Dataface_Record $email, Dataface_Record $template, Dataface_Record $recipient){
if ( $template and $template->val('template_id') == 10 ){
// template with id=10 is the reset password email.
// Let's reset the recipient's password and store the new
// password in a calculated field that we created for this purpose.
$recipient->setValue('password', 'changeme');
$recipient->save();
}
}
Since
0.3
Email__afterOptIn (   $email)

Trigger fired after an email address opts into the email list.

Parameters
String$emailThe email address that was opted in. (i.e. added to the blacklist)
Since
0.3.2
Email__afterOptOut (   $email)

Trigger fired after an email address opts out of the email list.

Parameters
String$emailThe email address that was opted out (i.e. added to the blacklist).
Since
0.3.2
Email__isBlackListed (   $email)

Checks whether a particular Email address is blacklisted. This will complement or supplement the existing blacklist table check depending on the return value of this method.

If it returns a boolean value (true or false), then this value will be treated as definitive (i.e. will completely override the built-in blacklist). If it returns any other value (e.g. 1, 0, null, ", etc...), then the result is ignored, and the standard blacklist is used.

Parameters
String$emailThe email address the check against the blacklist.
Returns
mixed Either a boolean value (true or false) to indicate whether the email address is blacklisted, or any other value (e.g. null) to indicate that "we don't know".
Since
0.3.1
Email__onFail ( Dataface_Record  $recipient,
Dataface_Record  $email 
)

Trigger fired after an email is attempted to be sent, but fails.

Parameters
Dataface_Record$recipientRecord to which delivery was attempted. This will be a record of the table on which the "Send Email" option was selected. It should implement the Person ontology.
Dataface_Record$emailThe email record from the xataface__email_newsletters table.
Returns
void
Since
0.3.2
Email__onSuccess ( Dataface_Record  $recipient,
Dataface_Record  $email 
)

Trigger fired after an email is successfully sent.

Parameters
Dataface_Record$recipientRecord that was sent to. This will be a record of the table on which the "Send Email" option was selected. It should implement the Person ontology.
Dataface_Record$emailThe email record from the xataface__email_newsletters table.
Returns
void
Since
0.3.2
getEmailOptOutMessage ( Dataface_Record  $recipient,
  $url 
)

A hook that can optionally override the "opt-out" message that is added at the end of an email.

If this is not defined then a default message will be used with a link to the page where the user can opt out of the email list.

Parameters
Dataface_Record$recipientThe recipient record where the email is being sent.
string$urlThe URL to the opt-out form.
Returns
array An associative array with one or more of the following keys:
html : <String> // The HTML version of the message.
text : <String> // The plain text version of the message

Example

function getEmailOptOutMessage(Dataface_Record $recipient, $url){
return array(
'html' => '<hr/><p>Click <a href="'.$url.'">here</a> to opt out of our list.</p>',
'text' => "\r\n\r\n----------------------\r\n To opt out, go to $url \r\n"
);
}

Default Opt Out Messages

Note that you can override the default opt-out message in the conf.ini file also using the opt_out_html or opt_out_text directives in the modules_Email section.

See Also
TableDelegate::getEmailOptOutMessage()
Since
0.3

The documentation for this interface was generated from the following file: