0
ORDER BY
`level` ASC", __FILE__, __LINE__);
// Are there some levels (VERY BAD IF NONE!)
if (!SQL_HASZERONUMS($result_levels)) {
// List all ref levels or entries if no refback is installed
$OUT = '';
while ($levels = SQL_FETCHARRAY($result_levels)) {
// Is the refback still active? ;-)
if (isExtensionActive('refback')) {
// Load all refs of this user
$result_refs = SQL_QUERY_ESC("SELECT `refid` FROM `{?_MYSQL_PREFIX?}_user_refs` WHERE `userid`=%s AND `level`='%s' ORDER BY refid ASC",
array($userid, $levels['level']), __FILE__, __LINE__);
//* DEBUG: */ debugOutput($userid.'/'.$levels['level'].'/'.SQL_NUMROWS($result_refs));
// Do we have levels?
if (!SQL_HASZERONUMS($result_refs)) {
// Count entries
$menge = countSumTotalData($userid, 'user_data', 'userid', 'refid', true);
$menge_lck = countSumTotalData($userid, 'user_data', 'userid', 'refid', true, " AND `status` != 'CONFIRMED'");
// Output info message
$levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($userid), $menge, $menge_lck);
// Init variables
$OUT_REFS = '';
// Load all refs
while ($content = SQL_FETCHARRAY($result_refs)) {
// Is the data there?
if (fetchUserData($content['refid'])) {
// Check for referals
$refs_cnt = countSumTotalData(getUserData('userid'), 'user_refs', 'id', 'userid', true);
// Prepare data for the template
// @TODO Try to rewrite some to EL
$content = array(
'userid' => getUserData('userid'),
'gender' => getUserData('gender'),
'refs_link' => 0,
'surname' => getUserData('surname'),
'family' => getUserData('family'),
'email' => '[' . getUserData('email') . ']',
'status' => getUserData('status'),
'registered' => generateDateTime(getUserData('joined'), 3),
);
// Check if referal count is larger 0 and update link
if ($refs_cnt > 0) {
$content['refs_link'] = generateUserProfileLink(getUserData('userid'), $refs_cnt, 'list_refs');
} // END - if
// Load template for level one
$OUT_REFS .= loadTemplate('admin_list_refs_row', true, $content);
} else {
// No refs found
$OUT_REFS = loadTemplate('admin_list_refs_nodata', true, $content);
}
// Add content
$levels['rows'] = $OUT_REFS;
} // END - while
} else {
// Output info message
$levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($userid), 0, 0);
// No refs found
$levels['rows'] = loadTemplate('admin_list_refs_norefs', true, array('userid' => $userid));
}
// Free result
SQL_FREERESULT($result_refs);
// Load level template
$OUT .= loadTemplate('admin_list_refs_level', true, $levels);
} else {
// Check for referals
$refs_cnt = countSumTotalData($levels['userid'], 'user_data', 'userid', 'refid', true);
// Prepare data for the template
$content = array(
'userid' => $levels['userid'],
'gender' => $levels['gender'],
'refs_link' => 0,
'surname' => $levels['surname'],
'family' => $levels['family'],
'email' => '[' . $levels['email'] . ']',
'status' => $levels['status'],
'registered' => generateDateTime($levels['joined'], 3),
);
// Check if referal count is larger 0 and update link
if ($refs_cnt > 0) $content['refs_link'] = generateUserProfileLink($levels['userid'], $refs_cnt, 'list_refs');
// Load template for level one
$OUT .= loadTemplate('admin_list_refs_row', true, $content);
}
} // END - while
// Prepare content
$content = array(
'rows' => $OUT,
'userid' => getRequestParameter('userid')
);
// Load main template
if (isExtensionActive('refback')) {
loadTemplate('admin_list_refs2', false, $content);
} else {
loadTemplate('admin_list_refs', false, $content);
}
} elseif (isExtensionActive('refback')) {
// No levels found, very bad!
displayMessage('{--ADMIN_NO_REFERAL_LEVELS--}');
} else {
// No refs made so far
displayMessage('{--USER_REFERAL_404--}');
}
// Free result
SQL_FREERESULT($result_levels);
} else {
// User not found
displayMessage(getMaskedMessage('ADMIN_MEMBER_404', getRequestParameter('userid')));
}
} else {
// Output selection form with all confirmed user accounts listed
addMemberSelectionBox();
}
// [EOF]
?>