Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / modules / member / what-reflist.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 09/09/2008 *
4  * ===================                          Last change: 09/09/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-reflist.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Refback setup                                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Refback-Einstellungen                            *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         exit();
41 } elseif (!isMember()) {
42         // User is not logged in
43         redirectToIndexMemberOnlyModule();
44 }
45
46 // Add description as navigation point
47 addYouAreHereLink('member', __FILE__);
48
49 // Load all referral levels
50 $result = sqlQuery('SELECT
51         `level`,
52         `percents`
53 FROM
54         `{?_MYSQL_PREFIX?}_refdepths`
55 WHERE
56         `level` > 0
57 ORDER BY
58         `level` ASC', __FILE__, __LINE__);
59
60 // Are there some entries? (Shall be!)
61 if (!ifSqlHasZeroNumRows($result)) {
62         // List all levels
63         $OUT = '';
64         while ($content = sqlFetchArray($result)) {
65                 // Init variables
66                 $rows = '';
67                 $counter = '0';
68
69                 // Check for users ref in this level
70                 foreach (getUserReferralPoints(getMemberId(), $content['level']) as $refRow) {
71                         // Load row template
72                         $rows .= loadTemplate('member_list_referral_row', TRUE, $refRow);
73
74                         // Count this ref and switch color
75                         $counter++;
76                 } // END - foreach
77
78                 // Remember the content
79                 $content['counter']  = $counter;
80                 $content['percents'] = translateComma($content['percents'], TRUE, 1);
81                 $content['rows']     = $rows;
82
83                 // Load level template
84                 $OUT .= loadTemplate('member_list_referral_level', TRUE, $content);
85         } // END - while
86
87         // Load main template
88         loadTemplate('member_list_referral', FALSE, $OUT);
89 } else {
90         // No entries
91         displayMessage('{--MEMBER_REFBACK_NO_ENTRIES--}');
92 }
93
94 // Free result
95 sqlFreeResult($result);
96
97 // [EOF]
98 ?>