Xataface Email Module 0.3
Email/Mailmerge Module for Xataface
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.

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();
     }
 }

The documentation for this interface was generated from the following file:
 All Data Structures Files Functions Variables Enumerations