X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-send_newsletter.php;h=d94191ef980f3b2f5203fc2f8ba545f2173b0e31;hb=8ce32e702f3caa76b8d446902948e83e1e6854c8;hp=8f85d134b969370c01cc3657a70d0d026bdb4896;hpb=75ad748a68473ace540251427a74fb781b1145e9;p=mailer.git diff --git a/inc/modules/admin/what-send_newsletter.php b/inc/modules/admin/what-send_newsletter.php index 8f85d134b9..d94191ef98 100644 --- a/inc/modules/admin/what-send_newsletter.php +++ b/inc/modules/admin/what-send_newsletter.php @@ -1,7 +1,7 @@ 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_HASZERONUMS($result)) { // 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) && (postRequestElement('mail_mode') == 'html')) { // Set mode to text mode - $_POST['mode'] == "text"; - } - elseif ($_POST['mode'] == "html") - { + postRequestElement('mail_mode') == 'text'; + } elseif (postRequestElement('mail_mode') == 'html') { // Set HTML templates - $template = "newsletter_html"; + $template = 'newsletter_html'; } // Compile message - $_POST['text'] = stripslashes(COMPILE_CODE($_POST['text'])); + setPostRequestElement('text', preCompileCode(postRequestElement('text'))); // Load template - $msg = LOAD_EMAIL_TEMPLATE($template, $_POST['text'], $id); + $message = loadEmailTemplate($template, array('text' => postRequestElement('text')), $content['userid']); // ... and send it away! - SEND_NEWSLETTER($email, $_POST['subject'], $msg, $_POST['mode']); - } - - // Free memory - SQL_FREERESULT($result); + sendNewsletter($content['email'], postRequestElement('subject'), $message, postRequestElement('mail_mode')); + } // END - while // Output message - LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NL_SEND_DONE); - } -} - else -{ + displayMessage('{--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); + + // Extension html_mail installed? + 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] ?>