]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-send_newsletter.php
More misc fixes and rewrites (sorry, lame description)
[mailer.git] / inc / modules / admin / what-send_newsletter.php
index 5f90fd230cdfa7c46155155c38d2ead26ef7bc69..cf3f96306623e929835a2c1d4507b65810decb8e 100644 (file)
  * -------------------------------------------------------------------- *
  * 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                           *
  * For more information visit: http://www.mxchange.org                  *
  ************************************************************************/
 
 // Some security stuff...
-if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
        require($INC);
 }
 
 // Add description as navigation point
-ADD_DESCR("admin", basename(__FILE__));
+ADD_DESCR('admin', __FILE__);
 
-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 (!EXT_IS_ACTIVE('html_mail', true) && (REQUEST_POST('mode') == 'html')) {
                                // Set mode to text mode
-                               $_POST['mode'] == "text";
-                       }
-                        elseif ($_POST['mode'] == "html")
-                       {
+                               REQUEST_POST('mode') == 'text';
+                       } elseif (REQUEST_POST('mode') == 'html') {
                                // Set HTML templates
-                               $template = "newsletter_html";
+                               $template = 'newsletter_html';
                        }
 
                        // Compile message
-                       $_POST['text'] = COMPILE_CODE($_POST['text']);
+                       REQUEST_SET_POST('text', COMPILE_CODE(REQUEST_POST('text')));
 
                        // Load template
-                       $msg = LOAD_EMAIL_TEMPLATE($template, $_POST['text'], $id);
+                       $message = LOAD_EMAIL_TEMPLATE($template, array('text' => REQUEST_POST('text')), $content['userid']);
 
                        // ... and send it away!
-                       SEND_NEWSLETTER($email, $_POST['subject'], $msg, $_POST['mode']);
+                       SEND_NEWSLETTER($content['email'], REQUEST_POST('subject'), $message, REQUEST_POST('mode'));
                }
 
                // Free memory
                SQL_FREERESULT($result);
 
                // Output message
-               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NL_SEND_DONE);
+               LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NL_SEND_DONE'));
        }
-}
- else
-{
+} else {
        // Copy data into constants for the template and load it
-       define('_DATESTAMP', MAKE_DATETIME(time(), "3"));
-       if (EXT_IS_ACTIVE("html_mail"))
-       {
+       // @TODO Rewrite this constant
+       define('_DATESTAMP', generateDateTime(time(), '3'));
+       if (EXT_IS_ACTIVE('html_mail')) {
                // Load template with HTML mode
-               LOAD_TEMPLATE("admin_newsletter");
-       }
-        else
-       {
+               LOAD_TEMPLATE('admin_newsletter');
+       } else {
                // Load template with only text mode
-               LOAD_TEMPLATE("admin_newsletter_nohtml");
+               LOAD_TEMPLATE('admin_newsletter_nohtml');
        }
 }