Even more rewrites/fixes from EL branch (please report any broken part after you...
[mailer.git] / inc / pool / pool-user.php
index 7848cdc0e606ef56d34b46f70088a3f0fa1ccdd2..b29d3fb625568476092b8d12ddcc7f1706726cb9 100644 (file)
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -76,7 +77,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                // Entry updated?
                if (SQL_AFFECTEDROWS() == 1) {
                        // "Explode" all receivers into an array
-                       if (ereg(';', $DATA['receivers'])) {
+                       if (isInString(';', $DATA['receivers'])) {
                                // There's more than one receiver in the list...
                                $receiverS = explode(';', $DATA['receivers']);
                        } elseif (!empty($DATA['receivers'])) {
@@ -100,7 +101,7 @@ if (SQL_NUMROWS($result_main) > 0) {
 
                                        // If there's no stats entry add it!
                                        //* DEBUG: */ outputHtml("!L:".__LINE__.'/'.SQL_NUMROWS($result_stats)."!<br />");
-                                       if (SQL_NUMROWS($result_stats) == '0') {
+                                       if (SQL_NUMROWS($result_stats) == 0) {
                                                // No entry was found, so we add him!
                                                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats` (`pool_id` , `userid`, `cat_id`, `payment_id`, `subject`, `url` , `max_rec` , `timestamp_ordered`, `timestamp_sstart`) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s' , UNIX_TIMESTAMP())",
                                                        array(bigintval($DATA['id']), bigintval($DATA['sender']), bigintval($DATA['cat_id']), bigintval($DATA['payment_id']), $DATA['subject'], $DATA['url'], $DATA['target_send'], bigintval($DATA['timestamp'])), __FILE__, __LINE__);
@@ -151,14 +152,14 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET emails_sent=emails_sent+1 WHERE `userid`=%s LIMIT 1",
                                                                        array(bigintval($DATA['sender'])), __FILE__, __LINE__);
 
-                                                               if (getExtensionVersion('user') >= '0.1.4') {
+                                                               if (isExtensionInstalledAndNewer('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
 
                                                                // Update mediadata if version is 0.0.4 or higher
-                                                               if (getExtensionVersion('mediadata') >= '0.0.4') {
+                                                               if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) {
                                                                        // Update entry (or add missing)
                                                                        //* DEBUG: */ outputHtml("*MEDIA/L:".__LINE__."*<br />");
                                                                        updateMediadataEntry(array('total_send', 'normal_send'), 'add', 1);
@@ -213,7 +214,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                $cnt2 += $GLOBALS['pool_cnt'];
 
                                                // Update mediadata if version is 0.0.4 or higher
-                                               if (getExtensionVersion('mediadata') >= '0.0.4') {
+                                               if (isExtensionInstalledAndNewer('mediadata', '0.0.4')) {
                                                        // Update entry (or add missing)
                                                        //* DEBUG: */ outputHtml("*MEDIA/L:".__LINE__."*<br />");
                                                        updateMediadataEntry(array('total_orders', 'normal_orders'), 'add', 1);
@@ -227,8 +228,11 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                // There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered)
                                                $add = '';
                                                if ($GLOBALS['pool_cnt'] <= $DATA['target_send']) $add = ", target_send=target_send-".$GLOBALS['pool_cnt'];
-                                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='NEW', receivers='%s'".$add." WHERE `id`=%s LIMIT 1",
-                                                       array(implode(';', $dummy), bigintval($DATA['id'])), __FILE__, __LINE__);
+                                               SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='NEW', receivers='%s'" . $add . " WHERE `id`=%s LIMIT 1",
+                                                       array(
+                                                               implode(';', $dummy),
+                                                               bigintval($DATA['id'])
+                                                       ), __FILE__, __LINE__);
 
                                                //* DEBUG: */ outputHtml("*EXIT/L:".__LINE__."*<br />");
                                                break;