X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-del_email.php;h=aca046e8e81999a250ce9e75d875b274c6080d52;hp=bcc1fcc5d2607d21e02db72233b71d60ee9fd25c;hb=3f51c40f4fede87228216f9285b745a339e3891d;hpb=ffc9f83d2e03081fbf9e6106cc845d2326920d35
diff --git a/inc/modules/admin/what-del_email.php b/inc/modules/admin/what-del_email.php
index bcc1fcc5d2..aca046e8e8 100644
--- a/inc/modules/admin/what-del_email.php
+++ b/inc/modules/admin/what-del_email.php
@@ -36,17 +36,20 @@
// Some security stuff...
if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+ $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 (!empty($_GET['mid'])) {
+// Init counter for deleted mails
+$cnt = 0;
+
+if (REQUEST_ISSET_GET('mid')) {
// Load email data
- $result = SQL_QUERY_ESC("SELECT id, sender, subject, url, timestamp, payment_id FROM "._MYSQL_PREFIX."_pool WHERE id=%s LIMIT 1",
- array(bigintval($_GET['mid'])), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id`, `sender`, `subject`, `url`, `timestamp`, `payment_id` FROM `{!_MYSQL_PREFIX!}_pool` WHERE `id`=%s LIMIT 1",
+ array(bigintval(REQUEST_GET('mid'))), __FILE__, __LINE__);
// Delete mail only once
if (SQL_NUMROWS($result) == 1) {
@@ -55,14 +58,14 @@ if (!empty($_GET['mid'])) {
SQL_FREERESULT($result);
// Get points we shall pay back per mail
- $price = GET_PAY_POINTS($payId, "price");
+ $price = getPaymentPoints($payId, 'price');
// Prepare data for the template
define('__ID' , $id);
- define('__SENDER' , ADMIN_USER_PROFILE_LINK($sender));
+ define('__SENDER' , generateUserProfileLink($sender));
define('__SUBJECT', $subject);
define('__URL' , DEREFERER($url));
- define('__ORDERED', MAKE_DATETIME($timestamp, "0"));
+ define('__ORDERED', generateDateTime($timestamp, '0'));
// Load template
LOAD_TEMPLATE("admin_del_email_normal");
@@ -72,93 +75,143 @@ if (!empty($_GET['mid'])) {
// 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);
-
- // Delete mail from queue
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE id=%s LIMIT 1",
- array(bigintval($_GET['mid'])), __FILE__, __LINE__);
+ sendEmail($sender, getMessage('MEMBER_ORDER_DELETED'), $msg_user);
// Fetch right stats_id from pool
- $result = 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__);
- if (SQL_NUMROWS($result) == 1) {
+ $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(REQUEST_GET('mid'))), __FILE__, __LINE__);
+ if (SQL_NUMROWS($result_pool) == 1) {
// Fetch stats id
- list($stats_id) = SQL_FETCHROW($result);
-
- // Free the result
- SQL_FREERESULT($result);
+ list($stats_id) = SQL_FETCHROW($result_pool);
// Get all user links
- $result = SQL_QUERY_ESC("SELECT COUNT(id) AS 'cnt' FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s",
- array(bigintval($stats_id)), __FILE__, __LINE__);
+ $links = GET_TOTAL_DATA($stats_id, 'user_links', 'userid', 'stats_id', true);
- // Get unconfirmed links for calculation of total points
- list($links) = SQL_FETCHROW($result);
-
- // Free result
- SQL_FREERESULT($result);
+ // Reset sent mails for recipient(s)
+ reduceRecipientReceivedMails('stats_id', REQUEST_GET('mid'), $links);
// Calc total points and pay them back
$totalPoints = $links * $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 (getConfig('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") {
+ if (getConfig('repay_deleted_mails') == 'JACKPOT') {
// Set jackpot
$sender = 0;
- }
+ } // END - if
// Pay back points
//* DEBUG: */ echo "PAYBACK:".$sender."
\n";
- ADD_POINTS_REFSYSTEM($sender, $totalPoints, true, "0", false,"direct");
+ ADD_POINTS_REFSYSTEM('mail_deleted', $sender, $totalPoints, true, '0', false,'direct');
// Output message
- if ($_CONFIG['repay_deleted_mails'] == 'REPAY') {
+ if (getConfig('repay_deleted_mails') == 'REPAY') {
// Repayed
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_POINTS_REPAYED,
- number_format($totalPoints, 0, ",", ".")
+ LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_POINTS_REPAYED'),
+ translateComma($totalPoints)
));
} else {
// To jackpot
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_POINTS_TO_JACKPOT,
- number_format($totalPoints, 0, ",", ".")
+ LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_POINTS_TO_JACKPOT'),
+ translateComma($totalPoints)
));
}
} else {
// No points repayed!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NO_POINTS_REPAYED);
+ LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_POINTS_REPAYED'));
}
} else {
// Points shredded!
- LOAD_TEMPLATE("admin_settings_saved", false, sprintf(ADMIN_POINTS_SHREDDED, $totalPoints));
+ LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_POINTS_SHREDDED'), $totalPoints));
}
// Remove links from DB
- $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s",
- array(bigintval($stats_id)), __FILE__, __LINE__);
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE stats_id=%s",
+ array(bigintval($stats_id)), __FILE__, __LINE__);
+ $cnt += SQL_AFFECTEDROWS();
+
+ // Load template for link
+ LOAD_TEMPLATE('admin_settings_saved', false, "".ADMIN_REMOVE_STATS_ENTRY."");
+ } // END - if
+
+ // Free the result
+ SQL_FREERESULT($result_pool);
- // Output link for manually removing stats entry
- LOAD_TEMPLATE("admin_settings_saved", false, "".ADMIN_REMOVE_STATS_ENTRY."");
- }
+ // Delete mail from queue
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_pool` WHERE `id`=%s LIMIT 1",
+ array(bigintval(REQUEST_GET('mid'))), __FILE__, __LINE__);
+ $cnt += SQL_AFFECTEDROWS();
+
+ // Output link for manually removing stats entry
+ OUTPUT_HTML(sprintf(ADMIN_DELETED_MAILS_COUNT, $cnt));
} else {
// Mail already deleted!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NORMAL_MAIL_ALREADY_DELETED);
+ LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NORMAL_MAIL_ALREADY_DELETED'));
}
-} elseif (!empty($_GET['pid'])) {
+} elseif (REQUEST_ISSET_GET('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__);
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_USER_STATS_REMOVED);
-} elseif ((!empty($_GET['bid'])) && (EXT_IS_ACTIVE("bonus"))) {
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_stats` WHERE `pool_id`=%s LIMIT 1",
+ array(bigintval(REQUEST_GET('pid'))), __FILE__, __LINE__);
+
+ // Output message
+ LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_USER_STATS_REMOVED'));
+} elseif ((REQUEST_ISSET_GET('bid')) && (EXT_IS_ACTIVE('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(REQUEST_GET('bid'))), __FILE__, __LINE__);
+
+ // Delete mail only once
+ if (SQL_NUMROWS($result) == 1) {
+ // Load data
+ list($id, $subject, $url, $timestamp, $sent) = SQL_FETCHROW($result);
+
+ // Reset sent mails for recipient(s)
+ reduceRecipientReceivedMails('bonus_id', REQUEST_GET('bid'), $sent);
+
+ // Init counter for deleted mails
+ $cnt = 0;
+
+ // Delete bonus mail entirely from database
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `id`=%s LIMIT 1",
+ array(bigintval(REQUEST_GET('bid'))), __FILE__, __LINE__);
+ $cnt += SQL_AFFECTEDROWS();
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `bonus_id`=%s",
+ array(bigintval(REQUEST_GET('bid'))), __FILE__, __LINE__);
+ $cnt += SQL_AFFECTEDROWS();
+
+ // Prepare data for the template
+ define('__ID' , $id);
+ define('__SUBJECT', $subject);
+ define('__URL' , DEREFERER($url));
+ define('__ORDERED', generateDateTime($timestamp, '0'));
+ define('__CNT' , $cnt);
+
+ // Load template
+ LOAD_TEMPLATE('admin_del_email_bonus');
+ } else {
+ // Mail already deleted!
+ LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_BONUS_MAIL_ALREADY_DELETED'));
+ }
+
+ // Free result
+ SQL_FREERESULT($result);
+} elseif ((REQUEST_ISSET_GET('nid')) && (GET_EXT_VERSION('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['bid'])), __FILE__, __LINE__);
+ $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `id`=%s",
+ array(bigintval(REQUEST_GET('nid'))), __FILE__, __LINE__);
// Delete mail only once
if (SQL_NUMROWS($result) == 1) {
@@ -166,27 +219,33 @@ WHERE s.pool_id=%s LIMIT 1",
list ($id, $subject, $url, $timestamp) = SQL_FETCHROW($result);
SQL_FREERESULT($result);
+ // Init counter for deleted mails
+ $cnt = 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['bid'])), __FILE__, __LINE__);
- $result = 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(REQUEST_GET('nid'))), __FILE__, __LINE__);
+ $cnt += SQL_AFFECTEDROWS();
+ SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{!_MYSQL_PREFIX!}_user_links` WHERE `bonus_id`=%s",
+ array(bigintval(REQUEST_GET('nid'))), __FILE__, __LINE__);
+ $cnt += SQL_AFFECTEDROWS();
// Prepare data for the template
define('__ID' , $id);
define('__SUBJECT', $subject);
define('__URL' , DEREFERER($url));
- define('__ORDERED', MAKE_DATETIME($timestamp, "0"));
+ define('__ORDERED', generateDateTime($timestamp, '0'));
+ define('__CNT' , $cnt);
// Load template
- LOAD_TEMPLATE("admin_del_email_bonus");
+ LOAD_TEMPLATE('admin_del_email_notify');
} else {
// Mail already deleted!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_MAIL_ALREADY_DELETED);
+ LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NOTIFY_MAIL_ALREADY_DELETED'));
}
} else {
// No mail orders fond
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_WRONG_CALL);
+ LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_WRONG_CALL'));
}
//