Only allow betting if user is in a match

This commit is contained in:
2022-08-12 20:07:38 +02:00
parent 41397ffbdc
commit 76cedb15a2
4 changed files with 31 additions and 4 deletions

View File

@@ -741,6 +741,32 @@ function user_is_member($userid, $season, $league)
$db->sql_freeresult($result);
}
/**
* Is user allowed to bet this matchday
*/
function user_is_allowed_to_bet($userid, $season, $league, $matchday)
{
global $db;
$sql = 'SELECT COUNT(*) AS counter
FROM ' . FOOTB_MATCHES . "
WHERE season = $season
AND league = $league + 50
AND matchday = $matchday
AND (team_id_home = $userid + 2000 OR team_id_guest = $userid + 2000)";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
if ($row['counter'] > 0)
{
return true;
}
else
{
return false;
}
$db->sql_freeresult($result);
}
/**
* Count existing matches on matchday or league
*/