X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fmodules%2Fmember%2Fwhat-points.php;h=c0e9f07c0906c3e44cbecbdd9df707cb92982903;hp=86dc794f94694d8be72284f859e3e148b17277bf;hb=0f3a135204757cc8750262871c8e62c42300acb4;hpb=116747e4dba29e9e2e4daa82c45d8bbb302e9378 diff --git a/inc/modules/member/what-points.php b/inc/modules/member/what-points.php index 86dc794f94..c0e9f07c09 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 (GET_EXT_VERSION('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 -define('__ROWS_VALUE', ($depths*2+15)); +$content['rowspan'] = ($numDepths * 2 + 15); + +// Initialize array elements +$content['part_points'] = '0.00000'; +$content['part_referals'] = '0'; +$content['part_locked'] = '0.00000'; +$content['part_order'] = '0.00000'; +$content['part_locked_order'] = '0.00000'; -// Init some vars... -$TPTS = 0; $TREF = 0; $TLOCK = 0; $OUT = ''; +// And output variable +$OUT = ''; // Load ref levels -while ($content = SQL_FETCHARRAY($result_depths)) { - // Initialize ref-count - $REFS = 0; +while ($data = SQL_FETCHARRAY($result_depths)) { + // Init points and counter here + $content['counter'] = '0'; + $content['points'] = '0.00000'; + $content['order_points'] = '0.00000'; + $content['locked_points'] = '0.00000'; + $content['locked_order_points'] = '0.00000'; + + // Merge it together + $content = merge_array($content, $data); + + // Default for referal level > 0 + $depth = 'p.`ref_depth`=%s'; + if (is_null($content['level'])) { + $depth = 'p.`ref_depth` IS NULL'; + } // END - if // Load referal points - $result_points = SQL_QUERY_ESC("SELECT points, locked_points FROM `{!_MYSQL_PREFIX!}_user_points` WHERE userid=%s AND ref_depth=%d LIMIT 1", array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__); + $result_points = SQL_QUERY_ESC("SELECT + p.`points`, + p.`order_points`, + p.`locked_points`, + p.`locked_order_points`, + r.`counter` +FROM + `{?_MYSQL_PREFIX?}_user_points` AS p +LEFT JOIN + `{?_MYSQL_PREFIX?}_refsystem` AS r +ON + p.`userid`=r.`userid` AND + p.`ref_depth`=r.`level` +WHERE + p.`userid`=%s AND + ".$depth." +LIMIT 1", + array( + getMemberId(), + makeZeroToNull($content['level']) + ), __FILE__, __LINE__); + + // Do we have an entry? if (SQL_NUMROWS($result_points) == 1) { - list($points, $locked) = SQL_FETCHROW($result_points); - SQL_FREERESULT($result_points); - // Also count locked points - $TPTS += $points; $TLOCK += $locked; - } else { - $points = "0.00000"; $locked = "0.00000"; - } - - // 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__); - if (SQL_NUMROWS($result_refs) == 1) { - list($REFS) = SQL_FETCHROW($result_refs); - SQL_FREERESULT($result_refs); - $TREF += $REFS; - } else { - $REFS = 0; - } - - // Transfer data to array for template - $content = array( - 'lvl' => $content['level'], - 'per' => TRANSLATE_COMMA($content['percents']), - 'points' => TRANSLATE_COMMA($points), - 'refs' => TRANSLATE_COMMA($REFS), - ); + // Load data + $content = merge_array($content, SQL_FETCHARRAY($result_points)); + + // Add all entries + $content['part_points'] += $content['points']; + $content['part_order'] += $content['order_points']; + $content['part_locked'] += $content['locked_points']; + $content['part_locked_order'] += $content['locked_order_points']; + $content['part_referals'] += $content['counter']; + } // END - if + + // Free result + SQL_FREERESULT($result_points); // Output row - $OUT .= LOAD_TEMPLATE("member_points_row", true, $content); -} + $OUT .= loadTemplate('member_points_row', true, $content); +} // END - while // Free memory SQL_FREERESULT($result_depths); -// Put rows to constant for the main template -define('__REF_LEVEL_ROWS', $OUT); - -$result = SQL_QUERY_ESC("SELECT used_points, ref_payout FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array(getUserId()), __FILE__, __LINE__); -list($USED, $PAY) = SQL_FETCHROW($result); -SQL_FREERESULT($result); - -// Initialize variables -$CONFIRMED = "---"; $SENT = "---"; $RECEIVED = "---"; - -// Only user >= v0.1.2: Fetch confirmed mails counter -if (GET_EXT_VERSION('user') >= '0.1.2') { - $add = ''; - if (GET_EXT_VERSION('user') >= '0.1.4') { - $add = ", emails_sent, emails_received"; - } - $result = SQL_QUERY_ESC("SELECT mails_confirmed".$add." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", array(getUserId()), __FILE__, __LINE__); - list($CONFIRMED, $SENT, $RECEIVED) = SQL_FETCHROW($result); - SQL_FREERESULT($result); - - // Please update the user extension if you see 3 dashes - if (empty($SENT)) $SENT = "---"; - if (empty($RECEIVED)) $RECEIVED = "---"; -} else { - // Please update! - $CONFIRMED = "---"; -} +// Add userid +$content['userid'] = getMemberId(); -// If TLOCK is 0 add 3 zeros for floating -if ($TLOCK == "0") $TLOCK = "0.00000"; - -// Remember several values in constants -define('__USED_VALUE' , TRANSLATE_COMMA($USED)); -define('__TPTS_VALUE' , TRANSLATE_COMMA($TPTS - $USED)); -define('__TREF_VALUE' , $TREF); -define('__TLOCK_VALUE', TRANSLATE_COMMA($TLOCK)); +// Put rows to constant for the main template +$content['rows'] = $OUT; // Fixes a bug when there is no bonus extension installed -if (EXT_VERSION_IS_OLDER('bonus', '0.4.4')) setConfigEntry('bonus_active', "X"); +if (isExtensionInstalledAndOlder('bonus', '0.4.4')) { + setConfigEntry('bonus_active', 'X'); +} // END - if -// Display login bonus and turbo-click bonus -if ((GET_EXT_VERSION('bonus') >= '0.2.2') && (EXT_IS_ACTIVE('bonus')) && (getConfig('bonus_active') == 'Y')) { - $add = ", 0, 0, 0"; - if (GET_EXT_VERSION('bonus') >= '0.4.4') $add = ", bonus_ref, bonus_order, bonus_stats"; - - // Load data - $result = SQL_QUERY_ESC("SELECT login_bonus, turbo_bonus".$add." FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1", - array(getUserId()), __FILE__, __LINE__); - - // We don't add this points now. This will be done after each month - list($login, $turbo, $ref, $order, $stats) = SQL_FETCHROW($result); - SQL_FREERESULT($result); - - // Prepare constants - define('__TURBO_VALUE', TRANSLATE_COMMA($turbo)); - define('__LOGIN_VALUE', TRANSLATE_COMMA($login)); - - if (GET_EXT_VERSION('bonus') >= '0.4.4') { - // Add referal, stats and order bonys - define('__REF_VALUE' , TRANSLATE_COMMA($ref)); - define('__ORDER_VALUE', TRANSLATE_COMMA($order)); - define('__STATS_VALUE', TRANSLATE_COMMA($stats)); - } +// Members shall see no special rows here +$content['special_rows'] = ''; +// Display login bonus and turbo-click bonus +if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (isBonusRallyeActive())) { // Total bonus points - define('__TTOTAL_VALUE', TRANSLATE_COMMA($turbo + $login + $ref + $order + $stats)); + $content['bonus_total_points'] = getUserData('turbo_bonus') + getUserData('login_bonus') + getUserData('bonus_ref') + getUserData('bonus_order') + getUserData('bonus_stats'); // Output rows - define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_rows", true)); -} elseif (getConfig('bonus_active') != 'Y') { + $content['special_rows'] = loadTemplate('member_points_bonus_rows', true, $content); +} elseif ((isExtensionActive('bonus')) && (!isBonusRallyeActive())) { // Bonus active rallye deactivated - define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_bonus_disabled", true)); -} elseif ((IS_ADMIN()) && (EXT_VERSION_IS_OLDER('bonus', '0.2.2')) && (EXT_IS_ACTIVE('bonus'))) { + $content['special_rows'] = loadTemplate('member_points_bonus_disabled', true); +} elseif ((isAdmin()) && (isExtensionInstalledAndOlder('bonus', '0.2.2')) && (isExtensionActive('bonus'))) { // Please upgrade your bonus extension to v0.2.2 or newer! - define('__SPECIAL_ROWS', LOAD_TEMPLATE("member_points_upgrade")); -} else { - // Members shall see no special rows here - define('__SPECIAL_ROWS', ''); + $content['special_rows'] = loadTemplate('member_points_upgrade'); } -// Remeber values for the final template -define('__PAY_VALUE' , $PAY); -define('__CONFIRMED_VALUE', $CONFIRMED); -define('__RECEIVE_VALUE' , $RECEIVED); -define('__SENT_VALUE' , $SENT); - // Load final template -if (EXT_IS_ACTIVE('user')) { +if (isExtensionActive('user')) { // Load template when required extension is there - LOAD_TEMPLATE("member_points"); -} elseif (IS_ADMIN()) { + loadTemplate('member_points', false, $content); +} elseif (isAdmin()) { // Missing extension - addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), 'user'); + displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=user%}'); } else { // Message for user - LOAD_TEMPLATE('admin_settings_saved', false, getMessage('PROBLEM_POINTS_OVERVIEW_UNAVAILABLE')); + displayMessage('{--PROBLEM_POINTS_OVERVIEW_UNAVAILABLE--}'); } -if (EXT_IS_ACTIVE('payout')) { +if (isExtensionActive('payout')) { // Payput extension is installed and active so we can check if the user has enougth points - PAYOUT_OUTPUT_PAYOUT_LIST(REVERT_COMMA(($TPTS - $USED))); -} + outputPayoutList($content['part_points'] - getUserData('used_points')); +} // END - if -// +// [EOF] ?>