Properly upload the project and update the reg email

This commit is contained in:
dave 2010-01-28 00:12:43 +00:00
parent c8087c54c3
commit 9f9f2053df

View File

@ -194,6 +194,7 @@ function award_upload_school(&$student, &$school, $year, &$response)
function award_upload_assign(&$fair, &$prize, &$project, $year, &$response) function award_upload_assign(&$fair, &$prize, &$project, $year, &$response)
{ {
$reg_email_needs_update = false;
/* Copied from admin/award_upload.php, this is the /* Copied from admin/award_upload.php, this is the
* transport name => sql name mapping */ * transport name => sql name mapping */
$student_fields = array('firstname'=>'firstname', $student_fields = array('firstname'=>'firstname',
@ -245,11 +246,12 @@ function award_upload_assign(&$fair, &$prize, &$project, $year, &$response)
'".mysql_real_escape_string($project['projectnumber'])."', '".mysql_real_escape_string($project['projectnumber'])."',
'$year', '{$fair['id']}');"); '$year', '{$fair['id']}');");
$pid = mysql_insert_id(); $pid = mysql_insert_id();
$reg_email_needs_update = true;
} }
/* Update the project in case anythign changed */ /* Update the project in case anythign changed */
mysql_query("UPDATE projects SET title='".mysql_real_escape_string($project['title'])."', mysql_query("UPDATE projects SET title='".mysql_real_escape_string($project['title'])."',
summary='".mysql_real_escape_string($project['abstract'])."' summary='".mysql_real_escape_string($project['abstract'])."',
projectcategories_id='".intval($project['projectcategories_id'])."' projectcategories_id='".intval($project['projectcategories_id'])."',
projectdivisions_id='".intval($project['projectdivisions_id'])."' projectdivisions_id='".intval($project['projectdivisions_id'])."'
WHERE id='$pid'"); WHERE id='$pid'");
@ -274,6 +276,13 @@ function award_upload_assign(&$fair, &$prize, &$project, $year, &$response)
/* Note lack of comma before $keys, we added it above for both keys and values */ /* Note lack of comma before $keys, we added it above for both keys and values */
mysql_query("INSERT INTO students (`registrations_id`,`fairs_id`, `schools_id`,`year` $keys) mysql_query("INSERT INTO students (`registrations_id`,`fairs_id`, `schools_id`,`year` $keys)
VALUES('$registrations_id','{$fair['id']}','$schools_id','$year' $values )"); VALUES('$registrations_id','{$fair['id']}','$schools_id','$year' $values )");
/* Update the registration email */
if($reg_email_needs_update) {
mysql_query("UPDATE registrations SET email='".mysql_real_escape_string($student['email'])."'
WHERE id='$registrations_id'");
$reg_email_needs_update = false;
}
} }
} }
@ -344,6 +353,7 @@ function handle_get_divisions(&$u, &$fair, &$data, &$response)
$div[$r->id] = array('division' => $r->division); $div[$r->id] = array('division' => $r->division);
} }
$response['divisions'] = $div; $response['divisions'] = $div;
$response['tmp'] = $data;
$response['error'] = 0; $response['error'] = 0;
} }