X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_refs.php;h=4e01e4a6bdc2ad3f6b76e77a61810f99ea4f1c2a;hb=64ad7e20acdc9b16363e25cecc3e7f2a0f435a37;hp=35b5f3b6ac0061c5b95d823409a351699d37715f;hpb=7c92b706722b1bd4c8af68b213b65c1bf8e68eee;p=mailer.git
diff --git a/inc/modules/admin/what-list_refs.php b/inc/modules/admin/what-list_refs.php
index 35b5f3b6ac..4e01e4a6bd 100644
--- a/inc/modules/admin/what-list_refs.php
+++ b/inc/modules/admin/what-list_refs.php
@@ -1,12 +1,12 @@
");
- if ($result)
- {
- $rows = SQL_NUMROWS($result);
- if ($rows > 0)
- {
- // Load all referrals
- $SW = "2"; $OUT = "";
- while ($row = SQL_FETCHROW($result))
- {
- // Check for referrals
- $result_refs = SQL_QUERY_ESC("SELECT COUNT(userid) FROM "._MYSQL_PREFIX."_user_data WHERE refid=%s",
- array(bigintval($row[0])), __FILE__, __LINE__);
- $refs_cnt = SQL_RESULT($result_refs, 0, 0);
+addYouAreHereLink('admin', __FILE__);
+
+if (isGetRequestParameterSet('userid')) {
+ // Secure userid
+ $userid = bigintval(getRequestParameter('userid'));
+
+ // Fix missing variable
+ $result_levels = false;
+
+ // User found?
+ if (fetchUserData($userid)) {
+ // Get total refs
+ $menge = countSumTotalData($userid, 'user_data', 'userid', 'refid', true);
+ $menge_lck = countSumTotalData($userid, 'user_data', 'userid', 'refid', true, " AND `status` != 'CONFIRMED'");
+
+ // Output info message
+ loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink(getRequestParameter('userid')), $menge, $menge_lck));
+
+ // Load all referal levels
+ $result_levels = SQL_QUERY("SELECT
+ `level`, `percents`
+FROM
+ `{?_MYSQL_PREFIX?}_refdepths`
+WHERE
+ `level` > 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');
+
+ // 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(
- 'sw' => $SW,
- 'u_link' => ADMIN_USER_PROFILE_LINK($row[0]),
- 'gender' => TRANSLATE_GENDER($row[1]),
- 'refs_link' => "0",
- 'surname' => $row[2],
- 'family' => $row[3],
- 'email' => "".$row[4]."",
- 'status' => TRANSLATE_STATUS($row[5]),
- 'registered' => MAKE_DATETIME($row[6], "3"),
+ '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 referral count is larger 0 and update link
- if ($refs_cnt > 0) $content['refs_link'] = ADMIN_USER_PROFILE_LINK($row[0], $refs_cnt, "list_refs");
+ // 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 row template and switch color
- $OUT .= LOAD_TEMPLATE("admin_list_refs_row", true, $content);
- $SW = 3 - $SW;
+ // Load template for level one
+ $OUT .= loadTemplate('admin_list_refs_row', true, $content);
}
+ } // END - while
- // Free memory
- SQL_FREERESULT($result);
- define('__REF_ROWS', $OUT);
+ // Prepare content
+ $content = array(
+ 'rows' => $OUT,
+ 'userid' => getRequestParameter('userid')
+ );
- // Load main template
- LOAD_TEMPLATE("admin_list_refs");
+ // 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!
+ loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_REFERAL_LEVELS--}');
+ } else {
+ // No refs made so far
+ loadTemplate('admin_settings_saved', false, '{--USER_REFERAL_404--}');
}
- else
- {
- // No referrals made so far
- LOAD_TEMPLATE("admin_settings_saved", false, USER_REF_404);
- }
- }
- else
- {
+
+ // Free result
+ SQL_FREERESULT($result_levels);
+ } else {
// User not found
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2);
+ loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_MEMBER_404', getRequestParameter('userid')));
}
-}
- else
-{
+} else {
// Output selection form with all confirmed user accounts listed
- ADD_MEMBER_SELECTION_BOX();
+ addMemberSelectionBox();
}
-//
+// [EOF]
?>