[TEP-COMMIT] [CVS admin] standards updates
hpdl-OfajU3CKLf1/[email protected] 17 Aug 2004 23:59:13 -0000
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit in admin/admin/includes on MAIN
languages/english/modules/newsletters/email.php +18 added 1.1
languages/espanol/modules/newsletters/email.php +18 added 1.1
languages/german/modules/newsletters/email.php +18 added 1.1
modules/newsletters/email.php +191 added 1.1
/newsletter.php +103 -45 1.1 -> 1.2
/product_notification.php +186 -126 1.7 -> 1.8
+534 -171
4 added + 2 modified, total 6 files
standards updates
new email newsletter module to replace the "send email" page
modules now log which email addresses a newsletter has been sent to
automatically refresh the sending page at 80% of the maximum script
execution time to avoid a server timeout from occuring
----------
admin /admin /includes /languages /english /modules /newsletters
email.php added at 1.1
diff -N email.php
--- /dev/null Wed Aug 18 01:58:47 2004
+++ /tmp/cvsAAA6MaiK2 Wed Aug 18 01:59:09 2004
@@ -0,0 +1,18 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ define('MODULE_NEWSLETTER_EMAIL_TITLE', 'E-Mail');
+
+ define('MODULE_NEWSLETTER_EMAIL_TEXT_TOTAL_RECIPIENTS', 'Recipients receiving email: %s');
+
+ define('MODULE_NEWSLETTER_EMAIL_TEXT_ALL_CUSTOMERS', '-- All Customers --');
+?>
----------
admin /admin /includes /languages /espanol /modules /newsletters
email.php added at 1.1
diff -N email.php
--- /dev/null Wed Aug 18 01:58:47 2004
+++ /tmp/cvsAAAaSaOK2 Wed Aug 18 01:59:09 2004
@@ -0,0 +1,18 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ define('MODULE_NEWSLETTER_EMAIL_TITLE', 'E-Mail');
+
+ define('MODULE_NEWSLETTER_EMAIL_TEXT_TOTAL_RECIPIENTS', 'Recipients receiving email: %s');
+
+ define('MODULE_NEWSLETTER_EMAIL_TEXT_ALL_CUSTOMERS', '-- All Customers --');
+?>
----------
admin /admin /includes /languages /german /modules /newsletters
email.php added at 1.1
diff -N email.php
--- /dev/null Wed Aug 18 01:58:47 2004
+++ /tmp/cvsAAAvXaiL2 Wed Aug 18 01:59:09 2004
@@ -0,0 +1,18 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ define('MODULE_NEWSLETTER_EMAIL_TITLE', 'E-Mail');
+
+ define('MODULE_NEWSLETTER_EMAIL_TEXT_TOTAL_RECIPIENTS', 'Anzahl der Kunden, welche das E-Mail erhalten: %s');
+
+ define('MODULE_NEWSLETTER_EMAIL_TEXT_ALL_CUSTOMERS', '-- Alle Kunden --');
+?>
----------
admin /admin /includes /modules /newsletters
email.php added at 1.1
diff -N email.php
--- /dev/null Wed Aug 18 01:58:47 2004
+++ /tmp/cvsAAAd4aOL2 Wed Aug 18 01:59:10 2004
@@ -0,0 +1,191 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class osC_Newsletter_email {
+
+/* Private methods */
+
+ var $_title,
+ $_has_audience_selection = true,
+ $_newsletter_title,
+ $_newsletter_content,
+ $_newsletter_id,
+ $_audience_size = 0;
+
+/* Class constructor */
+
+ function osC_Newsletter_email($title = '', $content = '', $newsletter_id = '') {
+ $this->_title = MODULE_NEWSLETTER_EMAIL_TITLE;
+
+ $this->_newsletter_title = $title;
+ $this->_newsletter_content = $content;
+ $this->_newsletter_id = $newsletter_id;
+ }
+
+/* Public methods */
+
+ function getTitle() {
+ return $this->_title;
+ }
+
+ function hasAudienceSelection() {
+ if ($this->_has_audience_selection === true) {
+ return true;
+ }
+
+ return false;
+ }
+
+ function showAudienceSelectionForm() {
+ if (PHP_VERSION < 4.1) {
+ global $_GET;
+ }
+
+ global $osC_Database;
+
+ $customers_array = array(array('id' => '***', 'text' => MODULE_NEWSLETTER_EMAIL_TEXT_ALL_CUSTOMERS));
+
+ $Qcustomers = $osC_Database->query('select customers_id, customers_firstname, customers_lastname, customers_email_address from :table_customers order by customers_lastname');
+ $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
+ $Qcustomers->execute();
+
+ while ($Qcustomers->next()) {
+ $customers_array[] = array('id' => $Qcustomers->valueInt('customers_id'),
+ 'text' => $Qcustomers->value('customers_lastname') . ', ' . $Qcustomers->value('customers_firstname') . ' (' . $Qcustomers->value('customers_email_address') . ')');
+ }
+
+ $Qcustomers->freeResult();
+
+ $audience_form = tep_draw_form('customers', FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID'] . '&action=nmConfirm') .
+ ' <p align="center">' . osc_draw_pull_down_menu('customer', $customers_array, '', 'size="20" style="width: 100%;"') . '</p>' .
+ ' <p align="right"><input type="submit" value="' . BUTTON_OK . '" class="operationButton"> <input type="button" value="' . BUTTON_CANCEL . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID']) . '\';" class="operationButton"></p>' .
+ '</form>';
+
+ return $audience_form;
+ }
+
+ function showConfirmation() {
+ if (PHP_VERSION < 4.1) {
+ global $_GET, $_POST;
+ }
+
+ global $osC_Database;
+
+ if (isset($_POST['customer']) && !empty($_POST['customer'])) {
+ $Qcustomers = $osC_Database->query('select count(customers_id) as total from :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where nl.email_address is null');
+ $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
+ $Qcustomers->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
+ $Qcustomers->bindInt(':newsletters_id', $this->_newsletter_id);
+
+ if (is_numeric($_POST['customer'])) {
+ $Qcustomers->appendQuery('and c.customers_id = :customers_id');
+ $Qcustomers->bindInt(':customers_id', $_POST['customer']);
+ }
+
+ $Qcustomers->execute();
+
+ $this->_audience_size =+ $Qcustomers->valueInt('total');
+ }
+
+ $confirmation_string = '<p><font color="#ff0000"><b>' . sprintf(MODULE_NEWSLETTER_EMAIL_TEXT_TOTAL_RECIPIENTS, $this->_audience_size) . '</b></font></p>' .
+ '<p><b>' . $this->_newsletter_title . '</b></p>' .
+ '<p>' . nl2br(tep_output_string_protected($this->_newsletter_content)) . '</p>' .
+ tep_draw_form('confirm', FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID'] . '&action=nmSendConfirm') .
+ '<p align="right">';
+
+ if ($this->_audience_size > 0) {
+ $confirmation_string .= osc_draw_hidden_field('customer', $_POST['customer']) .
+ '<input type="submit" value="' . BUTTON_SEND . '" class="operationButton"> ';
+ }
+
+ $confirmation_string .= '<input type="button" value="' . BUTTON_BACK . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID'] . '&action=nmSend') . '\'" class="operationButton"> <input type="button" value="' . BUTTON_CANCEL . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID']) . '\'" class="operationButton"></p>' .
+ '</form>';
+
+ return $confirmation_string;
+ }
+
+ function sendEmail() {
+ if (PHP_VERSION < 4.1) {
+ global $_GET, $_POST;
+ }
+
+ global $osC_Database;
+
+ $max_execution_time = 0.8 * (int)ini_get('max_execution_time');
+ $time_start = explode(' ', PAGE_PARSE_START_TIME);
+
+ $audience = array();
+
+ $customer = '';
+ if (isset($_POST['customer']) && !empty($_POST['customer'])) {
+ $customer = $_POST['customer'];
+ } elseif (isset($_GET['customer']) && !empty($_GET['customer'])) {
+ $customer = $_GET['customer'];
+ }
+
+ if (!empty($customer)) {
+ $Qcustomers = $osC_Database->query('select customers_id, customers_firstname, customers_lastname, customers_email_address from :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where nl.email_address is null');
+ $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
+ $Qcustomers->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
+ $Qcustomers->bindInt(':newsletters_id', $this->_newsletter_id);
+
+ if (is_numeric($customer)) {
+ $Qcustomers->appendQuery('and c.customers_id = :customers_id');
+ $Qcustomers->bindInt(':customers_id', $customer);
+ }
+
+ $Qcustomers->execute();
+
+ while ($Qcustomers->next()) {
+ if (!isset($audience[$Qcustomers->valueInt('customers_id')])) {
+ $audience[$Qcustomers->valueInt('customers_id')] = array('firstname' => $Qcustomers->value('customers_firstname'),
+ 'lastname' => $Qcustomers->value('customers_lastname'),
+ 'email_address' => $Qcustomers->value('customers_email_address'));
+ }
+ }
+
+ $Qcustomers->freeResult();
+
+ if (sizeof($audience) > 0) {
+ $mimemessage = new email(array(base64_decode('WC1NYWlsZXI6IG9zQ29tbWVyY2UgKGh0dHA6Ly93d3cub3Njb21tZXJjZS5jb20p')));
+ $mimemessage->add_text($this->_newsletter_content);
+ $mimemessage->build_message();
+
+ foreach ($audience as $key => $value) {
+ $mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], '', EMAIL_FROM, $this->_newsletter_title);
+
+ $Qlog = $osC_Database->query('insert into :table_newsletters_log (newsletters_id, email_address, date_sent) values (:newsletters_id, :email_address, now())');
+ $Qlog->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
+ $Qlog->bindInt(':newsletters_id', $this->_newsletter_id);
+ $Qlog->bindValue(':email_address', $value['email_address']);
+ $Qlog->execute();
+
+ $time_end = explode(' ', microtime());
+ $timer_total = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);
+
+ if ($timer_total > $max_execution_time) {
+ echo '<p><font color="#38BB68"><b>' . TEXT_REFRESHING_PAGE . '</b></font></p>' .
+ '<p><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $this->_newsletter_id . '&action=nmSendConfirm&customer=' . $customer) . '">' . TEXT_CONTINUE_MANUALLY . '</a></p>' .
+ '<META HTTP-EQUIV="refresh" content="2; URL=' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $this->_newsletter_id . '&action=nmSendConfirm&customer=' . $customer) . '">';
+ exit;
+ }
+ }
+ }
+
+ $Qupdate = $osC_Database->query('update :table_newsletters set date_sent = now(), status = 1 where newsletters_id = :newsletters_id');
+ $Qupdate->bindTable(':table_newsletters', TABLE_NEWSLETTERS);
+ $Qupdate->bindInt(':newsletters_id', $this->_newsletter_id);
+ $Qupdate->execute();
+ }
+ }
+ }
+?>
----------
admin /admin /includes /modules /newsletters
newsletter.php 1.1 -> 1.2
diff -u -r1.1 -r1.2
--- newsletter.php 2002/03/08 18:38:18 1.1
+++ newsletter.php 2004/08/17 23:59:10 1.2
@@ -5,69 +5,127 @@
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
- Copyright (c) 2002 osCommerce
+ Copyright (c) 2004 osCommerce
Released under the GNU General Public License
*/
- class newsletter {
- var $show_choose_audience, $title, $content;
+ class osC_Newsletter_newsletter {
- function newsletter($title, $content) {
- $this->show_choose_audience = false;
- $this->title = $title;
- $this->content = $content;
+/* Private methods */
+
+ var $_title,
+ $_has_audience_selection = false,
+ $_newsletter_title,
+ $_newsletter_content,
+ $_newsletter_id,
+ $_audience_size = 0;
+
+/* Class constructor */
+
+ function osC_Newsletter_newsletter($title = '', $content = '', $newsletter_id = '') {
+ $this->_title = MODULE_NEWSLETTER_NEWSLETTER_TITLE;
+
+ $this->_newsletter_title = $title;
+ $this->_newsletter_content = $content;
+ $this->_newsletter_id = $newsletter_id;
+ }
+
+/* Public methods */
+
+ function getTitle() {
+ return $this->_title;
+ }
+
+ function hasAudienceSelection() {
+ if ($this->_has_audience_selection === true) {
+ return true;
+ }
+
+ return false;
}
- function choose_audience() {
+ function showAudienceSelectionForm() {
return false;
}
+
+ function showConfirmation() {
+ if (PHP_VERSION < 4.1) {
+ global $_GET;
+ }
+
+ global $osC_Database;
- function confirm() {
- global $HTTP_GET_VARS;
+ $Qrecipients = $osC_Database->query('select count(*) as total from :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where c.customers_newsletter = 1 and nl.email_address is null');
+ $Qrecipients->bindTable(':table_customers', TABLE_CUSTOMERS);
+ $Qrecipients->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
+ $Qrecipients->bindInt(':newsletters_id', $this->_newsletter_id);
+ $Qrecipients->execute();
+
+ $this->_audience_size = $Qrecipients->valueInt('total');
+
+ $confirmation_string = '<p><font color="#ff0000"><b>' . sprintf(MODULE_NEWSLETTER_NEWSLETTER_TEXT_TOTAL_RECIPIENTS, $this->_audience_size) . '</b></font></p>' .
+ '<p><b>' . $this->_newsletter_title . '</b></p>' .
+ '<p>' . nl2br(tep_output_string_protected($this->_newsletter_content)) . '</p>' .
+ '<p align="right">';
- $mail_query = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
- $mail = tep_db_fetch_array($mail_query);
+ if ($this->_audience_size > 0) {
+ $confirmation_string .= '<input type="button" value="' . BUTTON_SEND . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID'] . '&action=nmSendConfirm') . '\';" class="operationButton"> ';
+ }
- $confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
- ' <tr>' . "\n" .
- ' <td class="main"><font color="#ff0000"><b>' . sprintf(TEXT_COUNT_CUSTOMERS, $mail['count']) . '</b></font></td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td class="main"><b>' . $this->title . '</b></td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td align="right"><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . '">' . tep_image_button('button_send.gif', IMAGE_SEND) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></td>' . "\n" .
- ' </tr>' . "\n" .
- '</table>';
+ $confirmation_string .= '<input type="button" value="' . BUTTON_CANCEL . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID']) . '\'" class="operationButton"></p>';
- return $confirm_string;
+ return $confirmation_string;
}
+
+ function sendEmail() {
+ if (PHP_VERSION < 4.1) {
+ global $_GET;
+ }
+
+ global $osC_Database;
+
+ $max_execution_time = 0.8 * (int)ini_get('max_execution_time');
+ $time_start = explode(' ', PAGE_PARSE_START_TIME);
- function send($newsletter_id) {
- $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
+ $Qrecipients = $osC_Database->query('select c.customers_firstname, c.customers_lastname, c.customers_email_address from :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where c.customers_newsletter = 1 and nl.email_address is null');
+ $Qrecipients->bindTable(':table_customers', TABLE_CUSTOMERS);
+ $Qrecipients->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
+ $Qrecipients->bindInt(':newsletters_id', $this->_newsletter_id);
+ $Qrecipients->execute();
+
+ if ($Qrecipients->numberOfRows() > 0) {
+ $mimemessage = new email(array(base64_decode('WC1NYWlsZXI6IG9zQ29tbWVyY2UgKGh0dHA6Ly93d3cub3Njb21tZXJjZS5jb20p')));
+ $mimemessage->add_text($this->_newsletter_content);
+ $mimemessage->build_message();
+
+ while ($Qrecipients->next()) {
+ $mimemessage->send($Qrecipients->value('customers_firstname') . ' ' . $Qrecipients->value('customers_lastname'), $Qrecipients->value('customers_email_address'), '', EMAIL_FROM, $this->_newsletter_title);
+
+ $Qlog = $osC_Database->query('insert into :table_newsletters_log (newsletters_id, email_address, date_sent) values (:newsletters_id, :email_address, now())');
+ $Qlog->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
+ $Qlog->bindInt(':newsletters_id', $this->_newsletter_id);
+ $Qlog->bindValue(':email_address', $Qrecipients->value('customers_email_address'));
+ $Qlog->execute();
+
+ $time_end = explode(' ', microtime());
+ $timer_total = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);
+
+ if ($timer_total > $max_execution_time) {
+ echo '<p><font color="#38BB68"><b>' . TEXT_REFRESHING_PAGE . '</b></font></p>' .
+ '<p><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $this->_newsletter_id . '&action=nmSendConfirm') . '">' . TEXT_CONTINUE_MANUALLY . '</a></p>' .
+ '<META HTTP-EQUIV="refresh" content="2; URL=' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $this->_newsletter_id . '&action=nmSendConfirm') . '">';
+ exit;
+ }
+ }
- $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
- $mimemessage->add_text($this->content);
- $mimemessage->build_message();
- while ($mail = tep_db_fetch_array($mail_query)) {
- $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
+ $Qrecipients->freeResult();
}
- $newsletter_id = tep_db_prepare_input($newsletter_id);
- tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
+ $Qupdate = $osC_Database->query('update :table_newsletters set date_sent = now(), status = 1 where newsletters_id = :newsletters_id');
+ $Qupdate->bindTable(':table_newsletters', TABLE_NEWSLETTERS);
+ $Qupdate->bindInt(':newsletters_id', $this->_newsletter_id);
+ $Qupdate->execute();
}
}
?>
----------
admin /admin /includes /modules /newsletters
product_notification.php 1.7 -> 1.8
diff -u -r1.7 -r1.8
--- product_notification.php 2003/06/30 11:02:48 1.7
+++ product_notification.php 2004/08/17 23:59:10 1.8
@@ -5,31 +5,69 @@
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
- Copyright (c) 2002 osCommerce
+ Copyright (c) 2004 osCommerce
Released under the GNU General Public License
*/
- class product_notification {
- var $show_choose_audience, $title, $content;
+ class osC_Newsletter_product_notification {
- function product_notification($title, $content) {
- $this->show_choose_audience = true;
- $this->title = $title;
- $this->content = $content;
+/* Private methods */
+
+ var $_title,
+ $_has_audience_selection = true,
+ $_newsletter_title,
+ $_newsletter_content,
+ $_newsletter_id,
+ $_audience_size = 0;
+
+/* Class constructor */
+
+ function osC_Newsletter_product_notification($title = '', $content = '', $newsletter_id = '') {
+ $this->_title = MODULE_NEWSLETTER_PRODUCT_NOTIFICATION_TITLE;
+
+ $this->_newsletter_title = $title;
+ $this->_newsletter_content = $content;
+ $this->_newsletter_id = $newsletter_id;
+ }
+
+/* Public methods */
+
+ function getTitle() {
+ return $this->_title;
+ }
+
+ function hasAudienceSelection() {
+ if ($this->_has_audience_selection === true) {
+ return true;
+ }
+
+ return false;
}
+
+ function showAudienceSelectionForm() {
+ if (PHP_VERSION < 4.1) {
+ global $_GET;
+ }
- function choose_audience() {
- global $HTTP_GET_VARS, $languages_id;
+ global $osC_Database, $osC_Session;
$products_array = array();
- $products_query = tep_db_query("select pd.products_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where pd.language_id = '" . $languages_id . "' and pd.products_id = p.products_id and p.products_status = '1' order by pd.products_name");
- while ($products = tep_db_fetch_array($products_query)) {
- $products_array[] = array('id' => $products['products_id'],
- 'text' => $products['products_name']);
+
+ $Qproducts = $osC_Database->query('select pd.products_id, pd.products_name from :table_products p, :table_products_description pd where pd.language_id = :language_id and pd.products_id = p.products_id and p.products_status = 1 order by pd.products_name');
+ $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qproducts->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qproducts->execute();
+
+ while ($Qproducts->next()) {
+ $products_array[] = array('id' => $Qproducts->valueInt('products_id'),
+ 'text' => $Qproducts->value('products_name'));
}
+
+ $Qproducts->freeResult();
-$choose_audience_string = '<script language="javascript"><!--
+ $audience_form = '<script language="javascript"><!--
function mover(move) {
if (move == \'remove\') {
for (x=0; x<(document.notifications.products.length); x++) {
@@ -65,7 +103,7 @@
}
if (x<1) {
- alert(\'' . JS_PLEASE_SELECT_PRODUCTS . '\');
+ alert(\'' . MODULE_NEWSLETTER_PRODUCT_NOTIFICATION_JS_PLEASE_SELECT_PRODUCTS . '\');
return false;
} else {
return true;
@@ -73,144 +111,166 @@
}
//--></script>';
- $global_button = '<script language="javascript"><!--' . "\n" .
- 'document.write(\'<input type="button" value="' . BUTTON_GLOBAL . '" style="width: 8em;" onclick="document.location=\\\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm&global=true') . '\\\'">\');' . "\n" .
- '//--></script><noscript><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm&global=true') . '">[ ' . BUTTON_GLOBAL . ' ]</a></noscript>';
-
- $cancel_button = '<script language="javascript"><!--' . "\n" .
- 'document.write(\'<input type="button" value="' . BUTTON_CANCEL . '" style="width: 8em;" onclick="document.location=\\\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '\\\'">\');' . "\n" .
- '//--></script><noscript><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">[ ' . BUTTON_CANCEL . ' ]</a></noscript>';
-
- $choose_audience_string .= '<form name="notifications" action="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm') . '" method="post" onSubmit="return selectAll(\'notifications\', \'chosen[]\')"><table border="0" width="100%" cellspacing="0" cellpadding="2">' . "\n" .
- ' <tr>' . "\n" .
- ' <td align="center" class="main"><b>' . TEXT_PRODUCTS . '</b><br>' . tep_draw_pull_down_menu('products', $products_array, '', 'size="20" style="width: 20em;" multiple') . '</td>' . "\n" .
- ' <td align="center" class="main"> <br>' . $global_button . '<br><br><br><input type="button" value="' . BUTTON_SELECT . '" style="width: 8em;" onClick="mover(\'remove\');"><br><br><input type="button" value="' . BUTTON_UNSELECT . '" style="width: 8em;" onClick="mover(\'add\');"><br><br><br><input type="submit" value="' . BUTTON_SUBMIT . '" style="width: 8em;"><br><br>' . $cancel_button . '</td>' . "\n" .
- ' <td align="center" class="main"><b>' . TEXT_SELECTED_PRODUCTS . '</b><br>' . tep_draw_pull_down_menu('chosen[]', array(), '', 'size="20" style="width: 20em;" multiple') . '</td>' . "\n" .
- ' </tr>' . "\n" .
- '</table></form>';
+ $audience_form .= tep_draw_form('notifications', FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID'] . '&action=nmConfirm', 'post', 'onSubmit="return selectAll(\'notifications\', \'chosen[]\');"') .
+ ' <table border="0" width="100%" cellspacing="0" cellpadding="2">' .
+ ' <tr>' .
+ ' <td align="center" class="main"><b>' . MODULE_NEWSLETTER_PRODUCT_NOTIFICATION_TABLE_HEADING_PRODUCTS . '</b><br>' . osc_draw_pull_down_menu('products', $products_array, '', 'size="20" style="width: 20em;" multiple') . '</td>' .
+ ' <td align="center" class="main"> <br><input type="button" value="' . MODULE_NEWSLETTER_PRODUCT_NOTIFICATION_BUTTON_GLOBAL . '" style="width: 90px;" onClick="document.location=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID'] . '&action=nmConfirm&global=true') . '\';" class="operationButton"><br><br><br><input type="button" value="' . MODULE_NEWSLETTER_PRODUCT_NOTIFICATION_BUTTON_SELECT . '" style="width: 90px;" onClick="mover(\'remove\');" class="infoBoxButton"><br><br><input type="button" value="' . MODULE_NEWSLETTER_PRODUCT_NOTIFICATION_BUTTON_UNSELECT . '" style="width: 90px;" onClick="mover(\'add\');" class="infoBoxButton"><br><br><br><input type="submit" value="' . BUTTON_OK . '" style="width: 90px;" class="o
perationButton"><br><br><input type="button" value="' . BUTTON_CANCEL . '" style="width: 90px;" onClick="document.location=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=[...]
+ ' <td align="center" class="main"><b>' . MODULE_NEWSLETTER_PRODUCT_NOTIFICATION_TABLE_HEADING_SELECTED_PRODUCTS . '</b><br>' . osc_draw_pull_down_menu('chosen[]', array(), '', 'size="20" style="width: 20em;" multiple') . '</td>' .
+ ' </tr>' .
+ ' </table>' .
+ '</form>';
- return $choose_audience_string;
+ return $audience_form;
}
- function confirm() {
- global $HTTP_GET_VARS, $HTTP_POST_VARS;
+ function showConfirmation() {
+ if (PHP_VERSION < 4.1) {
+ global $_GET, $_POST;
+ }
- $audience = array();
+ global $osC_Database;
+
+ if ( (isset($_POST['chosen']) && !empty($_POST['chosen'])) || (isset($_GET['global']) && ($_GET['global'] == 'true')) ) {
+ $Qcustomers = $osC_Database->query('select count(customers_info_id) as total from :table_customers_info where global_product_notifications = 1');
+ $Qcustomers->bindTable(':table_customers_info', TABLE_CUSTOMERS_INFO);
+ $Qcustomers->execute();
+
+ $this->_audience_size = $Qcustomers->valueInt('total');
+
+ $Qcustomers = $osC_Database->query('select count(distinct pn.customers_id) as total from :table_products_notifications pn, :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where pn.customers_id = c.customers_id and nl.email_address is null');
+ $Qcustomers->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS);
+ $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
+ $Qcustomers->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
+ $Qcustomers->bindInt(':newsletters_id', $this->_newsletter_id);
- if (isset($HTTP_GET_VARS['global']) && ($HTTP_GET_VARS['global'] == 'true')) {
- $products_query = tep_db_query("select distinct customers_id from " . TABLE_PRODUCTS_NOTIFICATIONS);
- while ($products = tep_db_fetch_array($products_query)) {
- $audience[$products['customers_id']] = '1';
- }
-
- $customers_query = tep_db_query("select customers_info_id from " . TABLE_CUSTOMERS_INFO . " where global_product_notifications = '1'");
- while ($customers = tep_db_fetch_array($customers_query)) {
- $audience[$customers['customers_info_id']] = '1';
- }
- } else {
- $chosen = $HTTP_POST_VARS['chosen'];
-
- $ids = implode(',', $chosen);
-
- $products_query = tep_db_query("select distinct customers_id from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id in (" . $ids . ")");
- while ($products = tep_db_fetch_array($products_query)) {
- $audience[$products['customers_id']] = '1';
- }
-
- $customers_query = tep_db_query("select customers_info_id from " . TABLE_CUSTOMERS_INFO . " where global_product_notifications = '1'");
- while ($customers = tep_db_fetch_array($customers_query)) {
- $audience[$customers['customers_info_id']] = '1';
+ if (isset($_POST['chosen']) && !empty($_POST['chosen'])) {
+ $Qcustomers->appendQuery('and pn.products_id in (:products_id)');
+ $Qcustomers->bindRaw(':products_id', implode(', ', $_POST['chosen']));
}
+
+ $Qcustomers->execute();
+
+ $this->_audience_size =+ $Qcustomers->valueInt('total');
}
- $confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
- ' <tr>' . "\n" .
- ' <td class="main"><font color="#ff0000"><b>' . sprintf(TEXT_COUNT_CUSTOMERS, sizeof($audience)) . '</b></font></td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td class="main"><b>' . $this->title . '</b></td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . "\n" .
- ' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
- ' </tr>' . "\n" .
- ' <tr>' . tep_draw_form('confirm', FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send') . "\n" .
- ' <td align="right">';
- if (sizeof($audience) > 0) {
- if (isset($HTTP_GET_VARS['global']) && ($HTTP_GET_VARS['global'] == 'true')) {
- $confirm_string .= tep_draw_hidden_field('global', 'true');
- } else {
- for ($i = 0, $n = sizeof($chosen); $i < $n; $i++) {
- $confirm_string .= tep_draw_hidden_field('chosen[]', $chosen[$i]);
+ $confirmation_string = '<p><font color="#ff0000"><b>' . sprintf(MODULE_NEWSLETTER_PRODUCT_NOTIFICATION_TEXT_TOTAL_RECIPIENTS, $this->_audience_size) . '</b></font></p>' .
+ '<p><b>' . $this->_newsletter_title . '</b></p>' .
+ '<p>' . nl2br(tep_output_string_protected($this->_newsletter_content)) . '</p>' .
+ tep_draw_form('confirm', FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID'] . '&action=nmSendConfirm') .
+ '<p align="right">';
+
+ if ($this->_audience_size > 0) {
+ if (isset($_GET['global']) && ($_GET['global'] == 'true')) {
+ $confirmation_string .= osc_draw_hidden_field('global', 'true');
+ } elseif (isset($_POST['chosen']) && !empty($_POST['chosen'])) {
+ for ($i=0, $n=sizeof($_POST['chosen']); $i<$n; $i++) {
+ $confirmation_string .= osc_draw_hidden_field('chosen[]', $_POST['chosen'][$i]);
}
}
- $confirm_string .= tep_image_submit('button_send.gif', IMAGE_SEND) . ' ';
+
+ $confirmation_string .= '<input type="submit" value="' . BUTTON_SEND . '" class="operationButton"> ';
}
- $confirm_string .= '<a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=send') . '">' . tep_image_button('button_back.gif', IMAGE_BACK) . '</a> <a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></td>' . "\n" .
- ' </tr>' . "\n" .
- '</table>';
+
+ $confirmation_string .= '<input type="button" value="' . BUTTON_BACK . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID'] . '&action=nmSend') . '\'" class="operationButton"> <input type="button" value="' . BUTTON_CANCEL . '" onClick="document.location.href=\'' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $_GET['nmID']) . '\'" class="operationButton"></p>' .
+ '</form>';
- return $confirm_string;
+ return $confirmation_string;
}
- function send($newsletter_id) {
- global $HTTP_POST_VARS;
+ function sendEmail() {
+ if (PHP_VERSION < 4.1) {
+ global $_GET, $_POST;
+ }
- $audience = array();
+ global $osC_Database;
- if (isset($HTTP_POST_VARS['global']) && ($HTTP_POST_VARS['global'] == 'true')) {
- $products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id");
- while ($products = tep_db_fetch_array($products_query)) {
- $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
- 'lastname' => $products['customers_lastname'],
- 'email_address' => $products['customers_email_address']);
- }
+ $max_execution_time = 0.8 * (int)ini_get('max_execution_time');
+ $time_start = explode(' ', PAGE_PARSE_START_TIME);
+
+ if (isset($_POST['chosen'])) {
+ $chosen = $_POST['chosen'];
+ } elseif (isset($_GET['chosen'])) {
+ $chosen = $_GET['chosen'];
+ } elseif (isset($_POST['global'])) {
+ $global = $_POST['global'];
+ } elseif (isset($_GET['global'])) {
+ $global = $_GET['global'];
+ }
- $customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
- while ($customers = tep_db_fetch_array($customers_query)) {
- $audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
- 'lastname' => $customers['customers_lastname'],
- 'email_address' => $customers['customers_email_address']);
+ $chosen_get_string = '';
+ if (isset($chosen) && !empty($chosen)) {
+ foreach ($chosen as $id) {
+ $chosen_get_string .= 'chosen[]=' . $id . '&';
}
- } else {
- $chosen = $HTTP_POST_VARS['chosen'];
+ }
- $ids = implode(',', $chosen);
+ $audience = array();
- $products_query = tep_db_query("select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_PRODUCTS_NOTIFICATIONS . " pn where c.customers_id = pn.customers_id and pn.products_id in (" . $ids . ")");
- while ($products = tep_db_fetch_array($products_query)) {
- $audience[$products['customers_id']] = array('firstname' => $products['customers_firstname'],
- 'lastname' => $products['customers_lastname'],
- 'email_address' => $products['customers_email_address']);
+ $Qcustomers = $osC_Database->query('select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from :table_customers c, :table_customers_info ci where ci.global_product_notifications = 1 and ci.customers_info_id = c.customers_id');
+ $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
+ $Qcustomers->bindTable(':table_customers_info', TABLE_CUSTOMERS_INFO);
+ $Qcustomers->execute();
+
+ while ($Qcustomers->next()) {
+ if (!isset($audience[$Qcustomers->valueInt('customers_id')])) {
+ $audience[$Qcustomers->valueInt('customers_id')] = array('firstname' => $Qcustomers->value('customers_firstname'),
+ 'lastname' => $Qcustomers->value('customers_lastname'),
+ 'email_address' => $Qcustomers->value('customers_email_address'));
}
+ }
- $customers_query = tep_db_query("select c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_INFO . " ci where c.customers_id = ci.customers_info_id and ci.global_product_notifications = '1'");
- while ($customers = tep_db_fetch_array($customers_query)) {
- $audience[$customers['customers_id']] = array('firstname' => $customers['customers_firstname'],
- 'lastname' => $customers['customers_lastname'],
- 'email_address' => $customers['customers_email_address']);
- }
+ $Qcustomers = $osC_Database->query('select distinct pn.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address from :table_products_notifications pn, :table_customers c left join :table_newsletters_log nl on (c.customers_email_address = nl.email_address and nl.newsletters_id = :newsletters_id) where pn.customers_id = c.customers_id and nl.email_address is null');
+ $Qcustomers->bindTable(':table_products_notifications', TABLE_PRODUCTS_NOTIFICATIONS);
+ $Qcustomers->bindTable(':table_customers', TABLE_CUSTOMERS);
+ $Qcustomers->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
+ $Qcustomers->bindInt(':newsletters_id', $this->_newsletter_id);
+
+ if (isset($chosen) && !empty($chosen)) {
+ $Qcustomers->appendQuery('and pn.products_id in (:products_id)');
+ $Qcustomers->bindRaw(':products_id', implode(', ', $chosen));
}
+
+ $Qcustomers->execute();
- $mimemessage = new email(array('X-Mailer: osCommerce bulk mailer'));
- $mimemessage->add_text($this->content);
- $mimemessage->build_message();
+ while ($Qcustomers->next()) {
+ if (!isset($audience[$Qcustomers->valueInt('customers_id')])) {
+ $audience[$Qcustomers->valueInt('customers_id')] = array('firstname' => $Qcustomers->value('customers_firstname'),
+ 'lastname' => $Qcustomers->value('customers_lastname'),
+ 'email_address' => $Qcustomers->value('customers_email_address'));
+ }
+ }
- reset($audience);
- while (list($key, $value) = each ($audience)) {
- $mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], '', EMAIL_FROM, $this->title);
+ if (sizeof($audience) > 0) {
+ $mimemessage = new email(array(base64_decode('WC1NYWlsZXI6IG9zQ29tbWVyY2UgKGh0dHA6Ly93d3cub3Njb21tZXJjZS5jb20p')));
+ $mimemessage->add_text($this->_newsletter_content);
+ $mimemessage->build_message();
+
+ foreach ($audience as $key => $value) {
+ $mimemessage->send($value['firstname'] . ' ' . $value['lastname'], $value['email_address'], '', EMAIL_FROM, $this->_newsletter_title);
+
+ $Qlog = $osC_Database->query('insert into :table_newsletters_log (newsletters_id, email_address, date_sent) values (:newsletters_id, :email_address, now())');
+ $Qlog->bindTable(':table_newsletters_log', TABLE_NEWSLETTERS_LOG);
+ $Qlog->bindInt(':newsletters_id', $this->_newsletter_id);
+ $Qlog->bindValue(':email_address', $value['email_address']);
+ $Qlog->execute();
+
+ $time_end = explode(' ', microtime());
+ $timer_total = number_format(($time_end[1] + $time_end[0] - ($time_start[1] + $time_start[0])), 3);
+
+ if ($timer_total > $max_execution_time) {
+ echo '<p><font color="#38BB68"><b>' . TEXT_REFRESHING_PAGE . '</b></font></p>' .
+ '<p><a href="' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $this->_newsletter_id . '&action=nmSendConfirm&' . ((isset($global) && ($global == 'true')) ? 'global=true' : $chosen_get_string)) . '">' . TEXT_CONTINUE_MANUALLY . '</a></p>' .
+ '<META HTTP-EQUIV="refresh" content="2; URL=' . tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $_GET['page'] . '&nmID=' . $this->_newsletter_id . '&action=nmSendConfirm&' . ((isset($global) && ($global == 'true')) ? 'global=true' : $chosen_get_string)) . '">';
+ exit;
+ }
+ }
}
- $newsletter_id = tep_db_prepare_input($newsletter_id);
- tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
+ $Qupdate = $osC_Database->query('update :table_newsletters set date_sent = now(), status = 1 where newsletters_id = :newsletters_id');
+ $Qupdate->bindTable(':table_newsletters', TABLE_NEWSLETTERS);
+ $Qupdate->bindInt(':newsletters_id', $this->_newsletter_id);
+ $Qupdate->execute();
}
}
?>
[Note: Some over-long lines of diff output only partialy shown]
CVSspam 0.2.9
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285