]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-points.php
Introduced template call-back function 'doTemplateAdminListUserTitle':
[mailer.git] / inc / modules / member / what-points.php
index 6932b6ecd04b07e76792e65f0df88f305c9bf0c3..d83e597a0b820624b68c4a1d973287f129e5feab 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                    *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -45,20 +43,22 @@ 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...
 $content['total_points'] = '0';
@@ -72,12 +72,26 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
        $content = merge_array($content, $data);
 
        // Initialize array elements
-       $content['counter'] = '0';
-       $content['points'] = '0.00000';
+       $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",
+       $result_points = SQL_QUERY_ESC("SELECT
+       p.`points`,
+       p.`locked_points`,
+       r.`counter`
+FROM
+       `{?_MYSQL_PREFIX?}_user_points` AS p
+INNER JOIN
+       `{?_MYSQL_PREFIX?}_refsystem` AS r
+ON
+       p.`userid`=r.`userid` AND
+       p.`ref_depth`=r.`level`
+WHERE
+       p.`userid`=%s AND
+       p.`ref_depth`='%s'
+LIMIT 1",
                array(
                        getMemberId(),
                        bigintval($content['level'])
@@ -88,27 +102,9 @@ while ($data = SQL_FETCHARRAY($result_depths)) {
                // 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(
-                       getMemberId(),
-                       bigintval($content['level'])
-               ), __FILE__, __LINE__);
-
-       // Do we have an entry?
-       if (SQL_NUMROWS($result_refs) == 1) {
-               // Load data
-               $content = merge_array($content, SQL_FETCHARRAY($result_refs));
-
-               // Add them to total refs
+               // Add all entries
+               $content['total_points']   += $content['points'];
+               $content['total_locked']   += $content['locked_points'];
                $content['total_referals'] += $content['counter'];
        } // END - if
 
@@ -125,49 +121,25 @@ SQL_FREERESULT($result_depths);
 // Put rows to constant for the main template
 $content['rows'] = $OUT;
 
-// Initialize variables
-$content['confirmed'] = '---';
-$content['sent']      = '---';
-$content['receive']  = '---';
-
-// Only user >= v0.1.2: Fetch confirmed mails counter
-if (isExtensionInstalledAndNewer('user', '0.1.2')) {
-       $add = '';
-       $content['confirmed'] = getUserData('mails_confirmed');
-
-       if (isExtensionInstalledAndNewer('user', '0.1.4')) {
-               $content['sent']     = getUserData('emails_sent');
-               $content['receive'] = getUserData('emails_received');
-       } // END - if
-
-       // Please update the user extension if you see 3 dashes
-       if (empty($content['sent']))     $content['sent']     = '---';
-       if (empty($content['receive'])) $content['receive'] = '---';
-} else {
-       // Please update!
-       $content['confirmed'] = '---';
-}
-
-// If TLOCK is 0 add 3 zeros for floating
-if ($content['total_locked'] == '0') $content['total_locked'] = '0.00000';
-
 // Remember several values in constants
 $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');
+if (isExtensionInstalledAndOlder('bonus', '0.4.4')) {
+       setConfigEntry('bonus_active', 'X');
+} // END - if
 
 // 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')) && (getConfig('bonus_active') == 'Y')) {
+if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && (isExtensionActive('bonus')) && (isBonusRallyeActive())) {
        // Total bonus points
        $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'))) {
@@ -181,10 +153,10 @@ if (isExtensionActive('user')) {
        loadTemplate('member_points', false, $content);
 } elseif (isAdmin()) {
        // Missing extension
-       loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('user'));
+       displayMessage(generateExtensionInactiveNotInstalledMessage('user'));
 } else {
        // Message for user
-       loadTemplate('admin_settings_saved', false, '{--PROBLEM_POINTS_OVERVIEW_UNAVAILABLE--}');
+       displayMessage('{--PROBLEM_POINTS_OVERVIEW_UNAVAILABLE--}');
 }
 
 if (isExtensionActive('payout')) {