]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-points.php
Renamed function so it might be more understandable
[mailer.git] / inc / modules / member / what-points.php
index 67aa5913f994f0ef8d088b865bc01727ca9faf9b..cf69736aad413f60309403d6193073fb585049f5 100644 (file)
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -44,25 +43,27 @@ if (!defined('__SECURITY')) {
 }
 
 // Add description as navigation point
-addMenuDescription('member', __FILE__);
+addYouAreHereLink('member', __FILE__);
 
 // Query for referal levels and percents
 $result_depths = SQL_QUERY("SELECT `level`, `percents` FROM `{?_MYSQL_PREFIX?}_refdepths` ORDER BY `level` ASC", __FILE__, __LINE__);
-$depths = SQL_NUMROWS($result_depths);
+
+// Get total depths
+$numDepths = SQL_NUMROWS($result_depths);
 
 // Add many more rows for the login/turbo/ref/order bonus
 // @TODO Should we rewrite this to a filter?
-if (!isExtensionActive('bonus')) $depths += 1;
-if (isExtensionInstalledAndNewer('bonus', '0.2.2')) $depths += 6;
-if (isExtensionInstalledAndNewer('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';
-$totalReferals = '0';
-$totalLocked = '0';
+$content['total_points'] = '0';
+$content['total_referals'] = '0';
+$content['total_locked'] = '0';
 $OUT = '';
 
 // Load ref levels
@@ -88,8 +89,8 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
                $content = merge_array($content, SQL_FETCHARRAY($result_points));
 
                // Add both points
-               $totalPoints += $content['points'];
-               $totalLocked += $content['locked_points'];
+               $content['total_points'] += $content['points'];
+               $content['total_locked'] += $content['locked_points'];
        } // END - if
 
        // Free result
@@ -108,22 +109,14 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
                $content = merge_array($content, SQL_FETCHARRAY($result_refs));
 
                // Add them to total refs
-               $totalReferals += $content['counter'];
+               $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($content['points']),
-               'refs'     => translateComma($content['counter']),
-       );
-
        // Output row
-       $OUT .= loadTemplate('member_points_row', true, $row);
+       $OUT .= loadTemplate('member_points_row', true, $content);
 } // END - while
 
 // Free memory
@@ -132,34 +125,8 @@ SQL_FREERESULT($result_depths);
 // Put rows to constant for the main template
 $content['rows'] = $OUT;
 
-// Initialize variables
-$CONFIRMED = '---'; $SENT = '---'; $RECEIVED = '---';
-
-// Only user >= v0.1.2: Fetch confirmed mails counter
-if (isExtensionInstalledAndNewer('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 ($totalLocked == '0') $totalLocked = '0.00000';
-
 // Remember several values in constants
-$content['sum']   = translateComma($totalPoints - getUserData('used_points'), false);
-$content['tref']  = translateComma($totalReferals);
-$content['tlock'] = translateComma($totalLocked);
+$content['total_points']  = ($content['total_points'] - getUserData('used_points'));
 
 // Fixes a bug when there is no bonus extension installed
 if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', 'X');
@@ -168,38 +135,13 @@ if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active
 $content['special_rows'] = '';
 
 // Display login bonus and turbo-click bonus
-if ((isExtensionInstalledAndNewer('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'], false);
-
-       // 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 ((isExtensionActive('bonus')) && (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'))) {
@@ -207,11 +149,6 @@ if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonu
        $content['special_rows'] = loadTemplate('member_points_upgrade');
 }
 
-// Remeber values for the final template
-$content['receive']   = translateComma($RECEIVED);
-$content['confirmed'] = translateComma($CONFIRMED);
-$content['sent']      = translateComma($SENT);
-
 // Load final template
 if (isExtensionActive('user')) {
        // Load template when required extension is there
@@ -221,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]