diff --git a/admin/judges_teams.php b/admin/judges_teams.php index 00e6ffa7..8b5cd385 100644 --- a/admin/judges_teams.php +++ b/admin/judges_teams.php @@ -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")