Merge pull request #157 from mi3ll/filtered-email-recipients

NEW: Additional arguments for filtered email recipients
This commit is contained in:
Will Rossiter 2013-09-04 02:23:08 -07:00
commit b2b030366b

View File

@ -280,10 +280,10 @@ class UserDefinedForm extends Page {
* *
* @return ArrayList * @return ArrayList
*/ */
public function FilteredEmailRecipients() { public function FilteredEmailRecipients($data = null, $form = null) {
$recipients = new ArrayList($this->getComponents('EmailRecipients')->toArray()); $recipients = new ArrayList($this->getComponents('EmailRecipients')->toArray());
$this->extend('updateFilteredEmailRecipients', $recipients); $this->extend('updateFilteredEmailRecipients', $recipients, $data, $form);
return $recipients; return $recipients;
} }
@ -964,7 +964,7 @@ JS
); );
// email users on submit. // email users on submit.
if($this->FilteredEmailRecipients()) { if($recipients = $this->FilteredEmailRecipients($data, $form)) {
$email = new UserDefinedForm_SubmittedFormEmail($submittedFields); $email = new UserDefinedForm_SubmittedFormEmail($submittedFields);
if($attachments){ if($attachments){
@ -979,7 +979,7 @@ JS
} }
} }
foreach($this->FilteredEmailRecipients() as $recipient) { foreach($recipients as $recipient) {
$email->populateTemplate($recipient); $email->populateTemplate($recipient);
$email->populateTemplate($emailData); $email->populateTemplate($emailData);
$email->setFrom($recipient->EmailFrom); $email->setFrom($recipient->EmailFrom);