if (!$this->templates) {
$this->getHeaderFooter();
$this->templates = array();
- if ($this->body_text || $this->header->body_text || $this->footer->body_text) {
+
+ if ($this->body_text) {
$template = array();
- if ($this->header->body_text) {
+ if ($this->header) {
$template[] = $this->header->body_text;
}
- else {
- $template[] = CRM_Utils_String::htmlToText($this->header->body_html);
- }
- if ($this->body_text) {
- $template[] = $this->body_text;
- }
- else {
- $template[] = CRM_Utils_String::htmlToText($this->body_html);
- }
+ $template[] = $this->body_text;
- if ($this->footer->body_text) {
+ if ($this->footer) {
$template[] = $this->footer->body_text;
}
- else {
- $template[] = CRM_Utils_String::htmlToText($this->footer->body_html);
- }
$this->templates['text'] = implode("\n", $template);
}
// this is where we create a text template from the html template if the text template did not exist
// this way we ensure that every recipient will receive an email even if the pref is set to text and the
// user uploads an html email only
- if (empty($this->templates['text'])) {
+ if (!$this->body_text) {
$this->templates['text'] = CRM_Utils_String::htmlToText($this->templates['html']);
}
}