Even more rewrites/fixes from EL branch (please report any broken part after you...
[mailer.git] / inc / modules / admin / what-send_newsletter.php
index 8f85d134b969370c01cc3657a70d0d026bdb4896..22c3685833d5cbc586f4cb32bb3c0ea47b57ca10 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 09/28/2003 *
- * ===============                              Last change: 03/04/2005 *
+ * Mailer v0.2.1-FINAL                                Start: 09/28/2003 *
+ * ===================                          Last change: 03/04/2005 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : what-send_newsletter.php                         *
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Verwalten von HTML- oder Text-Newslettern        *
  * -------------------------------------------------------------------- *
- *                                                                      *
+ * $Revision::                                                        $ *
+ * $Date::                                                            $ *
+ * $Tag:: 0.2.1-FINAL                                                 $ *
+ * $Author::                                                          $ *
+ * Needs to be in all Files and every File needs "svn propset           *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  ************************************************************************/
 
 // Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
-{
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
-}
+if ((!defined('__SECURITY')) || (!isAdmin())) {
+       die();
+} // END - if
+
 // Add description as navigation point
-ADD_DESCR("admin", basename(__FILE__));
+addMenuDescription('admin', __FILE__);
 
-OPEN_TABLE("100%", "admin_content admin_content_align", "");
-if (isset($_POST['ok']))
-{
-       $result = SQL_QUERY("SELECT userid, email FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND nl_receive='Y' ORDER BY userid", __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) > 0)
-       {
+if (isFormSent()) {
+       $result = SQL_QUERY("SELECT
+       `userid`, `email`
+FROM
+       `{?_MYSQL_PREFIX?}_user_data`
+WHERE
+       `status`='CONFIRMED' AND `nl_receive`='Y'
+ORDER BY
+       `userid` ASC", __FILE__, __LINE__);
+       if (SQL_NUMROWS($result) > 0) {
                // Members are available so we can send out the newsletter!
-               while (list($id, $email) = SQL_FETCHROW($result))
-               {
+               while ($content = SQL_FETCHARRAY($result)) {
                        // Construct mail...
-                       $template = "newsletter";
+                       $template = 'newsletter';
 
                        // Check for extension and sending-mode
-                       if (!EXT_IS_ACTIVE("html_mail", true) && ($_POST['mode'] == "html"))
-                       {
+                       if (!isExtensionActive('html_mail', true) && (postRequestParameter('mode') == 'html')) {
                                // Set mode to text mode
-                               $_POST['mode'] == "text";
-                       }
-                        elseif ($_POST['mode'] == "html")
-                       {
+                               postRequestParameter('mode') == 'text';
+                       } elseif (postRequestParameter('mode') == 'html') {
                                // Set HTML templates
-                               $template = "newsletter_html";
+                               $template = 'newsletter_html';
                        }
 
                        // Compile message
-                       $_POST['text'] = stripslashes(COMPILE_CODE($_POST['text']));
+                       setPostRequestParameter('text', preCompileCode(postRequestParameter('text')));
 
                        // Load template
-                       $msg = LOAD_EMAIL_TEMPLATE($template, $_POST['text'], $id);
+                       $message = loadEmailTemplate($template, array('text' => postRequestParameter('text')), $content['userid']);
 
                        // ... and send it away!
-                       SEND_NEWSLETTER($email, $_POST['subject'], $msg, $_POST['mode']);
-               }
-
-               // Free memory
-               SQL_FREERESULT($result);
+                       sendNewsletter($content['email'], postRequestParameter('subject'), $message, postRequestParameter('mode'));
+               } // END - while
 
                // Output message
-               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NL_SEND_DONE);
-       }
-}
- else
-{
+               loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NL_SEND_DONE'));
+       } // END - if
+
+       // Free memory
+       SQL_FREERESULT($result);
+} else {
        // Copy data into constants for the template and load it
-       define('_DATESTAMP', MAKE_DATETIME(time(), "3"));
-       if (EXT_IS_ACTIVE("html_mail"))
-       {
+       $content['datestamp'] = generateDateTime(time(), 3);
+       if (isExtensionActive('html_mail')) {
                // Load template with HTML mode
-               LOAD_TEMPLATE("admin_newsletter");
-       }
-        else
-       {
+               loadTemplate('admin_newsletter', false, $content);
+       } else {
                // Load template with only text mode
-               LOAD_TEMPLATE("admin_newsletter_nohtml");
+               loadTemplate('admin_newsletter_nohtml', false, $content);
        }
 }
-CLOSE_TABLE();
-//
+
+// [EOF]
 ?>