]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Fix for deleting email
[mailer.git] / inc / mysql-manager.php
index 46154a41084d7508073acf6f18619de9225ccf75..5cc8edd6468507a077f110c208739ebcda4b5226 100644 (file)
@@ -270,6 +270,7 @@ function ADD_DESCR($ACC_LVL, $file, $return = false, $output = true)
                        if (($type == "what") || (($type == "action") && (!isset($_GET['what'])) && ($GLOBALS['what'] != "welcome"))) {
                                //* DEBUG: */ echo __LINE__."+".$type."+<br />\n";
                                $OUT .= "</DIV><br />\n";
+                               $DEPTH="0";
                        }
                }
        }
@@ -1035,21 +1036,17 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
        global $DEPTH, $_CONFIG, $DATA, $link;
 
        // When $uid = 0 add points to jackpot
-       if ($uid == "0")
-       {
+       if ($uid == "0") {
                // Add points to jackpot
                ADD_JACKPOT($points);
                return;
        }
 
        // Count up referral depth
-       if (empty($DEPTH))
-       {
+       if (empty($DEPTH)) {
                // Initialialize referral system
                $DEPTH = "0";
-       }
-        else
-       {
+       } else {
                // Increase referral level
                $DEPTH++;
        }
@@ -1059,49 +1056,57 @@ function ADD_POINTS_REFSYSTEM($uid, $points, $send_notify=false, $rid="0", $lock
 
        $result_user = SQL_QUERY_ESC("SELECT refid, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d AND status='CONFIRMED' LIMIT 1",
         array(bigintval($uid)), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result_user) == 1)
-       {
+       //* DEBUG */ echo "+".SQL_NUMROWS($result_user).":".$points."+<br />\n";
+       if (SQL_NUMROWS($result_user) == 1) {
                // This is the user and his ref
                list ($ref, $email) = SQL_FETCHROW($result_user);
                SQL_FREERESULT($result_user);
+
                $result = SQL_QUERY_ESC("SELECT percents FROM "._MYSQL_PREFIX."_refdepths WHERE level='%s' LIMIT 1",
                 array(bigintval($DEPTH)), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 1)
-               {
+               //* DEBUG */ echo "DEPTH:".$DEPTH."<br />\n";
+               if (SQL_NUMROWS($result) == 1) {
                        list($per) = SQL_FETCHROW($result);
                        SQL_FREERESULT($result);
                        $P = $points * $per / 100;
+                       //* DEBUG */ echo "ADD:".$P."<br />\n";
 
                        // Update points...
                        $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points SET %s=%s+%s WHERE userid=%d AND ref_depth=%d LIMIT 1",
                         array($data, $data, $P, bigintval($uid), bigintval($DEPTH)), __FILE__, __LINE__);
-                       if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 0)
-                       {
+                       if (SQL_AFFECTEDROWS($link, __FILE__, __LINE__) == 0) {
                                // First ref in this level! :-)
                                $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_user_points (userid, ref_depth, %s) VALUES (%d, %d, %s)",
                                 array($data, bigintval($uid), bigintval($DEPTH), $P), __FILE__, __LINE__);
                        }
 
                        // Update mediadata as well
-                       if (GET_EXT_VERSION("mediadata") >= "0.0.4")
-                       {
+                       if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
                                // Update database
                                MEDIA_UPDATE_ENTRY(array("total_points"), "add", $P);
                        }
 
                        // Points updated, maybe I shall send him an email?
-                       if (($send_notify) && ($ref > 0) && (!$locked))
-                       {
+                       if (($send_notify) && ($ref > 0) && (!$locked)) {
                                //              0                1      2              3
                                $DATA = array($per, bigintval($DEPTH), $P, bigintval($ref));
                                $msg = LOAD_EMAIL_TEMPLATE("confirm-referral", "", bigintval($uid));
 
                                SEND_EMAIL($email, THANX_REFERRAL_ONE, $msg);
+                       } elseif (($send_notify) && ($ref == 0) && (!$locked) && ($add_mode == "direct") && (!defined('__POINTS_VALUE'))) {
+                               // Direct payment shall be notified about
+                               define('__POINTS_VALUE', $P);
+
+                               // Load message
+                               $msg = LOAD_EMAIL_TEMPLATE("add-points", REASON_DIRECT_PAYMENT, $uid);
+
+                               // And sent it away
+                               SEND_EMAIL($email, SUBJECT_DIRECT_PAYMENT, $msg);
+                               LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_POINTS_ADDED);
                        }
 
                        // Maybe there's another ref?
-                       if (($ref > 0) && ($points > 0) && ($ref != $uid) && ($add_mode == "ref"))
-                       {
+                       if (($ref > 0) && ($points > 0) && ($ref != $uid) && ($add_mode == "ref")) {
                                // Then let's credit him here...
                                ADD_POINTS_REFSYSTEM($ref, $points, $send_notify, $ref, $locked);
                        }