return $ret;
}
-// Remove a receiver's ID from $ARRAY and add a link for him to confirm
-function REMOVE_RECEIVER (&$ARRAY, $key, $uid, $pool_id, $stats_id="", $bonus=false) {
+// Remove a receiver's ID from $receivers and add a link for him to confirm
+function REMOVE_RECEIVER (&$receivers, $key, $uid, $pool_id, $stats_id="", $bonus=false) {
+ // Default is not removed
$ret = "failed";
+
+ // Is the userid valid?
if ($uid > 0) {
// Remove entry from array
- unset($ARRAY[$key]);
+ unset($receivers[$key]);
// Is there already a line for this user available?
if ($stats_id > 0) {
// Only when we got a real stats ID continue searching for the entry
$type = "NORMAL"; $rowName = "stats_id";
if ($bonus) { $type = "BONUS"; $rowName = "bonus_id"; }
+
+ // Try to look the entry up
$result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_links` WHERE %s='%s' AND userid=%s AND link_type='%s' LIMIT 1",
array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
+
+ // Was it *not* found?
if (SQL_NUMROWS($result) == 0) {
- // No, so we add one!
+ // So we add one!
SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_links` (%s, userid, link_type) VALUES ('%s','%s','%s')",
array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
$ret = "done";