Properly handle award id = -1 for "i dont want special awards"

This commit is contained in:
james 2011-03-04 16:15:10 +00:00
parent c0299dc870
commit a28ab561eb

View File

@ -352,16 +352,32 @@ function saveProjectData($data,$registrations_id=null){
} }
mysql_query("DELETE FROM project_specialawards_link WHERE projects_id='{$data['project_id']}' AND conferences_id='{$conference['id']}'"); mysql_query("DELETE FROM project_specialawards_link WHERE projects_id='{$data['project_id']}' AND conferences_id='{$conference['id']}'");
$idx=0; //now filter the list we've been given, to make sure everything's hunky dory
$awards=array();
foreach($data['specialawards'] AS $sa) { foreach($data['specialawards'] AS $sa) {
if($sa['selected'] && in_array($sa['id'],$eligibleAwardsList)) { //If all they've selected is they don't want to self nominate, then erase all other selections
$qstr="INSERT INTO project_specialawards_link (award_awards_id,projects_id,conferences_id) VALUES ('".intval($sa['id'])."','".intval($data['project_id'])."','{$conference['id']}')"; if($sa['id']==-1) {
mysql_query($qstr); //reset the array
$idx++; unset($awards);
//dont let them sign up for more than they are allowed to $awards=array();
if($idx>=$config['maxspecialawardsperproject']) $awards[]=$sa;
break; break;
} }
else {
if($sa['selected'] && in_array($sa['id'],$eligibleAwardsList)) {
$awards[]=$sa;
}
}
}
$idx=0;
foreach($awards AS $sa) {
$qstr="INSERT INTO project_specialawards_link (award_awards_id,projects_id,conferences_id) VALUES ('".intval($sa['id'])."','".intval($data['project_id'])."','{$conference['id']}')";
mysql_query($qstr);
$idx++;
//dont let them sign up for more than they are allowed to
if($idx>=$config['maxspecialawardsperproject'])
break;
} }
} }