require($INC);
}
-function alpha($sortby, $colspan, $return=false)
-{
+// Add links for selecting some users
+function alpha($sortby, $colspan, $return=false) {
global $_CONFIG;
if (empty($_GET['offset'])) $_GET['offset'] = 0;
- $ADD = "&page=".$_GET['page']."&offset=".$_GET['offset'];
+ $ADD = "&page=".SQL_ESCAPE($_GET['page'])."&offset=".SQL_ESCAPE($_GET['offset']);
if (!empty($_GET['mode'])) $ADD .= "&mode=".SQL_ESCAPE($_GET['mode']);
/* Creates the list of letters and makes them a link. */
$alphabet = array(_ALL2,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",_OTHERS);
$num = count($alphabet) - 1;
$OUT = "";
- while (list($counter, $ltr) = each($alphabet))
- {
- if ($_GET['letter'] == $ltr)
- {
+ while (list($counter, $ltr) = each($alphabet)) {
+ if ($_GET['letter'] == $ltr) {
// Current letter is letter from URL
$OUT .= "<STRONG>".$ltr."</STRONG>";
- }
- else
- {
+ } else {
// Output link to letter
$OUT .= "<A href=\"".URL."/modules.php?module=admin&what=".$GLOBALS['what'];
if (!empty($_GET['mode'])) $OUT .= "&mode=".SQL_ESCAPE($_GET['mode']);
$OUT .= "&letter=".$ltr."&sortby=".$sortby.$ADD."\">".$ltr."</A>";
}
- if ((($counter / $_CONFIG['user_alpha']) == round($counter / $_CONFIG['user_alpha'])) && ($counter > 0))
- {
+
+ if ((($counter / getConfig('user_alpha')) == round($counter / getConfig('user_alpha'))) && ($counter > 0)) {
$OUT .= " ]<br />[ ";
- }
- elseif ( $counter != $num )
- {
+ } elseif ( $counter != $num ) {
$OUT .= " | ";
}
- }
+ } // END - while
+
define('__ALPHA_LIST', $OUT);
// Load template
$OUT = LOAD_TEMPLATE("admin_list_user_alpha", true);
- if ($return)
- {
+ if ($return) {
// Return generated code
return $OUT;
- }
- else
- {
+ } else {
// Output generated code
OUTPUT_HTML($OUT);
}
}
-//
-function SortLinks($letter, $sortby, $colspan, $return=false)
-{
+
+// Add links for sorting
+function SortLinks($letter, $sortby, $colspan, $return=false) {
$OUT = "";
if (empty($_GET['offset'])) $_GET['offset'] = 0;
- $ADD = "&page=".$_GET['page']."&offset=".$_GET['offset'];
- if (!empty($_GET['mode'])) $ADD .= "&mode=".SQL_ESCAPE($_GET['mode']);
+ if (empty($_GET['page'])) $_GET['page'] = 0;
+
+ // Add page and offset
+ $ADD = "&page=".SQL_ESCAPE($_GET['page'])."&offset=".SQL_ESCAPE($_GET['offset']);
+
+ // Add status or mode
+ if (!empty($_GET['status'])) $ADD .= "&mode=".SQL_ESCAPE($_GET['status']);
+ elseif (!empty($_GET['mode'])) $ADD .= "&mode=".SQL_ESCAPE($_GET['mode']);
// Makes order by links..
if ($letter == "front") $letter = _ALL2;
} else {
$OUT .= "<A href=\"".URL."/modules.php?module=admin&what=list_user&letter=".$letter."&sortby=".$sort.$ADD."\">".$title."</a> | ";
}
- }
+ } // END - foreach
+
define('__SORT_LIST', substr($OUT, 0, -13));
// Load template
$OUT = LOAD_TEMPLATE("admin_list_user_sort", true);
- if ($return)
- {
+ if ($return) {
// Return code
return $OUT;
- }
- else
- {
+ } else {
// Output code
OUTPUT_HTML($OUT);
}
}
-//
-function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false)
-{
- if (!$show_form)
- {
+
+// Add page navigation
+function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false) {
+ if (!$show_form) {
// Empty row
define('__FORM_HEADER', "<TR><TD colspan=\"".$colspan."\" class=\"seperator\"> </TD></TR>");
- }
- else
- {
+ } else {
// Load form for changing number of lines
define('__FORM_HEADER', LOAD_TEMPLATE("admin_list_user_sort_form", true));
}
- if (!$show_form)
- {
+
+ if (!$show_form) {
// Add line with bottom border
define('__FORM_FOOTER', "<TR><TD colspan=\"".__COLSPAN2."\" class=\"seperator bottom2\"> </TD></TR>");
- }
- else
- {
+ } else {
// Add line without bottom border
define('__FORM_FOOTER', "<TR><TD colspan=\"".__COLSPAN2."\" class=\"seperator bottom2\"> </TD></TR>");
}
$OUT = "";
- for ($page = 1; $page <= $PAGES; $page++)
- {
- if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1")))
- {
+ for ($page = 1; $page <= $PAGES; $page++) {
+ if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1"))) {
$OUT .= "<STRONG>-";
- }
- else
- {
+ } else {
if (empty($_GET['letter'])) $_GET['letter'] = _ALL2;
if (empty($_GET['sortby'])) $_GET['sortby'] = "userid";
+
+ // Base link
$OUT .= "<A href=\"".URL."/modules.php?module=admin&what=".$GLOBALS['what'];
- if (!empty($_GET['mode'])) $OUT .= "&mode=".SQL_ESCAPE($_GET['mode']);
- $OUT .= "&letter=".$_GET['letter']."&sortby=".$_GET['sortby']."&page=".$page."&offset=".$offset."\">";
+
+ // Add status or mode
+ if (!empty($_GET['status'])) $OUT .= "&mode=".SQL_ESCAPE($_GET['status']);
+ elseif (!empty($_GET['mode'])) $OUT .= "&mode=".SQL_ESCAPE($_GET['mode']);
+
+ // Letter and so on
+ $OUT .= "&letter=".SQL_ESCAPE($_GET['letter'])."&sortby=".SQL_ESCAPE($_GET['sortby'])."&page=".$page."&offset=".$offset."\">";
}
+
$OUT .= $page;
- if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1")))
- {
+
+ if (($page == $_GET['page']) || ((empty($_GET['page'])) && ($page == "1"))) {
$OUT .= "-</STRONG>";
- }
- else
- {
+ } else {
$OUT .= "</A>";
}
+
if ($page < $PAGES) $OUT .= " | ";
- }
+ } // END - for
+
define('__PAGENAV_LIST', $OUT);
// Load template
$OUT = LOAD_TEMPLATE("admin_list_user_pagenav", true);
- if ($return)
- {
+ if ($return) {
// Return code
return $OUT;
- }
- else
- {
+ } else {
// Output code
OUTPUT_HTML($OUT);
}
}
+
// Create email link to user's account
-function USER_CREATE_EMAIL_LINK($email, $mod="admin")
-{
+function USER_CREATE_EMAIL_LINK($email, $mod="admin") {
+ // Show contact link only if user is confirmed by default
$locked = " AND status='CONFIRMED'";
+
+ // But admins shall always see it
if (IS_ADMIN()) $locked = "";
+
$result = SQL_QUERY_ESC("SELECT userid
FROM "._MYSQL_PREFIX."_user_data
WHERE email='%s'".$locked." LIMIT 1",
array($email), __FILE__, __LINE__);
- if (SQL_NUMROWS($result) == 1)
- {
+ if (SQL_NUMROWS($result) == 1) {
// Load userid
list($uid) = SQL_FETCHROW($result);
// Rewrite email address to contact link
$email = URL."/modules.php?module=".$mod."&what=user_contct&u_id=".bigintval($uid);
- }
+ } // END - if
// Free memory
SQL_FREERESULT($result);
// Return rewritten (?) email address
return $email;
}
-//
+
+// Selects a random user id as the new referal id if they have at least X confirmed mails in this run
+function SELECT_RANDOM_REFID () {
+ global $_CONFIG;
+
+ // Default is zero refid
+ $refid = 0;
+
+ // Is the extension version fine?
+ if (GET_EXT_VERSION("user") >= "0.3.4") {
+ // Get all user ids
+ $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true, " AND `rand_confirmed` >= ".getConfig('user_min_confirmed')."");
+
+ // Do we have at least one?
+ if ($totalUsers > 0) {
+ // Then choose random number
+ $randNum = mt_rand(0, ($totalUsers - 1));
+
+ // Look for random user
+ $result = SQL_QUERY_ESC("SELECT `userid` FROM `"._MYSQL_PREFIX."_user_data` WHERE `status`='CONFIRMED' AND `rand_confirmed` >= %s ORDER BY `rand_confirmed` DESC LIMIT %s, 1",
+ array(getConfig('user_min_confirmed'), $randNum), __FILE__, __LINE__);
+
+ // Do we have one entry there?
+ if (SQL_NUMROWS($result) == 1) {
+ // Use that userid as new referal id
+ list($refid) = SQL_FETCHROW($result);
+
+ // Reset this user's counter
+ SQL_QUERY_ESC("UPDATE `"._MYSQL_PREFIX."_user_data` SET `rand_confirmed`=0 WHERE userid=%s LIMIT 1",
+ array($refid), __FILE__, __LINE__);
+ } // END - if
+
+ // Free result
+ SQL_FREERESULT($result);
+ } // END - if
+ } // END - if
+
+ // Return result
+ return $refid;
+}
+
+// [EOF]
?>