2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 01/28/2004 *
4 * =================== Last change: 06/10/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-list_refs.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Show all referrals made by a member *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle generierten Refs eines Mitgliedes anzeigen *
12 * -------------------------------------------------------------------- *
13 * Copyright (c) 2003 - 2009 by Roland Haeder *
14 * Copyright (c) 2009 - 2012 by Mailer Developer Team *
15 * For more information visit: http://mxchange.org *
17 * This program is free software; you can redistribute it and/or modify *
18 * it under the terms of the GNU General Public License as published by *
19 * the Free Software Foundation; either version 2 of the License, or *
20 * (at your option) any later version. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
25 * GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, write to the Free Software *
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
31 ************************************************************************/
33 // Some security stuff...
34 if ((!defined('__SECURITY')) || (!isAdmin())) {
38 // Add description as navigation point
39 addYouAreHereLink('admin', __FILE__);
41 if (isGetRequestElementSet('userid')) {
43 $userid = bigintval(getRequestElement('userid'));
45 // Fix missing variable
46 $result_levels = false;
49 if (fetchUserData($userid)) {
51 $totalReferrals = getUsersTotalReferrals($userid);
52 $totalLockedReferrals = getUsersTotalLockedReferrals($userid);
54 // Output info message
55 displayMessage(sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink(getRequestElement('userid')), $totalReferrals, $totalLockedReferrals));
57 // Load all referral levels
58 $result_levels = SQL_QUERY("SELECT
62 `{?_MYSQL_PREFIX?}_refdepths`
66 `level` ASC", __FILE__, __LINE__);
68 // Are there some levels (VERY BAD IF NONE!)
69 if (!SQL_HASZERONUMS($result_levels)) {
70 // List all ref levels or entries if no refback is installed
72 while ($levels = SQL_FETCHARRAY($result_levels)) {
73 // Load all refs of this user
74 $result_refs = SQL_QUERY_ESC("SELECT `refid` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`=%s ORDER BY `refid` ASC",
78 ), __FILE__, __LINE__);
79 //* DEBUG: */ debugOutput($userid.'/'.$levels['level'].'/'.SQL_NUMROWS($result_refs));
82 if (!SQL_HASZERONUMS($result_refs)) {
84 $totalReferrals = getUsersTotalReferrals($userid, $levels['level']);
85 $totalLockedReferrals = getUsersTotalLockedReferrals($userid, $levels['level']);
87 // Output info message
88 $levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($userid), $totalReferrals, $totalLockedReferrals);
94 while ($content = SQL_FETCHARRAY($result_refs)) {
96 if (fetchUserData($content['refid'])) {
97 // Check for referrals
98 $refs_cnt = countSumTotalData(getUserData('userid'), 'user_refs', 'id', 'userid', true);
100 // Prepare data for the template
101 // @TODO Try to rewrite some to EL
103 'userid' => getUserData('userid'),
105 'email' => '[<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . getUserData('email') . '</a>]',
106 'registered' => generateDateTime(getUserData('joined'), 3),
109 // Check if referral count is larger 0 and update link
111 $content['refs_link'] = generateUserProfileLink(getUserData('userid'), $refs_cnt, 'list_refs');
114 // Load template for level one
115 $OUT_REFS .= loadTemplate('admin_list_refs_row', true, $content);
118 $OUT_REFS = loadTemplate('admin_list_refs_nodata', true, $content);
122 $levels['rows'] = $OUT_REFS;
125 // Output info message
126 $levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($userid), 0, 0);
129 $levels['rows'] = loadTemplate('admin_list_refs_norefs', true, array('userid' => $userid));
133 SQL_FREERESULT($result_refs);
135 // Load level template
136 $OUT .= loadTemplate('admin_list_refs_level', true, $levels);
142 'userid' => getRequestElement('userid')
145 // Load main template
146 loadTemplate('admin_list_refs', false, $content);
148 // No refs made so far
149 displayMessage('{--USER_REFERRAL_404--}');
153 SQL_FREERESULT($result_levels);
156 displayMessage('{%message,ADMIN_MEMBER_404=' . getRequestElement('userid') . '%}');
159 // Output selection form with all confirmed user accounts listed
160 addMemberSelectionBox();