automatically assign a new team captain if the current team captain is removed from the team

This commit is contained in:
james 2005-04-15 14:50:18 +00:00
parent 3f471bde41
commit ab424f244f

View File

@ -147,9 +147,33 @@ function switchjudgeinfo()
mysql_query("DELETE FROM judges_teams WHERE year='".$config['FAIRYEAR']."' AND id='".$_POST['team_id']."'");
echo notice(i18n("Removed empty team #%1 (%2)",array($_POST['team_num'],$_POST['team_name'])));
}
else
{
//make sure the team still has a captain!
//FIXME: this might best come from the "i am willing to be a team captain" question under the judges profile
$gotcaptain=false;
$first=true;
while($r=mysql_fetch_object($q))
{
if($first)
{
$firstjudge=$r->judges_id;
$first=false;
}
if($r->captain=="yes")
{
$gotcaptain=true;
break;
}
}
if(!$gotcaptain)
{
//make the first judge the captain
mysql_query("UPDATE judges_teams_link SET captain='yes' WHERE judges_teams_id='".$_POST['team_id']."' AND judges_id='$firstjudge' AND year='".$config['FAIRYEAR']."'");
echo notice(i18n("Team captain was removed. A new team captain has been automatically assigned"));
}
}
}
if($_POST['action']=="saveteamnames")