]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/refback_functions.php
Better here
[mailer.git] / inc / libs / refback_functions.php
index 5938bd79bf606dc7c665036ac70e95576c11ccb8..300ee3aacdfc7eb13745a1d3165566d6816e0a09 100644 (file)
@@ -17,7 +17,7 @@
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -50,14 +50,14 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) {
        $return = $ref_points;
 
        // Get all ref levels
-       $result_refs = SQL_QUERY('SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level` > 0 ORDER BY `level` ASC',
+       $result_refs = SQL_QUERY('SELECT `level`,`percents` FROM `{?_MYSQL_PREFIX?}_refdepths` WHERE `level` > 0 ORDER BY `level` ASC',
                __FUNCTION__, __LINE__);
 
        // "Walk" through all level
        while ($content = SQL_FETCHARRAY($result_refs)) {
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'level=' . $content['level'] . ',percents=' . $content['percents'] . ' - LOOP START!');
                // Reset ref depths
-               initReferalSystem();
+               initReferralSystem();
 
                // Init array
                $refids = getArrayFromRefbackLevel($userid, $content['level']);
@@ -70,9 +70,9 @@ function addRefbackPoints ($userid, $ref, $points, $ref_points) {
                         * call. If you do so, you will check the wrong direction, $userid
                         * is always bigger than $refid.
                         */
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . makeNullToZero($refid) . ' - CALLING getRefbackPercents()');
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . convertNullToZero($refid) . ' - CALLING getRefbackPercents()');
                        $content['refback_percents'] = getRefbackPercents($refid, $userid);
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . makeNullToZero($refid) . ',refback_percents=' . $content['refback_percents']);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . convertNullToZero($refid) . ',refback_percents=' . $content['refback_percents']);
 
                        // Some percents given?
                        if ($content['refback_percents'] > 0) {
@@ -98,12 +98,12 @@ LIMIT 1',
                                // Something must have been updated
                                if (SQL_HASZEROAFFECTED()) {
                                        // Please report this bug
-                                       debug_report_bug(__FUNCTION__, __LINE__, 'Nothing has been updated in user_refs,userid=' . $userid . ',refid=' . makeNullToZero($refid) . ',refbackPoints=' . $refbackPoints);
+                                       debug_report_bug(__FUNCTION__, __LINE__, 'Nothing has been updated in user_refs,userid=' . $userid . ',refid=' . convertNullToZero($refid) . ',refbackPoints=' . $refbackPoints);
                                } // END - if
 
                                // Add points again, but only directly
-                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refbackPoints=' . $refbackPoints . ',userid=' . $userid . ',ref=' . $ref . ',refid=' . makeNullToZero($refid) . ' - REFBACK-UPDATE! (' . SQL_AFFECTEDROWS() . ')');
-                               addPointsThroughReferalSystem(sprintf("refback:%s", $refid), $userid, $refbackPoints);
+                               //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refbackPoints=' . $refbackPoints . ',userid=' . $userid . ',ref=' . $ref . ',refid=' . convertNullToZero($refid) . ' - REFBACK-UPDATE! (' . SQL_AFFECTEDROWS() . ')');
+                               addPointsThroughReferralSystem(sprintf("refback:%s", $refid), $userid, $refbackPoints);
 
                                // Reduce points if refid is found
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ',ref=' . $ref . ' - REDUCING?');
@@ -131,14 +131,14 @@ LIMIT 1',
  * "Getter" for refback percents
  *
  * @param      $userid         "Current" user's userid
- * @param      $refid          $userid has this userid as referal
+ * @param      $refid          $userid has this userid as referral
  * @return     $percents       Refback percents $userid has given to $refid
  */
 function getRefbackPercents ($userid, $refid) {
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',refid=' . $refid . ' - ENTERED!');
        if ((!isValidUserId($userid)) || (!isValidUserId($refid))) {
                // userid and/or refid is invalid
-               debug_report_bug(__FUNCTION__, __LINE__, 'userid=' . makeNullToZero($userid) . ', refid=' . makeNullToZero($refid) . ' - Both must be > 0');
+               debug_report_bug(__FUNCTION__, __LINE__, 'userid=' . convertNullToZero($userid) . ', refid=' . convertNullToZero($refid) . ' - Both must be > 0');
        } elseif ($userid == $refid) {
                // Skip identical ids
                return 0;
@@ -174,7 +174,7 @@ function getRefbackPercents ($userid, $refid) {
 
 // "Getter" for userid array which will return only one entry
 function getArrayFromRefbackLevel ($refid, $level) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . makeNullToZero($refid) . ',level=' . $level . ' - ENTERED!');
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . convertNullToZero($refid) . ',level=' . $level . ' - ENTERED!');
        // Init userids
        $userIds = array();
 
@@ -195,7 +195,7 @@ ORDER BY
        if (!SQL_HASZERONUMS($result)) {
                // Add all
                while ($content = SQL_FETCHARRAY($result)) {
-                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . makeNullToZero($refid) . ',level=' . $level . ',userid=' . $content['userid']);
+                       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . convertNullToZero($refid) . ',level=' . $level . ',userid=' . $content['userid']);
                        $userIds[] = $content['userid'];
                } // END - while
        } // END - if
@@ -204,7 +204,7 @@ ORDER BY
        SQL_FREERESULT($result);
 
        // Return array
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . makeNullToZero($refid) . ',userIds()=' . count($userIds) . ' - EXIT!');
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'refid=' . convertNullToZero($refid) . ',userIds()=' . count($userIds) . ' - EXIT!');
        return $userIds;
 }
 
@@ -274,7 +274,7 @@ function getArrayFromUserRefbackData ($id) {
        $id = bigintval($id);
 
        // Get entry from database
-       $result = SQL_QUERY_ESC("SELECT `id`, `userid`, `refid`, `refback_percents`, `level`, `refback_points` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1",
+       $result = SQL_QUERY_ESC("SELECT `id`,`userid`,`refid`,`refback_percents`,`level`,`refback_points` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `id`=%s AND `userid`=%s LIMIT 1",
                array($id, getMemberId()), __FUNCTION__, __LINE__);
 
        // Is there an entry?
@@ -313,10 +313,10 @@ function updateMemberRefbackPercents ($id, $percents, $note) {
        }
 
        // Get ref entry
-       $dummy = getArrayFromUserRefbackData($id);
+       $content = getArrayFromUserRefbackData($id);
 
        // Is this valid?
-       if (count($dummy) == 0) {
+       if (count($content) == 0) {
                // id does not belong to user!
                $status['message'] = 'MEMBER_REFBACK_ERROR_ID_MISMATCH';
                return $status;
@@ -341,17 +341,17 @@ function updateMemberRefbackPercents ($id, $percents, $note) {
        } // END - if
 
        // Prepare email content
-       $dummy['refback_percents'] = $percents;
-       $dummy['refback_note']     = $note;
+       $content['refback_percents'] = $percents;
+       $content['refback_note']     = $note;
 
        // Load member email template
-       $mail = loadEmailTemplate('member_refback', $dummy, $dummy['refid']);
+       $mail = loadEmailTemplate('member_refback', $content, $content['refid']);
 
        // Send email to user
-       sendEmail($dummy['refid'], '{--MEMBER_REFBACK_SUBJECT--}', $mail);
+       sendEmail($content['refid'], '{--MEMBER_REFBACK_SUBJECT--}', $mail);
 
        // Send admin notification
-       sendAdminNotification('{--ADMIN_REFBACK_SUBJECT--}', 'admin_refback', $dummy, $dummy['refid']);
+       sendAdminNotification('{--ADMIN_REFBACK_SUBJECT--}', 'admin_refback', $content, $content['refid']);
 
        // All fine!
        $status['ok'] = true;