Skip to content

Commit

Permalink
Merge pull request #545 from haraldpdl/gergely-issue_499
Browse files Browse the repository at this point in the history
Gergely issue 499
  • Loading branch information
haraldpdl authored Nov 21, 2016
2 parents 4a0bdfa + 12f8b9b commit a7a78bd
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 38 deletions.
2 changes: 1 addition & 1 deletion catalog/account_notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
$product_global = 0;
}

(array)$products = $_POST['products'];
$products = isset($_POST['products']) && is_array($_POST['products']) ? $_POST['products'] : [];

if ($product_global !== $Qglobal->valueInt('global_product_notifications')) {
$product_global = ($Qglobal->valueInt('global_product_notifications') === 1) ? 0 : 1;
Expand Down
3 changes: 3 additions & 0 deletions catalog/admin/includes/languages/english/main.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,6 @@ error_filetype_not_allowed = Error: File upload type not allowed.
success_file_saved_successfully = Success: File upload saved successfully.
warning_no_file_uploaded = Warning: No file uploaded.
module_content_bootstrap_row_description = <p>Content Width can be 12 or less per column per row.</p><p>12/12 = 100% width, 6/12 = 50% width, 4/12 = 33% width.</p><p>Total of all columns in any one row must equal 12 (eg: 3 boxes of 4 columns each, 1 box of 12 columns and so on).</p>

email_type_html = HTML
email_type_plain = Plain
14 changes: 14 additions & 0 deletions catalog/admin/includes/languages/english/orders.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ email_text_comments_update = The comments for your order are

{{comments}}

email_separator_html = <hr>
email_text_order_number_html = <strong>Order Number:</strong>
email_text_invoice_url_html = <strong>Detailed Invoice:</strong>
email_text_date_ordered_html = <strong>Date Ordered:</strong>

email_text_status_update_html = <p>Your order has been updated to the following status.</p>
<p>New status: {{status}}</p>
<p>Please reply to this email if you have any questions.</p>

email_text_comments_update_html = <p>The comments for your order are</p>
<div>
<blockquote>{{comments}}</blockquote>
</div>

error_order_does_not_exist = Error: Order #{{order_id}} does not exist.
success_order_updated = Success: Order has been successfully updated.
warning_order_not_updated = Warning: Nothing to change. The order was not updated.
38 changes: 34 additions & 4 deletions catalog/admin/includes/modules/newsletters/newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
use OSC\OM\Registry;

class newsletter {
var $show_choose_audience, $title, $content;
var $show_choose_audience, $title, $content, $content_html;

function newsletter($title, $content) {
function __construct($title, $content, $content_html = null) {
$this->show_choose_audience = false;
$this->title = $title;
$this->content = $content;
$this->content_html = $content_html;
}

function choose_audience() {
Expand All @@ -43,7 +44,29 @@ function confirm() {
' <td>&nbsp;</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
' <td class="main">' . "\n" .
' <ul class="nav nav-tabs" role="tablist">' . "\n" .
' <li role="presentation" class="active"><a href="#html_preview" aria-controls="html_preview" role="tab" data-toggle="tab">' . OSCOM::getDef('email_type_html') . '</a></li>' . "\n" .
' <li role="presentation"><a href="#plain_preview" aria-controls="plain_preview" role="tab" data-toggle="tab">' . OSCOM::getDef('email_type_plain') . '</a></li>' . "\n" .
' </ul>' . "\n" .
' <div class="tab-content">' . "\n" .
' <div role="tabpanel" class="tab-pane active" id="html_preview">' . "\n" .
' <iframe id="emailHtmlPreviewContent" style="width: 100%; height: 400px; border: 0;"></iframe>' . "\n" .
' <script id="emailHtmlPreview" type="x-tmpl-mustache">' . "\n" .
' ' . HTML::outputProtected($this->content_html) . "\n" .
' </script>' . "\n" .
' <script>' . "\n" .
' $(function() {' . "\n" .
' var content = $(\'<div />\').html($(\'#emailHtmlPreview\').html()).text();' . "\n" .
' $(\'#emailHtmlPreviewContent\').contents().find(\'html\').html(content);' . "\n" .
' });' . "\n" .
' </script>' . "\n" .
' </div>' . "\n" .
' <div role="tabpanel" class="tab-pane" id="plain_preview">' . "\n" .
' ' . nl2br(HTML::outputProtected($this->content)) . "\n" .
' </div>' . "\n" .
' </div>' . "\n" .
' </td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>&nbsp;</td>' . "\n" .
Expand All @@ -62,7 +85,14 @@ function send($newsletter_id) {
$newsletterEmail = new Mail();
$newsletterEmail->setFrom(STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER);
$newsletterEmail->setSubject($this->title);
$newsletterEmail->setBody($this->content);

if (!empty($this->content)) {
$newsletterEmail->setBodyPlain($this->content);
}

if (!empty($this->content_html)) {
$newsletterEmail->setBodyHTML($this->content_html);
}

$Qmail = $OSCOM_Db->get('customers', [
'customers_firstname',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
use OSC\OM\Registry;

class product_notification {
var $show_choose_audience, $title, $content;
var $show_choose_audience, $title, $content, $content_html;

function product_notification($title, $content) {
function __construct($title, $content, $content_html = null) {
$this->show_choose_audience = true;
$this->title = $title;
$this->content = $content;
$this->content_html = $content_html;
}

function choose_audience() {
Expand Down Expand Up @@ -155,7 +156,8 @@ function confirm() {
}
}

$confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
$confirm_string = HTML::form('confirm', OSCOM::link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nID=' . $_GET['nID'] . '&action=confirm_send')) . "\n" .
'<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
' <tr>' . "\n" .
' <td class="main"><font color="#ff0000"><strong>' . OSCOM::getDef('text_count_customers', ['audience' => sizeof($audience)]) . '</strong></font></td>' . "\n" .
' </tr>' . "\n" .
Expand All @@ -169,12 +171,34 @@ function confirm() {
' <td>&nbsp;</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
' <td class="main">' . "\n" .
' <ul class="nav nav-tabs" role="tablist">' . "\n" .
' <li role="presentation" class="active"><a href="#html_preview" aria-controls="html_preview" role="tab" data-toggle="tab">' . OSCOM::getDef('email_type_html') . '</a></li>' . "\n" .
' <li role="presentation"><a href="#plain_preview" aria-controls="plain_preview" role="tab" data-toggle="tab">' . OSCOM::getDef('email_type_plain') . '</a></li>' . "\n" .
' </ul>' . "\n" .
' <div class="tab-content">' . "\n" .
' <div role="tabpanel" class="tab-pane active" id="html_preview">' . "\n" .
' <iframe id="emailHtmlPreviewContent" style="width: 100%; height: 400px; border: 0;"></iframe>' . "\n" .
' <script id="emailHtmlPreview" type="x-tmpl-mustache">' . "\n" .
' ' . HTML::outputProtected($this->content_html) . "\n" .
' </script>' . "\n" .
' <script>' . "\n" .
' $(function() {' . "\n" .
' var content = $(\'<div />\').html($(\'#emailHtmlPreview\').html()).text();' . "\n" .
' $(\'#emailHtmlPreviewContent\').contents().find(\'html\').html(content);' . "\n" .
' });' . "\n" .
' </script>' . "\n" .
' </div>' . "\n" .
' <div role="tabpanel" class="tab-pane" id="plain_preview">' . "\n" .
' ' . nl2br(HTML::outputProtected($this->content)) . "\n" .
' </div>' . "\n" .
' </div>' . "\n" .
' </td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>&nbsp;</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . HTML::form('confirm', OSCOM::link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nID=' . $_GET['nID'] . '&action=confirm_send')) . "\n" .
' <tr>' . "\n" .
' <td class="smallText" align="right">';
if (sizeof($audience) > 0) {
if (isset($_GET['global']) && ($_GET['global'] == 'true')) {
Expand All @@ -188,7 +212,8 @@ function confirm() {
}
$confirm_string .= HTML::button(OSCOM::getDef('image_cancel'), 'fa fa-close', OSCOM::link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nID=' . $_GET['nID'] . '&action=send')) . '</td>' . "\n" .
' </tr>' . "\n" .
'</table>';
'</table>' . "\n" .
'</form>';

return $confirm_string;
}
Expand Down Expand Up @@ -299,7 +324,14 @@ function send($newsletter_id) {
$notificationEmail = new Mail();
$notificationEmail->setFrom(STORE_OWNER_EMAIL_ADDRESS, STORE_OWNER);
$notificationEmail->setSubject($this->title);
$notificationEmail->setBody($this->content);

if (!empty($this->content)) {
$notificationEmail->setBodyPlain($this->content);
}

if (!empty($this->content_html)) {
$notificationEmail->setBodyHTML($this->content_html);
}

foreach ( $audience as $key => $value ) {
$notificationEmail->clearTo();
Expand Down
54 changes: 51 additions & 3 deletions catalog/admin/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@
$customerEmail = new Mail();
$customerEmail->setFrom($_POST['from']);
$customerEmail->setSubject($_POST['subject']);
$customerEmail->setBody($_POST['message']);

if (!empty($_POST['message'])) {
$customerEmail->setBodyPlain($_POST['message']);
}

if (!empty($_POST['message_html'])) {
$customerEmail->setBodyHTML($_POST['message_html']);
}

while ($Qmail->fetch()) {
$customerEmail->clearTo();
Expand Down Expand Up @@ -123,7 +130,33 @@
<td>&nbsp;</td>
</tr>
<tr>
<td class="smallText"><strong><?php echo OSCOM::getDef('text_message'); ?></strong><br /><?php echo nl2br(HTML::outputProtected($_POST['message'])); ?></td>
<td class="smallText">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#html_preview" aria-controls="html_preview" role="tab" data-toggle="tab"><?= OSCOM::getDef('email_type_html'); ?></a></li>
<li role="presentation"><a href="#plain_preview" aria-controls="plain_preview" role="tab" data-toggle="tab"><?= OSCOM::getDef('email_type_plain'); ?></a></li>
</ul>

<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="html_preview">
<iframe id="emailHtmlPreviewContent" style="width: 100%; height: 400px; border: 0;"></iframe>

<script id="emailHtmlPreview" type="x-tmpl-mustache">
<?= HTML::outputProtected($_POST['message_html']); ?>
</script>

<script>
$(function() {
var content = $('<div />').html($('#emailHtmlPreview').html()).text();
$('#emailHtmlPreviewContent').contents().find('html').html(content);
});
</script>
</div>

<div role="tabpanel" class="tab-pane" id="plain_preview">
<?= nl2br(HTML::outputProtected($_POST['message'])); ?>
</div>
</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
Expand Down Expand Up @@ -201,7 +234,22 @@
</tr>
<tr>
<td valign="top" class="main"><?php echo OSCOM::getDef('text_message'); ?></td>
<td><?php echo HTML::textareaField('message', '60', '15'); ?></td>
<td>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#html_email" aria-controls="html_email" role="tab" data-toggle="tab"><?= OSCOM::getDef('email_type_html'); ?></a></li>
<li role="presentation"><a href="#plain_email" aria-controls="plain_email" role="tab" data-toggle="tab"><?= OSCOM::getDef('email_type_plain'); ?></a></li>
</ul>

<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="html_email">
<?= HTML::textareaField('message_html', '60', '15'); ?>
</div>

<div role="tabpanel" class="tab-pane" id="plain_email">
<?= HTML::textareaField('message', '60', '15'); ?>
</div>
</div>
</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
Expand Down
Loading

0 comments on commit a7a78bd

Please sign in to comment.