ENHANCEMENT: Allow custom email text to go to form submitter

This commit is contained in:
Saophalkun Ponlu 2009-02-11 02:00:20 +00:00
parent 7265fae386
commit e2f47e41c3
3 changed files with 64 additions and 7 deletions

View File

@ -16,7 +16,8 @@ class UserDefinedForm extends Page {
"EmailTo" => "Varchar",
"EmailOnSubmit" => "Boolean",
"SubmitButtonText" => "Varchar",
"OnCompleteMessage" => "HTMLText"
"OnCompleteMessage" => "HTMLText",
"EmailMessageToSubmitter" => "HTMLText",
);
static $defaults = array(
@ -35,7 +36,13 @@ class UserDefinedForm extends Page {
$fields->addFieldToTab("Root."._t('UserDefinedForm.FORM', 'Form'), new FieldEditor("Fields", 'Fields', "", $this ));
$fields->addFieldToTab("Root."._t('UserDefinedForm.SUBMISSIONS','Submissions'), new SubmittedFormReportField( "Reports", _t('UserDefinedForm.RECEIVED', 'Received Submissions'), "", $this ) );
$fields->addFieldToTab("Root.Content."._t('UserDefinedForm.ONCOMPLETE','On complete'), new HtmlEditorField( "OnCompleteMessage", _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion'),3,"",_t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage), $this ) );
$onCompleteFieldSet = new FieldSet(
new HtmlEditorField( "OnCompleteMessage", _t('UserDefinedForm.ONCOMPLETELABEL', 'Show on completion'),3,"",_t('UserDefinedForm.ONCOMPLETEMESSAGE', $this->OnCompleteMessage), $this ),
new HtmlEditorField( "EmailMessageToSubmitter", _t('UserDefinedForm.EMAILMESSAGETOSUBMITTER', 'Email message to submitter'),3,"",_t('UserDefinedForm.EMAILMESSAGETOSUBMITTER', $this->EmailMessageToSubmitter), $this )
);
$fields->addFieldsToTab("Root.Content."._t('UserDefinedForm.ONCOMPLETE','On complete'), $onCompleteFieldSet);
return $fields;
}
@ -386,9 +393,14 @@ class UserDefinedForm_Controller extends Page_Controller {
$email->send();
// send to each of email fields
$emailToSubmiter = new UserDefinedForm_SubmittedFormEmailToSubmitter($submittedFields);
$emailToSubmiter->populateTemplate($emailData);
$emailToSubmiter->setSubject( $this->Title );
foreach( $recipientAddresses as $addr ) {
$email->setTo( $addr );
$email->send();
$emailToSubmiter->setBody( $this->EmailMessageToSubmitter );
$emailToSubmiter->setTo( $addr );
$emailToSubmiter->send();
}
}
@ -443,4 +455,28 @@ class UserDefinedForm_SubmittedFormEmail extends Email {
}
}
/**
* Email that gets sent to submitter when a submission is made.
* @package cms
* @subpackage pagetypes
*/
class UserDefinedForm_SubmittedFormEmailToSubmitter extends Email {
protected $ss_template = "SubmittedFormEmailToSubmitter";
protected $from = '$Sender.Email';
protected $to = '$Recipient.Email';
protected $subject = 'Submission of form';
protected $data;
function __construct($values) {
$this->subject = _t('UserDefinedForm_SubmittedFormEmail.EMAILSUBJECT', 'Submission of form');
parent::__construct();
$this->data = $values;
}
function Data() {
return $this->data;
}
}
?>

View File

@ -12,8 +12,8 @@
<table>
<% control Fields %>
<tr>
<td><b>$Title</b></td>
<td>$Value</td>
<td style="padding: 5px"><b>$Title</b></td>
<td style="padding: 5px">$Value</td>
</tr>
<% end_control %>
</table>

View File

@ -0,0 +1,21 @@
<html>
<head>
</head>
<body>
$Body
<p>
<% _t('SUBMITTED',"You have submitted the following information:") %>
</p>
<table>
<% control Fields %>
<tr>
<td style="padding: 5px"><b>$Title</b></td>
<td style="padding: 5px">$Value</td>
</tr>
<% end_control %>
</table>
</body>
</html>