From 411186b685c8a2b7e0a4cdb673628dcd7475ccb2 Mon Sep 17 00:00:00 2001 From: bossanova808 Date: Sat, 24 Dec 2016 08:14:26 +1100 Subject: [PATCH] Bugfixes --- commercemailer/CommerceMailerPlugin.php | 2 +- .../controllers/CommerceMailerController.php | 28 ++++++++++++++++--- releases.json | 11 ++++++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/commercemailer/CommerceMailerPlugin.php b/commercemailer/CommerceMailerPlugin.php index ade513e..ffab952 100644 --- a/commercemailer/CommerceMailerPlugin.php +++ b/commercemailer/CommerceMailerPlugin.php @@ -3,7 +3,7 @@ class CommerceMailerPlugin extends BasePlugin { - private $version = "0.1.2"; + private $version = "0.1.3"; private $schemaVersion = "0.0.0"; private $name = 'Commerce Mailer'; diff --git a/commercemailer/controllers/CommerceMailerController.php b/commercemailer/controllers/CommerceMailerController.php index 768de69..4106ea0 100644 --- a/commercemailer/controllers/CommerceMailerController.php +++ b/commercemailer/controllers/CommerceMailerController.php @@ -119,12 +119,22 @@ public function actionSendMail() } $compiledMessage .= $postedMessage['body']; } - $vars['body'] = $compiledMessage; + if (isset($vars['noNl2br'])) { + $vars['body'] = $compiledMessage; + } + else { + $vars['body'] = "
" . nl2br($compiledMessage); + } } } else { - $vars['body'] = $postedMessage; + if (isset($vars['noNl2br'])) { + $vars['body'] = $postedMessage; + } + else { + $vars['body'] = "
" . nl2br($postedMessage); + } } } @@ -132,6 +142,14 @@ public function actionSendMail() // create an EmailModel & populate it $email = EmailModel::populateModel($vars); + //Attach a file if there is one... + $attachment = null; + if (isset($_FILES['attachment']) && !empty($_FILES['attachment']['name'])) + { + CommerceMailerPlugin::log("Found attachment " . $_FILES['attachment']['name']); + $attachment = \CUploadedFile::getInstanceByName('attachment'); + $email->addAttachment($attachment->getTempName(), $attachment->getName(), 'base64', $attachment->getType()); + } //validate the email model //put all our errors in one place, and return the email model if invalid - use message as this is what contactForm does @@ -185,6 +203,8 @@ public function actionSendMail() foreach ($errors as $error) { CommerceMailerPlugin::logError($error); } + //Log what page the error happened on... + CommerceMailerPlugin::logError(craft()->request->getUrlReferrer()); craft()->urlManager->setRouteVariables(['errors' => $errors, 'message' => $email] ); } else { @@ -195,7 +215,7 @@ public function actionSendMail() if (!$spam){ //Special sauce for us.... - if (craft()->config->get('environmentVariables')['customMessaging']){ + if (isset(craft()->config->get('environmentVariables')['IsImageScience'])){ //Are we sending to a local address? if(strpos($email->toEmail, "@" . $settings->internalDomain) === false){ @@ -205,7 +225,7 @@ public function actionSendMail() } else{ //Make a freshdesk ticket with the API - $sent = craft()->businessLogic_freshdesk->ticket($email->fromEmail, $email->toEmail, $email->subject, $email->htmlBody, (isset($vars['order']) ? $vars['order'] : null) ); + $sent = craft()->businessLogic_freshdesk->ticket($email->fromEmail, $email->toEmail, $email->subject, $email->htmlBody, (isset($vars['order']) ? $vars['order'] : null), false, $attachment); } } diff --git a/releases.json b/releases.json index e3e73fb..95cee2f 100644 --- a/releases.json +++ b/releases.json @@ -2,11 +2,18 @@ // $time = new DateTime; echo $time->format(DateTime::ATOM); [ - + { + "version": "0.1.3", + "date": "2016-12-24T12:20:36+11:00", + "downloadUrl": "https://github.com/bossanova808/CommerceMailer/archive/v0.1.3.zip", + "notes": [ + "[Fixed] Better detection of localised code", + ] + }, { "version": "0.1.2", "date": "2016-09-12T12:20:36+11:00", - "downloadUrl": "https://github.com/bossanova808/CommerceMailer/archive/v0.1.1.zip", + "downloadUrl": "https://github.com/bossanova808/CommerceMailer/archive/v0.1.2.zip", "notes": [ "[Fixed] Better detection of localised code", ]