X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-list_refs.php;h=8179b6a384602e0f9fc2a092d0d740c30ca0d343;hb=101e5f161c0c367c022c9288398226a57f3919d7;hp=6f4155dd02e120359e802589770e385e74ff8930;hpb=98e388b809fe0f6d5dbe2a02273a11e6816fb333;p=mailer.git
diff --git a/inc/modules/admin/what-list_refs.php b/inc/modules/admin/what-list_refs.php
index 6f4155dd02..8179b6a384 100644
--- a/inc/modules/admin/what-list_refs.php
+++ b/inc/modules/admin/what-list_refs.php
@@ -1,7 +1,7 @@
0
-ORDER BY level ASC", __FILE__, __LINE__);
- } else {
- // Loads surname, family's name and the email address
- $result = SQL_QUERY_ESC("SELECT COUNT(*) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s",
- array($uid), __FILE__, __LINE__);
- $result_lck = SQL_QUERY_ESC("SELECT COUNT(*) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s AND status != 'CONFIRMED' ORDER BY `userid` ASC",
- array($uid), __FILE__, __LINE__);
- $menge = SQL_RESULT($result , 0, 0);
- $menge_lck = SQL_RESULT($result_lck, 0, 0);
-
- // Free memory
- SQL_FREERESULT($result);
- SQL_FREERESULT($result_lck);
-
- // Query for refs
- $result_levels = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email, status, joined FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s ORDER BY userid ASC",
- array($uid), __FILE__, __LINE__);
-
- // Output info message
- LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink(REQUEST_GET('uid')), $menge, $menge_lck));
- }
+ 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
+ displayMessage(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_NUMROWS($result_levels) > 0) {
+ if (!SQL_HASZERONUMS($result_levels)) {
// List all ref levels or entries if no refback is installed
- $OUT = ''; $SW = 2;
+ $OUT = '';
while ($levels = SQL_FETCHARRAY($result_levels)) {
- // Insert more data
- $levels['sw'] = $SW;
-
// Is the refback still active? ;-)
- if (EXT_IS_ACTIVE('refback')) {
+ 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($uid, $levels['level']), __FILE__, __LINE__);
- //* DEBUG: */ echo $uid.'/'.$levels['level'].'/'.SQL_NUMROWS($result_refs)."
\n";
+ $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_NUMROWS($result_refs) > 0) {
- // Loads surname, family's name and the email address
- $result = SQL_QUERY_ESC("SELECT COUNT(*) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s",
- array($uid), __FILE__, __LINE__);
- $result_lck = SQL_QUERY_ESC("SELECT COUNT(*) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s AND status != 'CONFIRMED' ORDER BY `userid` ASC",
- array($uid), __FILE__, __LINE__);
- $menge = SQL_RESULT($result , 0, 0);
- $menge_lck = SQL_RESULT($result_lck, 0, 0);
-
- // Free memory
- SQL_FREERESULT($result);
- SQL_FREERESULT($result_lck);
+ 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($uid), $menge, $menge_lck);
+ $levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($userid), $menge, $menge_lck);
// Init variables
- $OUT_REFS = ''; $SW = 2;
+ $OUT_REFS = '';
// Load all refs
while ($content = SQL_FETCHARRAY($result_refs)) {
- // Query for data
- $result_user = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email, status, joined FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array($content['refid']), __FILE__, __LINE__);
-
// Is the data there?
- if (SQL_NUMROWS($result_user) == 1) {
- // Load data
- $data = SQL_FETCHARRAY($result_user);
-
+ if (fetchUserData($content['refid'])) {
// Check for referals
- $result_cnt = SQL_QUERY_ESC("SELECT COUNT(userid) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s",
- array($content['refid']), __FILE__, __LINE__);
-
- // Load refs
- $refs_cnt = SQL_RESULT($result_cnt, 0, 0);
-
- // Free result
- SQL_FREERESULT($result_cnt);
+ $refs_cnt = countSumTotalData(getUserData('userid'), 'user_refs', 'id', 'userid', true);
// Prepare data for the template
+ // @TODO Try to rewrite some to EL
$content = array(
- 'sw' => $SW,
- 'u_link' => generateUserProfileLink($data['userid']),
- 'gender' => translateGender($data['gender']),
- 'refs_link' => '0',
- 'surname' => $data['surname'],
- 'family' => $data['family'],
- 'email' => "[".$data['email']."]",
- 'status' => translateUserStatus($data['status']),
- 'registered' => generateDateTime($data['joined'], '3'),
+ '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($data['userid'], $refs_cnt, "list_refs");
+ if ($refs_cnt > 0) {
+ $content['refs_link'] = generateUserProfileLink(getUserData('userid'), $refs_cnt, 'list_refs');
+ } // END - if
// Load template for level one
- $OUT_REFS .= LOAD_TEMPLATE("admin_list_refs_row", true, $content);
+ $OUT_REFS .= loadTemplate('admin_list_refs_row', true, $content);
} else {
// No refs found
- $OUT_REFS = LOAD_TEMPLATE("admin_list_refs_nodata", true, $content['refid']);
+ $OUT_REFS = loadTemplate('admin_list_refs_nodata', true, $content);
}
- // Free result
- SQL_FREERESULT($result_user);
-
// Add content
$levels['rows'] = $OUT_REFS;
-
- // Switch colors
- $SW = 3 - $SW;
} // END - while
} else {
// Output info message
- $levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($uid), '0', '0');
+ $levels['info'] = sprintf(getMessage('ADMIN_USER_TOTAL_REFS'), generateUserProfileLink($userid), 0, 0);
// No refs found
- $levels['rows'] = LOAD_TEMPLATE("admin_list_refs_norefs", true, array('uid' => $uid));
+ $levels['rows'] = loadTemplate('admin_list_refs_norefs', true, array('userid' => $userid));
}
// Free result
SQL_FREERESULT($result_refs);
// Load level template
- $OUT .= LOAD_TEMPLATE("admin_list_refs_level", true, $levels);
+ $OUT .= loadTemplate('admin_list_refs_level', true, $levels);
} else {
// Check for referals
- $result_refs = SQL_QUERY_ESC("SELECT COUNT(userid) FROM `{!_MYSQL_PREFIX!}_user_data` WHERE refid=%s",
- array(bigintval($levels['userid'])), __FILE__, __LINE__);
- $refs_cnt = SQL_RESULT($result_refs, 0, 0);
- SQL_FREERESULT($result_refs);
+ $refs_cnt = countSumTotalData($levels['userid'], 'user_data', 'userid', 'refid', true);
// Prepare data for the template
$content = array(
- 'sw' => $SW,
- 'u_link' => generateUserProfileLink($levels['userid']),
- 'gender' => translateGender($levels['gender']),
- 'refs_link' => '0',
+ 'userid' => $levels['userid'],
+ 'gender' => $levels['gender'],
+ 'refs_link' => 0,
'surname' => $levels['surname'],
'family' => $levels['family'],
- 'email' => "[".$levels['email']."]",
- 'status' => translateUserStatus($levels['status']),
- 'registered' => generateDateTime($levels['joined'], '3'),
+ '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 .= LOAD_TEMPLATE('admin_list_refs_row', true, $content);
-
- // Switch colors
- $SW = 3 - $SW;
+ $OUT .= loadTemplate('admin_list_refs_row', true, $content);
}
} // END - while
// Prepare content
$content = array(
- 'rows' => $OUT,
- 'uid' => generateUserProfileLink(REQUEST_GET('uid'))
+ 'rows' => $OUT,
+ 'userid' => getRequestParameter('userid')
);
// Load main template
- if (EXT_IS_ACTIVE('refback')) {
- LOAD_TEMPLATE('admin_list_refs2', false, $content);
+ if (isExtensionActive('refback')) {
+ loadTemplate('admin_list_refs2', false, $content);
} else {
- LOAD_TEMPLATE('admin_list_refs', false, $content);
+ loadTemplate('admin_list_refs', false, $content);
}
- } elseif (EXT_IS_ACTIVE('refback')) {
+ } elseif (isExtensionActive('refback')) {
// No levels found, very bad!
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('ADMIN_NO_REF_LEVELS'));
+ displayMessage('{--ADMIN_NO_REFERAL_LEVELS--}');
} else {
// No refs made so far
- LOAD_TEMPLATE('admin_settings_saved', false, getMessage('USER_REF_404'));
+ displayMessage('{--USER_REFERAL_404--}');
}
// Free result
SQL_FREERESULT($result_levels);
} else {
// User not found
- LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_MEMBER_404'), REQUEST_GET('uid')));
+ displayMessage('{%message,ADMIN_MEMBER_404=' . getRequestParameter('userid') . '%}');
}
-
- // Free memory
- SQL_FREERESULT($result_user);
} else {
// Output selection form with all confirmed user accounts listed
- ADD_MEMBER_SELECTION_BOX();
+ addMemberSelectionBox();
}
-//
+// [EOF]
?>