X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-del_email.php;h=a6d57eddf3f7012fd7d9e45ebb197936f534ca54;hb=c28537699175c4cb71a92e720541e9ce1381c8a3;hp=13d4b6ef0f947647e3ff6b843e92feb8ee3f9366;hpb=291f6916fd3c7caca2800c47ecc776e2b961cd96;p=mailer.git
diff --git a/inc/modules/admin/what-del_email.php b/inc/modules/admin/what-del_email.php
index 13d4b6ef0f..a6d57eddf3 100644
--- a/inc/modules/admin/what-del_email.php
+++ b/inc/modules/admin/what-del_email.php
@@ -1,21 +1,22 @@
$url, 'subject' => $subject);
+ loadTemplate('admin_delete_email_normal', false, $content);
// Load email template and send the email away
- $msg_user = LOAD_EMAIL_TEMPLATE("order-deleted", array(), $sender);
- SEND_EMAIL($sender, MEMBER_ORDER_DELETED, $msg_user);
+ $message_user = loadEmailTemplate('order-deleted', $content, $content['sender']);
+ sendEmail($content['sender'], '{--MEMBER_ORDER_DELETED--}', $message_user);
// Fetch right stats_id from pool
- $result_pool = SQL_QUERY_ESC("SELECT s.id FROM "._MYSQL_PREFIX."_user_stats AS s
-LEFT JOIN "._MYSQL_PREFIX."_pool AS p
-ON s.pool_id=p.id
-WHERE s.pool_id=%s LIMIT 1",
- array(bigintval($_GET['mid'])), __FILE__, __LINE__);
+ $result_pool = SQL_QUERY_ESC("SELECT
+ s.id
+FROM
+ `{?_MYSQL_PREFIX?}_user_stats` AS s
+LEFT JOIN
+ `{?_MYSQL_PREFIX?}_pool` AS p
+ON
+ s.pool_id=p.id
+WHERE
+ s.`pool_id`=%s
+LIMIT 1",
+ array(bigintval(getRequestParameter('mid'))), __FILE__, __LINE__);
if (SQL_NUMROWS($result_pool) == 1) {
// Fetch stats id
list($stats_id) = SQL_FETCHROW($result_pool);
// Get all user links
- $links = GET_TOTAL_DATA($stats_id, "user_links", "userid", "stats_id", true);
+ $links = countSumTotalData($stats_id, 'user_links', 'userid', 'stats_id', true);
// Reset sent mails for recipient(s)
- REDUCT_RECIPIENT_RECEIVED_MAILS("stats_id", $_GET['mid'], $links);
+ reduceRecipientReceivedMails('stats_id', getRequestParameter('mid'), $links);
// Calc total points and pay them back
- $totalPoints = $links * $price;
+ $totalPoints = $links * $content['price'];
// Shall we pay the points back to the user?
- if ($_CONFIG['repay_deleted_mails'] != 'SHRED') {
- //* DEBUG: */ echo $stats_id.":".$totalPoints."/".$links."/".$price."
\n";
- if ($totalPoints > 0) {
- // Shall we payback to user or jackpot?
- if ($_CONFIG['repay_deleted_mails'] == "JACKPOT") {
- // Set jackpot
- $sender = 0;
- } // END - if
-
- // Pay back points
- //* DEBUG: */ echo "PAYBACK:".$sender."
\n";
- ADD_POINTS_REFSYSTEM("mail_deleted", $sender, $totalPoints, true, "0", false,"direct");
-
- // Output message
- if ($_CONFIG['repay_deleted_mails'] == 'REPAY') {
- // Repayed
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_POINTS_REPAYED,
- TRANSLATE_COMMA($totalPoints)
- ));
- } else {
- // To jackpot
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_POINTS_TO_JACKPOT,
- TRANSLATE_COMMA($totalPoints)
- ));
- }
+ if ($totalPoints == 0) {
+ // No points repayed!
+ displayMessage('{--ADMIN_NO_POINTS_REPAYED--}');
+ } elseif (getConfig('repay_deleted_mails') != 'SHRED') {
+ //* DEBUG: */ debugOutput($stats_id . ':' . $totalPoints . '/' . $links . '/' . $content['price']);
+ // Shall we payback to user or jackpot?
+ if (getConfig('repay_deleted_mails') == 'JACKPOT') {
+ // Set jackpot
+ $content['sender'] = '0';
+ } // END - if
+
+ // Pay back points
+ //* DEBUG: */ debugOutput('PAYBACK:'.$content['sender']);
+ addPointsDirectly('mail_deleted', $content['sender'], $totalPoints);
+
+ // Output message
+ if (getConfig('repay_deleted_mails') == 'REPAY') {
+ // Repayed
+ displayMessage(getMaskedMessage('ADMIN_POINTS_REPAYED',
+ '{%pipe,translateComma=' . $totalPoints . '%}'
+ ));
} else {
- // No points repayed!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NO_POINTS_REPAYED);
+ // To jackpot
+ displayMessage(getMaskedMessage('ADMIN_POINTS_TO_JACKPOT',
+ '{%pipe,translateComma=' . $totalPoints . '%}'
+ ));
}
} else {
// Points shredded!
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_POINTS_SHREDDED, $totalPoints));
+ displayMessage(getMaskedMessage('ADMIN_POINTS_SHREDDED', '{%pipe,translateComma=' . $totalPoints . '%}'));
}
- // Delete mail from queue
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE id=%s LIMIT 1",
- array(bigintval($_GET['mid'])), __FILE__, __LINE__);
-
// Remove links from DB
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s",
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `stats_id`=%s",
array(bigintval($stats_id)), __FILE__, __LINE__);
+ $count += SQL_AFFECTEDROWS();
- // Output link for manually removing stats entry
- LOAD_TEMPLATE("admin_settings_saved", false, "".ADMIN_REMOVE_STATS_ENTRY."");
+ // Load template for link
+ displayMessage('{--ADMIN_REMOVE_STATS_ENTRY--}');
} // END - if
// Free the result
SQL_FREERESULT($result_pool);
+
+ // Delete mail from queue
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
+ array(bigintval(getRequestParameter('mid'))), __FILE__, __LINE__);
+ $count += SQL_AFFECTEDROWS();
+
+ // Output link for manually removing stats entry
+ outputHtml(getMaskedMessage('ADMIN_DELETED_MAILS_COUNT', $count));
} else {
// Mail already deleted!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NORMAL_MAIL_ALREADY_DELETED);
+ displayMessage('{--ADMIN_NORMAL_MAIL_ALREADY_DELETED--}');
}
-} elseif (!empty($_GET['pid'])) {
+
+ // Free result
+ SQL_FREERESULT($result);
+} elseif (isGetRequestParameterSet('pid')) {
// Remove stats entries
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_stats WHERE pool_id=%s LIMIT 1",
- array(bigintval($_GET['pid'])), __FILE__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
+ array(bigintval(getRequestParameter('pid'))), __FILE__, __LINE__);
// Output message
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_USER_STATS_REMOVED);
-} elseif ((!empty($_GET['bid'])) && (EXT_IS_ACTIVE("bonus"))) {
+ displayMessage('{--ADMIN_USER_STATS_REMOVED--}');
+} elseif ((isGetRequestParameterSet('bid')) && (isExtensionActive('bonus'))) {
// Load data from bonus mail
- $result = SQL_QUERY_ESC("SELECT id, subject, url, timestamp, mails_sent FROM "._MYSQL_PREFIX."_bonus WHERE id=%s",
- array(bigintval($_GET['bid'])), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp`, `mails_sent` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ array(bigintval(getRequestParameter('bid'))), __FILE__, __LINE__);
// Delete mail only once
if (SQL_NUMROWS($result) == 1) {
// Load data
- list ($id, $subject, $url, $timestamp, $sent) = SQL_FETCHROW($result);
+ $content = SQL_FETCHARRAY($result);
// Reset sent mails for recipient(s)
- REDUCT_RECIPIENT_RECEIVED_MAILS ("bonus_id", $_GET['bid'], $sent);
+ reduceRecipientReceivedMails('bonus_id', getRequestParameter('bid'), $content['mails_sent']);
+
+ // Init counter for deleted mails
+ $count = '0';
// Delete bonus mail entirely from database
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus WHERE id=%s LIMIT 1",
- array(bigintval($_GET['bid'])), __FILE__, __LINE__);
- SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s",
- array(bigintval($_GET['bid'])), __FILE__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ array(bigintval(getRequestParameter('bid'))), __FILE__, __LINE__);
+ $count += SQL_AFFECTEDROWS();
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
+ array(bigintval(getRequestParameter('bid'))), __FILE__, __LINE__);
+ $count += SQL_AFFECTEDROWS();
// Prepare data for the template
- define('__ID' , $id);
- define('__SUBJECT', $subject);
- define('__URL' , DEREFERER($url));
- define('__ORDERED', MAKE_DATETIME($timestamp, "0"));
+ $content['timestamp'] = generateDateTime($content['timestamp'], 0);
+ $content['cnt'] = $count;
// Load template
- LOAD_TEMPLATE("admin_del_email_bonus");
+ loadTemplate('admin_delete_email_bonus', false, $content);
} else {
// Mail already deleted!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_MAIL_ALREADY_DELETED);
+ displayMessage('{--ADMIN_BONUS_MAIL_ALREADY_DELETED--}');
}
// Free result
SQL_FREERESULT($result);
-} elseif ((!empty($_GET['nid'])) && (GET_EXT_VERSION("bonus") >= "0.8.7")) {
+} elseif ((isGetRequestParameterSet('nid')) && (isExtensionInstalledAndNewer('bonus', '0.8.7'))) {
// Load data from bonus mail
- $result = SQL_QUERY_ESC("SELECT id, subject, url, timestamp FROM "._MYSQL_PREFIX."_bonus WHERE id=%s",
- array(bigintval($_GET['nid'])), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ array(bigintval(getRequestParameter('nid'))), __FILE__, __LINE__);
// Delete mail only once
if (SQL_NUMROWS($result) == 1) {
// Load data
- list ($id, $subject, $url, $timestamp) = SQL_FETCHROW($result);
- SQL_FREERESULT($result);
+ $content = SQL_FETCHARRAY($result);
+
+ // Init counter for deleted mails
+ $count = '0';
// Delete bonus mail entirely from database
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus WHERE id=%s LIMIT 1",
- array(bigintval($_GET['nid'])), __FILE__, __LINE__);
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s",
- array(bigintval($_GET['nid'])), __FILE__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
+ array(bigintval(getRequestParameter('nid'))), __FILE__, __LINE__);
+ $count += SQL_AFFECTEDROWS();
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `bonus_id`=%s",
+ array(bigintval(getRequestParameter('nid'))), __FILE__, __LINE__);
+ $count += SQL_AFFECTEDROWS();
// Prepare data for the template
- define('__ID' , $id);
- define('__SUBJECT', $subject);
- define('__URL' , DEREFERER($url));
- define('__ORDERED', MAKE_DATETIME($timestamp, "0"));
+ $content['timestamp'] = generateDateTime($content['timestamp'], 0);
+ $content['cnt'] = $count;
// Load template
- LOAD_TEMPLATE("admin_del_email_notify");
+ loadTemplate('admin_delete_email_notify', false, $content);
} else {
// Mail already deleted!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NOTIFY_MAIL_ALREADY_DELETED);
+ displayMessage('{--ADMIN_NOTIFY_MAIL_ALREADY_DELETED--}');
}
+
+ // Free result
+ SQL_FREERESULT($result);
} else {
// No mail orders fond
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_WRONG_CALL);
+ displayMessage('{--ADMIN_WRONG_CALL--}');
}
-//
+// [EOF]
?>