]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Required fix for NULL vs. 0 in user_points
[mailer.git] / inc / mysql-manager.php
index 45dbbf1a0ae904d991a92137a8c70a8efdfb7f22..4b9ee0e0138ad015586eaf8baec4091bb696f930 100644 (file)
@@ -1034,7 +1034,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
        if (!isset($GLOBALS['ref_level'])) {
                // Initialialize referal system
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, ' Referal system initialized!');
-               $GLOBALS['ref_level'] = '0';
+               $GLOBALS['ref_level'] = NULL;
        } else {
                // Increase referal level
                $GLOBALS['ref_level']++;
@@ -1077,7 +1077,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                                        $pointsColumn,
                                        $ref_points,
                                        bigintval($userid),
-                                       bigintval($GLOBALS['ref_level'])
+                                       makeZeroToNull($GLOBALS['ref_level'])
                                ), __FUNCTION__, __LINE__);
                        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'pointsColumn='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$addMode.' - UPDATE! ('.SQL_AFFECTEDROWS().')');
 
@@ -1088,7 +1088,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                                        array(
                                                $pointsColumn,
                                                bigintval($userid),
-                                               bigintval($GLOBALS['ref_level']),
+                                               makeZeroToNull($GLOBALS['ref_level']),
                                                $ref_points
                                        ), __FUNCTION__, __LINE__);
                                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'data='.$pointsColumn.',ref_points='.$ref_points.',userid='.$userid.',depth='.$GLOBALS['ref_level'].',mode='.$addMode.' - INSERTED! ('.SQL_AFFECTEDROWS().')');
@@ -2014,9 +2014,9 @@ function updateLastActivity($userid) {
 // Get points data for given extension's name
 function getPointsDataArrayFromExtensionName ($ext_name) {
        // If we have cache, shortcut it here
-       if (isset($GLOBALS['cache_array']['points_data'])) {
+       if (isset($GLOBALS['cache_array']['points_data'][$ext_name])) {
                // Return it
-               return $GLOBALS['cache_array']['points_data'];
+               return $GLOBALS['cache_array']['points_data'][$ext_name];
        } // END - if
 
        // Now checkout the entry in database table
@@ -2030,21 +2030,21 @@ function getPointsDataArrayFromExtensionName ($ext_name) {
 
                // Add all remaining entries
                foreach ($pointsData as $key=>$value) {
-                       $GLOBALS['cache_array']['points_data'][$key][$ext_name][$isLocked] = $value;
+                       $GLOBALS['cache_array']['points_data'][$ext_name][$key] = $value;
                } // END - foreach
        } else {
                /*
                 * Having no entry is not bad but it means that all points will go to
                 * the general account which the user can let payout.
                 */
-               logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ',isLocked=' . intval($isLocked) . ' - No entry found, switching to general points account.');
+               logDebugMessage(__FUNCTION__, __LINE__, 'ext_name=' . $ext_name . ' - No entry found, switching to general points account.');
        }
 
        // Free result
        SQL_FREERESULT($result);
 
        // Return it
-       return $GLOBALS['cache_array']['points_data'];
+       return $GLOBALS['cache_array']['points_data'][$ext_name];
 }
 
 // Determines the right points column name for given extension and 'locked'
@@ -2059,7 +2059,7 @@ function getPointsColumnNameFromExtensionNameLocked ($ext_name, $isLocked) {
        $pointsData = getPointsDataArrayFromExtensionName($ext_name);
 
        // Regular points by default
-       $columnName = $pointsData['columnName'];
+       $columnName = $pointsData['column_name'];
 
        // Are the points locked?
        if (($isLocked === true) && ($pointsData['locked_mode'] == 'LOCKED')) {
@@ -2068,7 +2068,25 @@ function getPointsColumnNameFromExtensionNameLocked ($ext_name, $isLocked) {
        } // END - if
 
        // Return the result
-       return $columName;
+       return $columnName;
+}
+
+// Determines the payment method for given extension and 'locked'
+function getPaymentMethodFromExtensionName ($ext_name) {
+       // Extension sql_patches must be up-to-date
+       if (isExtensionInstalledAndOlder('sql_patches', '0.8.0')) {
+               // Please update ext-sql_patches
+               debug_report_bug(__FUNCTION__, __LINE__, 'sql_patches is out-dated. Please update to at least 0.8.0 to continue. ext_name=' . $ext_name . ',isLocked=' . intval($isLocked));
+       } // END - if
+
+       // Get the points_data entry
+       $pointsData = getPointsDataArrayFromExtensionName($ext_name);
+
+       // Regular points by default
+       $paymentMethod = $pointsData['payment_method'];
+
+       // Return the result
+       return $paymentMethod;
 }
 
 // [EOF]