Only allow betting if user is in a match
This commit is contained in:
@@ -20,7 +20,9 @@ $join_league = false;
|
||||
$matchnumber = 0;
|
||||
$userid = $user->data['user_id'];
|
||||
$lang_dates = $user->lang['datetime'];
|
||||
$league_info = league_info($season, $league);
|
||||
$user_is_member = user_is_member($userid, $season, $league);
|
||||
$user_is_allowed_to_bet = $league_info['bet_type'] ? true : user_is_allowed_to_bet($userid, $season, $league, $matchday);
|
||||
$display_rating = false;
|
||||
|
||||
// Calculate multiple delivery
|
||||
@@ -470,7 +472,6 @@ while ($row = $db->sql_fetchrow($result))
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$league_info = league_info($season, $league);
|
||||
$bet_explain = '';
|
||||
switch ($league_info['bet_ko_type'])
|
||||
{
|
||||
@@ -511,7 +512,7 @@ $template->assign_vars(array(
|
||||
'S_FORM_ACTION_BET' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday, 'action' => 'bet')),
|
||||
'S_FORM_ACTION_JOIN' => $this->helper->route('football_main_controller', array('side' => 'bet', 's' => $season, 'l' => $league, 'm' => $matchday, 'action' => 'join')),
|
||||
'S_USER_IS_MEMBER' => $user_is_member,
|
||||
'S_DATA_BET' => $data_bet,
|
||||
'S_DATA_BET' => $data_bet && $user_is_allowed_to_bet,
|
||||
'S_DATA_GROUP' => $data_group,
|
||||
'S_DATA_BET_RESULTS' => $data_bet_results,
|
||||
'S_EDIT_MODE' => $edit_mode,
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -246,7 +246,7 @@ $lang = array_merge($lang, array(
|
||||
'NO_MATCH' => 'Das von dir ausgewählte Spiel existiert nicht. ',
|
||||
'NO_MATCHDAY' => 'Der von dir ausgewählte Spieltag existiert nicht. ',
|
||||
'NO_MATCHES' => 'Keine Spiele vorhanden!',
|
||||
'NO_MATCHES_ON_MATCHDAY' => 'Der Spielplan wurde noch nicht erstellt. ',
|
||||
'NO_MATCHES_ON_MATCHDAY' => 'Der Spielplan wurde noch nicht erstellt oder du darfst diesen Spieltag nicht tippen. ',
|
||||
'NO_MATCHES_TEAM' => 'Dieses Team hat in dieser Saison noch keine Spiele bestritten. ',
|
||||
'NO_MEMBER' => 'Du bist kein Mitglied dieser Tipprunde!',
|
||||
'NO_MYBETS_ME' => 'Du bist kein Mitglied dieser Tipprunde!',
|
||||
|
||||
@@ -234,7 +234,7 @@ $lang = array_merge($lang, array(
|
||||
'NO_MATCH' => 'The match chosen by you does not exist. ',
|
||||
'NO_MATCHDAY' => 'The matchday chosen by you does not exist. ',
|
||||
'NO_MATCHES' => 'No matches available!',
|
||||
'NO_MATCHES_ON_MATCHDAY' => 'The fixture list was not created yet. ',
|
||||
'NO_MATCHES_ON_MATCHDAY' => 'The fixture list was not created yet or you are not allowed to bet this matchday. ',
|
||||
'NO_MATCHES_TEAM' => 'This team has not played any matches this season yet . ',
|
||||
'NO_MEMBER' => 'You are not a member of this Webtip!',
|
||||
'NO_MYBETS_ME' => 'You are not a member of this Webtip!',
|
||||
|
||||
Reference in New Issue
Block a user