]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/user_functions.php
Admin user details extended, DEBUG_LOG() rewritten, random userid on refid=0 added
[mailer.git] / inc / libs / user_functions.php
index 115bec72f7a4c7f858e289a8153e8dc7698eb2f8..75cf35e9972a3bfa42064ed2895e5c0b9b651523 100644 (file)
@@ -37,6 +37,7 @@ if (!defined('__SECURITY')) {
        require($INC);
 }
 
+// Add links for selecting some users
 function alpha($sortby, $colspan, $return=false)
 {
        global $_CONFIG;
@@ -86,7 +87,8 @@ function alpha($sortby, $colspan, $return=false)
                OUTPUT_HTML($OUT);
        }
 }
-//
+
+// Add links for sorting
 function SortLinks($letter, $sortby, $colspan, $return=false)
 {
        $OUT = "";
@@ -132,7 +134,8 @@ function SortLinks($letter, $sortby, $colspan, $return=false)
                OUTPUT_HTML($OUT);
        }
 }
-//
+
+// Add page navigation
 function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false)
 {
        if (!$show_form)
@@ -197,6 +200,7 @@ function ADD_PAGENAV($PAGES, $offset, $show_form, $colspan,$return=false)
                OUTPUT_HTML($OUT);
        }
 }
+
 // Create email link to user's account
 function USER_CREATE_EMAIL_LINK($email, $mod="admin")
 {
@@ -221,5 +225,42 @@ WHERE email='%s'".$locked." LIMIT 1",
        // 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` >= ".$_CONFIG['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($_CONFIG['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);
+                       } // END - if
+
+                       // Free result
+                       SQL_FREERESULT($result);
+               } // END - if
+       } // END - if
+
+       // Return result
+       return $refid;
+}
+
+// [EOF]
 ?>