]> git.mxchange.org Git - mailer.git/commitdiff
Now total received mails are reduced if no entry in user_stats_data is found
authorRoland Häder <roland@mxchange.org>
Sat, 21 Nov 2009 17:54:07 +0000 (17:54 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 21 Nov 2009 17:54:07 +0000 (17:54 +0000)
inc/mysql-manager.php
inc/pool/pool-bonus.php
inc/pool/pool-user.php

index 0e41c93d78987f21a3ee3f218903e500c4e88200..c9fad71c38bd45b68868552f4ecc139b956bb10c 100644 (file)
@@ -2083,16 +2083,29 @@ ORDER BY ur.refid ASC",
 // Recuce the amount of received emails for the receipients for given email
 function reduceRecipientReceivedMails ($column, $id, $count) {
        // Search for mail in database
-       $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s ORDER BY `userid` ASC LIMIT %s",
+       $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s ORDER BY `userid` ASC LIMIT %s",
                array($column, bigintval($id), $count), __FUNCTION__, __LINE__);
 
        // Are there entries?
        if (SQL_NUMROWS($result) > 0) {
                // Now load all userids for one big query!
-               // @TODO This can be somehow rewritten
                $userids = array();
-               while (list($userid) = SQL_FETCHROW($result)) {
-                       $userids[$userid] = $userid;
+               while ($data = SQL_FETCHARRAY($result)) {
+                       // By default we want to reduce and have no mails found
+                       $num = 0;
+
+                       // We must now look if he has already confirmed this mail, so might sound double, but it may resolve problems
+                       // @TODO Rewrite this to a filter
+                       if ((isset($data['stats_id'])) && ($data['stats_id'] > 0)) {
+                               // User email
+                               $num = countSumTotalData($data['userid'], 'user_stats_data', 'id', 'userid', true, sprintf(" AND `stats_type`='mailid' AND `stats_data`=%s", bigintval($data['stats_id'])));
+                       } elseif ((isset($data['bonus_id'])) && ($data['bonus_id'] > 0)) {
+                               // Bonus mail
+                               $num = countSumTotalData($data['userid'], 'user_stats_data', 'id', 'userid', true, sprintf(" AND `stats_type`='bonusid' AND `stats_data`=%s", bigintval($data['bonus_id'])));
+                       }
+
+                       // Reduce this users total received emails?
+                       if ($num === 0) $userids[$data['userid']] = $data['userid'];
                } // END - while
 
                // Now update all user accounts
index 9ab55f880677f46641c3ab3203bc04485fd18518..6baa5b7705d1b567bb09f23b13274ebc5eb00802 100644 (file)
@@ -125,7 +125,7 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) {
 
                                                if (getExtensionVersion('user') >= '0.1.4') {
                                                        // Update mails received for receiver
-                                                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET emails_received=emails_received+1 WHERE `userid`=%s LIMIT 1",
+                                                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`+1 WHERE `userid`=%s LIMIT 1",
                                                        array(bigintval($userid)), __FILE__, __LINE__);
                                                } // END - if
 
@@ -145,7 +145,7 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) {
                                $P = $GLOBALS['pool_cnt'];
                                if (!empty($cnt2) && empty($GLOBALS['pool_cnt'])) $P = $cnt2;
                                //* DEBUG: */ print("+MEDIA/L:".__LINE__.'/'.$P."+<br />");
-                               updateMediadataEntry(array("total_send", "bonus_send"), 'add', $P);
+                               updateMediadataEntry(array('total_send', 'bonus_send'), 'add', $P);
                        } // END - if
 
                        // Close sending system
@@ -160,7 +160,7 @@ if ($GLOBALS['pool_cnt'] < getConfig('max_send')) {
                                if (getExtensionVersion('mediadata') >= '0.0.4') {
                                        // Update entry (or add missing)
                                        //* DEBUG: */ print("*MEDIA/L:".__LINE__."*<br />");
-                                       updateMediadataEntry(array("total_orders", "bonus_orders"), 'add', 1);
+                                       updateMediadataEntry(array('total_orders', 'bonus_orders'), 'add', 1);
                                } // END - if
                        } elseif ($GLOBALS['pool_cnt'] >= getConfig('max_send')) {
                                // Update bonus pool
index 7848cdc0e606ef56d34b46f70088a3f0fa1ccdd2..ed548551f5be6c9cbfc0eab6643b7a3063bd308b 100644 (file)
@@ -153,7 +153,7 @@ if (SQL_NUMROWS($result_main) > 0) {
 
                                                                if (getExtensionVersion('user') >= '0.1.4') {
                                                                        // Update mails received for receiver
-                                                                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET emails_received=emails_received+1 WHERE `userid`=%s LIMIT 1",
+                                                                       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`+1 WHERE `userid`=%s LIMIT 1",
                                                                                array(bigintval($userid)), __FILE__, __LINE__);
                                                                } // END - if