X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fmember%2Fwhat-points.php;h=cf69736aad413f60309403d6193073fb585049f5;hp=4df5afb32fb45f4b6b6bd966f83aba98dbeaeabb;hb=e8ca54fe91872ab95a6ffdc4f1268bf18889021d;hpb=9f6c30cc0e06098171d773d671292081ecee3d29 diff --git a/inc/modules/member/what-points.php b/inc/modules/member/what-points.php index 4df5afb32f..cf69736aad 100644 --- a/inc/modules/member/what-points.php +++ b/inc/modules/member/what-points.php @@ -1,7 +1,7 @@ = '0.2.2') $depths += 6; -if (getExtensionVersion('bonus') >= '0.4.4') $depths += 4; +if (!isExtensionActive('bonus')) $numDepths += 1; +if (isExtensionInstalledAndNewer('bonus', '0.2.2')) $numDepths += 6; +if (isExtensionInstalledAndNewer('bonus', '0.4.4')) $numDepths += 4; // Remember row count in constant -$content['rowspan'] = ($depths*2+15); +$content['rowspan'] = ($numDepths * 2 + 15); // Init some vars... -$totalPoints = 0; $TREF = 0; $TLOCK = 0; $OUT = ''; +$content['total_points'] = '0'; +$content['total_referals'] = '0'; +$content['total_locked'] = '0'; +$OUT = ''; // Load ref levels while ($data = SQL_FETCHARRAY($result_depths)) { // Merge it together $content = merge_array($content, $data); - // Initialize ref-count - $REFS = 0; + // Initialize array elements + $content['counter'] = '0'; + $content['points'] = '0.00000'; + $content['locked_points'] = '0.00000'; // Load referal points - $result_points = SQL_QUERY_ESC("SELECT `points`, `locked_points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1", array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__); + $result_points = SQL_QUERY_ESC("SELECT `points`, `locked_points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1", + array( + getMemberId(), + bigintval($content['level']) + ), __FILE__, __LINE__); + + // Do we have an entry? if (SQL_NUMROWS($result_points) == 1) { - list($points, $locked) = SQL_FETCHROW($result_points); - // Also count locked points - $totalPoints += $points; $TLOCK += $locked; - } else { - $points = '0.00000'; $locked = '0.00000'; - } + // Load data + $content = merge_array($content, SQL_FETCHARRAY($result_points)); + + // Add both points + $content['total_points'] += $content['points']; + $content['total_locked'] += $content['locked_points']; + } // END - if // Free result SQL_FREERESULT($result_points); // Load referal counts $result_refs = SQL_QUERY_ESC("SELECT `counter` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s AND `level`='%s' LIMIT 1", - array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__); + array( + getMemberId(), + bigintval($content['level']) + ), __FILE__, __LINE__); + + // Do we have an entry? if (SQL_NUMROWS($result_refs) == 1) { - list($REFS) = SQL_FETCHROW($result_refs); - $TREF += $REFS; - } else { - $REFS = 0; - } + // Load data + $content = merge_array($content, SQL_FETCHARRAY($result_refs)); + + // Add them to total refs + $content['total_referals'] += $content['counter']; + } // END - if // Free result SQL_FREERESULT($result_refs); - // Transfer data to array for template - $row = array( - 'level' => $content['level'], - 'percents' => translateComma($content['percents']), - 'points' => translateComma($points), - 'refs' => translateComma($REFS), - ); - // Output row - $OUT .= loadTemplate('member_points_row', true, $row); + $OUT .= loadTemplate('member_points_row', true, $content); } // END - while // Free memory @@ -114,81 +125,23 @@ SQL_FREERESULT($result_depths); // Put rows to constant for the main template $content['rows'] = $OUT; -// Fetch user account -if (!fetchUserData(getUserId())) { - // Something really bad happened - debug_report_bug('User account ' . getUserId() . ' not found.'); -} // END - if - -// Initialize variables -$CONFIRMED = '---'; $SENT = '---'; $RECEIVED = '---'; - -// Only user >= v0.1.2: Fetch confirmed mails counter -if (getExtensionVersion('user') >= '0.1.2') { - $add = ''; - $CONFIRMED = getUserData('mails_confirmed'); - - if (getExtensionVersion('user') >= '0.1.4') { - $SENT = getUserData('emails_sent'); - $RECEIVED = getUserData('emails_received'); - } // END - if - - // Please update the user extension if you see 3 dashes - if (empty($SENT)) $SENT = '---'; - if (empty($RECEIVED)) $RECEIVED = '---'; -} else { - // Please update! - $CONFIRMED = '---'; -} - -// If TLOCK is 0 add 3 zeros for floating -if ($TLOCK == 0) $TLOCK = '0.00000'; - // Remember several values in constants -$content['used'] = translateComma(getUserData('used_points')); -$content['sum'] = translateComma($totalPoints - getUserData('used_points')); -$content['tref'] = $TREF; -$content['tlock'] = translateComma($TLOCK); +$content['total_points'] = ($content['total_points'] - getUserData('used_points')); // Fixes a bug when there is no bonus extension installed -if (isExtensionOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', "X"); +if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', 'X'); // Members shall see no special rows here $content['special_rows'] = ''; // Display login bonus and turbo-click bonus -if ((getExtensionVersion('bonus') >= '0.2.2') && (isExtensionActive('bonus')) && (getConfig('bonus_active') == 'Y')) { - // Fetch some data and init others (to avoid a notice here) - $content['login'] = getUserData('login_bonus'); - $content['turbo'] = getUserData('turbo_bonus'); - $content['ref'] = '0.00000'; - $content['order'] = '0.00000'; - $content['stats'] = '0.00000'; - - // Get more data if ext-bonus is newer - if (getExtensionVersion('bonus') >= '0.4.4') { - $content['ref'] = getUserData('bonus_ref'); - $content['order'] = getUserData('bonus_order'); - $content['stats'] = getUserData('bonus_stats'); - } // END - if - +if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (isBonusRallyeActive())) { // Total bonus points - $content['ttotal'] = translateComma($content['turbo'] + $content['login'] + $content['ref'] + $content['order'] + $content['stats']); - - // Translate more data - $content['turbo'] = translateComma($content['turbo']); - $content['login'] = translateComma($content['login']); - - if (getExtensionVersion('bonus') >= '0.4.4') { - // Add referal, stats and order bonys - $content['ref'] = translateComma($content['ref']); - $content['order'] = translateComma($content['order']); - $content['stats'] = translateComma($content['stats']); - } // END - if + $content['total'] = getUserData('turbo_bonus') + getUserData('login_bonus') + getUserData('bonus_ref') + getUserData('bonus_order') + getUserData('bonus_stats'); // Output rows $content['special_rows'] = loadTemplate('member_points_bonus_rows', true, $content); -} elseif (getConfig('bonus_active') != 'Y') { +} elseif ((isExtensionActive('bonus')) && (!isBonusRallyeActive())) { // Bonus active rallye deactivated $content['special_rows'] = loadTemplate('member_points_bonus_disabled', true); } elseif ((isAdmin()) && (isExtensionOlder('bonus', '0.2.2')) && (isExtensionActive('bonus'))) { @@ -196,12 +149,6 @@ if ((getExtensionVersion('bonus') >= '0.2.2') && (isExtensionActive('bonus')) && $content['special_rows'] = loadTemplate('member_points_upgrade'); } -// Remeber values for the final template -$content['receive'] = $RECEIVED; -$content['pay'] = getUserData('ref_payout'); -$content['confirmed'] = $CONFIRMED; -$content['sent'] = $SENT; - // Load final template if (isExtensionActive('user')) { // Load template when required extension is there @@ -211,12 +158,12 @@ if (isExtensionActive('user')) { loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('user')); } else { // Message for user - loadTemplate('admin_settings_saved', false, getMessage('PROBLEM_POINTS_OVERVIEW_UNAVAILABLE')); + loadTemplate('admin_settings_saved', false, '{--PROBLEM_POINTS_OVERVIEW_UNAVAILABLE--}'); } if (isExtensionActive('payout')) { // Payput extension is installed and active so we can check if the user has enougth points - outputPayoutList(convertCommaToDot(($totalPoints - getUserData('used_points')))); + outputPayoutList($content['total_points'] - getUserData('used_points')); } // END - if // [EOF]