/oscommerce2-mypgsql/catalog/admin/includes/modules/newsletters/newsletter.php

https://github.com/shooray/oscommerce2-mypgsql · PHP · 81 lines · 58 code · 12 blank · 11 comment · 4 complexity · 8c4698e821d960401abbf459b9930927 MD5 · raw file

  1. <?php
  2. /*
  3. $Id$
  4. osCommerce, Open Source E-Commerce Solutions
  5. http://www.oscommerce.com
  6. Copyright (c) 2002 osCommerce
  7. Released under the GNU General Public License
  8. */
  9. class newsletter {
  10. var $show_choose_audience, $title, $content;
  11. function newsletter($title, $content) {
  12. $this->show_choose_audience = false;
  13. $this->title = $title;
  14. $this->content = $content;
  15. }
  16. function choose_audience() {
  17. return false;
  18. }
  19. function confirm() {
  20. global $HTTP_GET_VARS;
  21. $mail_query = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  22. $mail = tep_db_fetch_array($mail_query);
  23. $confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
  24. ' <tr>' . "\n" .
  25. ' <td class="main"><font color="#ff0000"><strong>' . sprintf(TEXT_COUNT_CUSTOMERS, $mail['count']) . '</strong></font></td>' . "\n" .
  26. ' </tr>' . "\n" .
  27. ' <tr>' . "\n" .
  28. ' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
  29. ' </tr>' . "\n" .
  30. ' <tr>' . "\n" .
  31. ' <td class="main"><strong>' . $this->title . '</strong></td>' . "\n" .
  32. ' </tr>' . "\n" .
  33. ' <tr>' . "\n" .
  34. ' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
  35. ' </tr>' . "\n" .
  36. ' <tr>' . "\n" .
  37. ' <td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
  38. ' </tr>' . "\n" .
  39. ' <tr>' . "\n" .
  40. ' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
  41. ' </tr>' . "\n" .
  42. ' <tr>' . "\n" .
  43. ' <td class="smallText" align="right">' . tep_draw_button(IMAGE_SEND, 'mail-closed', tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'] . '&action=confirm_send'), 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link(FILENAME_NEWSLETTERS, 'page=' . $HTTP_GET_VARS['page'] . '&nID=' . $HTTP_GET_VARS['nID'])) . '</td>' . "\n" .
  44. ' </tr>' . "\n" .
  45. '</table>';
  46. return $confirm_string;
  47. }
  48. function send($newsletter_id) {
  49. $mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
  50. $mimemessage = new email(array('X-Mailer: osCommerce'));
  51. // Build the text version
  52. $text = strip_tags($this->content);
  53. if (EMAIL_USE_HTML == 'true') {
  54. $mimemessage->add_html($this->content, $text);
  55. } else {
  56. $mimemessage->add_text($text);
  57. }
  58. $mimemessage->build_message();
  59. while ($mail = tep_db_fetch_array($mail_query)) {
  60. $mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
  61. }
  62. $newsletter_id = tep_db_prepare_input($newsletter_id);
  63. tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
  64. }
  65. }
  66. ?>