Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bossanova808 committed Dec 23, 2016
1 parent 6f29c6c commit 411186b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion commercemailer/CommerceMailerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
28 changes: 24 additions & 4 deletions commercemailer/controllers/CommerceMailerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,37 @@ public function actionSendMail()
}
$compiledMessage .= $postedMessage['body'];
}
$vars['body'] = $compiledMessage;
if (isset($vars['noNl2br'])) {
$vars['body'] = $compiledMessage;
}
else {
$vars['body'] = "<br>" . nl2br($compiledMessage);
}
}
}
else
{
$vars['body'] = $postedMessage;
if (isset($vars['noNl2br'])) {
$vars['body'] = $postedMessage;
}
else {
$vars['body'] = "<br>" . nl2br($postedMessage);
}
}
}


// 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
Expand Down Expand Up @@ -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 {
Expand All @@ -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){
Expand All @@ -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);
}

}
Expand Down
11 changes: 9 additions & 2 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down

0 comments on commit 411186b

Please sign in to comment.