+ $result_refs = sqlQueryEscaped("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'].'/'.sqlNumRows($result_refs));
+
+ // Is there levels?
+ if (!ifSqlHasZeroNums($result_refs)) {
+ // Count entries
+ $totalReferrals = getUsersTotalReferrals($userid, $levels['level']);
+ $totalLockedReferrals = getUsersTotalLockedReferrals($userid, $levels['level']);
+
+ // Output info message
+ $levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($userid), $totalReferrals, $totalLockedReferrals);
+
+ // Init variables
+ $OUT_REFS = '';
+
+ // Load all refs
+ while ($content = sqlFetchArray($result_refs)) {
+ // Is the data there?
+ if (fetchUserData($content['refid'])) {
+ // Check for referrals
+ $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'),
+ 'refs_link' => '0',
+ 'email' => '[<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . getUserData('email') . '</a>]',
+ 'registered' => generateDateTime(getUserData('joined'), 3),
+ );
+
+ // Check if referral count is larger 0 and update link
+ if ($refs_cnt > 0) {
+ $content['refs_link'] = generateUserProfileLink(getUserData('userid'), $refs_cnt, 'list_refs');
+ } // END - if