Fix added for extension update with always active extensions, thanks to profi-concept
[mailer.git] / inc / pool-update.php
index 6f1fc8f9f90a89988d918316f2dd3c3d0c574254..baa7f89c3e94d8ea72878a35ed156caf51b35df7 100644 (file)
@@ -212,7 +212,9 @@ if (SQL_NUMROWS($result_main) > 0)
 
                                                // Get sender's data
                                                $result_sender = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
-                                                array(bigintval($DATA[1])), __FILE__, __LINE__);
+                                                       array(bigintval($DATA[1])), __FILE__, __LINE__);
+
+                                               // Is the sender found?
                                                if (SQL_NUMROWS($result_sender) == 1) {
                                                        // Load data and prepare mail
                                                        list($sname, $fname, $email) = SQL_FETCHROW($result_sender);
@@ -223,7 +225,7 @@ if (SQL_NUMROWS($result_main) > 0)
 
                                                        // Send it also waway
                                                        SEND_EMAIL($email, MEMBER_SUBJ_SEND_DONE, $msg);
-                                               }
+                                               } // END - if
 
                                                // Set status to SEND because we completely send it away
                                                $result_done = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='SEND', target_send='0', receivers='' WHERE id=%s LIMIT 1",
@@ -237,19 +239,17 @@ if (SQL_NUMROWS($result_main) > 0)
                                                $cnt2 += $cnt;
 
                                                // Update mediadata if version is 0.0.4 or higher
-                                               if (GET_EXT_VERSION("mediadata") >= "0.0.4")
-                                               {
+                                               if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
                                                        // Update entry (or add missing)
                                                        //* DEBUG: */ echo "*MEDIA/L:".__LINE__."*<br />";
                                                        MEDIA_UPDATE_ENTRY(array("total_orders", "normal_orders"), "add", 1);
-                                               }
+                                               } // END - if
 
                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$P."<br />";
                                                break;
                                        }
                                        // Do we have send maximum mails?
-                                        elseif (($cnt >= $_CONFIG['max_send']) || ($cnt2 >= $_CONFIG['max_send']))
-                                       {
+                                        elseif (($cnt >= $_CONFIG['max_send']) || ($cnt2 >= $_CONFIG['max_send'])) {
                                                // There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered)
                                                $ADD = "";
                                                if ($cnt <= $DATA[8]) $ADD = ", target_send=target_send-".$cnt;
@@ -259,29 +259,27 @@ if (SQL_NUMROWS($result_main) > 0)
                                                //* DEBUG: */ echo"*EXIT/L:".__LINE__."*<br />";
                                                break;
                                        }
-                               }
-                                else
-                               {
+                               } else {
                                        // User does not exists so we have add the sender's points back to sender's account
-                                       if (($RECEIVERS[0] == "0") || (empty($RECEIVERS[0])))
-                                       {
+                                       if (($RECEIVERS[0] == "0") || (empty($RECEIVERS[0]))) {
                                                // List was empty
                                                $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='SEND' WHERE id=%s LIMIT 1",
                                                 array(bigintval($DATA[0])), __FILE__, __LINE__);
-                                       }
-                                        else
-                                       {
-                                               if ($uid > 0)
-                                               {
+                                       } else {
+                                               // Is the userid set?
+                                               if ($uid > 0) {
                                                        // User does not exists, pay points back
                                                        $points = GET_PAY_POINTS($DATA[5]);
                                                        ADD_POINTS_REFSYSTEM($DATA[1], $points, false, "0", false, "direct");
 
                                                        // Add points together and remove user
                                                        $points_BACK[$DATA[1]] += $points;
-                                               }
+                                               } // END - if
+
+                                               // Count up
                                                $cnt_back[$DATA[1]]++;
                                        }
+
                                        // Remove entry from list
                                        unset($dummy[$key]);
 
@@ -292,7 +290,10 @@ if (SQL_NUMROWS($result_main) > 0)
                        }
                }
        }
+
+       // Do we have points to "pay back"?
        if ((sizeof($points_BACK) > 0) && (!empty($points_BACK[0]))) {
+               // Walk through all points
                foreach ($points_BACK as $uid => $PB) {
                        // Add points only when we have points left to add and a valid user ID
                        if (($PB > 0) && ($uid > 0)) {
@@ -305,6 +306,8 @@ if (SQL_NUMROWS($result_main) > 0)
                                $result = SQL_QUERY_ESC("SELECT email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
                                        array(bigintval($uid)), __FILE__, __LINE__);
                                $DATA[10] = $PB; $DATA[11] = $cnt_back[$uid];
+
+                               // User found?
                                if (SQL_NUMROWS($result) == 1) {
                                        list($email) = SQL_FETCHROW($result);
                                        SQL_FREERESULT($result);
@@ -321,9 +324,9 @@ if (SQL_NUMROWS($result_main) > 0)
                                        // Send mail out to admin
                                        SEND_ADMIN_NOTIFICATION(ADMIN_BACK_JACKPOT." (".$uid.")", "back-admin", $content, "admin");
                                }
-                       }
-               }
-       }
+                       } // END - if
+               } // END - foreach
+       } // END - if
 }
 
 // Free memory