From f689d6ae9ce2a899c63ca5d1a0f2dd757644c349 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 18 Oct 2014 03:19:45 -0700 Subject: [PATCH] Added mail preview window to admin->mailout. --- e107_admin/mailout.php | 26 +++++++++++++++++++++++++- e107_core/templates/email_template.php | 2 +- e107_handlers/mail.php | 20 ++++++++++++++++++++ e107_handlers/mailout_admin_class.php | 4 +++- 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/e107_admin/mailout.php b/e107_admin/mailout.php index bb34280b7..c20183914 100644 --- a/e107_admin/mailout.php +++ b/e107_admin/mailout.php @@ -354,8 +354,15 @@ class mailout_main_ui extends e_admin_ui function init() { $action = varset($_GET['mode'], 'main'); + $this->mailAdmin = new mailoutAdminClass($action); + if($_GET['action'] == 'preview') + { + echo $this->previewPage(); + exit; + } + if ($this->mailAdmin->loadMailHandlers() == 0) { e107::getMessage()->addDebug('No mail handlers loaded!!'); @@ -578,8 +585,25 @@ class mailout_main_ui extends e_admin_ui } + /** + * Preview the Email. + */ + function previewPage() + { + $mailData = e107::getDb()->retrieve('mail_content','*','mail_source_id='.intval($_GET['id'])." LIMIT 1"); + + + $data = $this->mailAdmin->dbToMail($mailData); + + $eml = array( + 'body' => $data['mail_body'], + 'template' => $data['mail_send_style'] + ); + + return e107::getEmail()->preview($eml); + exit; - + } diff --git a/e107_core/templates/email_template.php b/e107_core/templates/email_template.php index 68efcc7df..51d6719a4 100644 --- a/e107_core/templates/email_template.php +++ b/e107_core/templates/email_template.php @@ -170,7 +170,7 @@ $EMAIL_TEMPLATE['default']['header'] = " - diff --git a/e107_handlers/mail.php b/e107_handlers/mail.php index b56f74bb7..459661826 100644 --- a/e107_handlers/mail.php +++ b/e107_handlers/mail.php @@ -594,6 +594,26 @@ class e107Email extends PHPMailer } } + /** + * Preview the BODY of an email + * @param $eml - array. + */ + public function preview($eml) + { + if (count($eml)) + { + if($error = $this->arraySet($eml)) // Set parameters from list + { + return $error; + } + + } + + return $this->Body; + + } + + /** * Sets one or more parameters from an array. See @see{sendEmail()} for list of parameters diff --git a/e107_handlers/mailout_admin_class.php b/e107_handlers/mailout_admin_class.php index 6b09b994d..e01d7e244 100644 --- a/e107_handlers/mailout_admin_class.php +++ b/e107_handlers/mailout_admin_class.php @@ -890,7 +890,9 @@ class mailoutAdminClass extends e107MailManager if($k == 'mail_body') { - $text .= $tp->toHtml($val,true); + // $text .= print_a($mailSource,true); + // $text .= $tp->toHtml($val,true); + $text .= ""; continue; }