forked from science-ation/science-ation
Update the sponsor if it changes for an existing award
Dont check year on the sponsors table
This commit is contained in:
parent
0f198346aa
commit
c7a3628f4a
@ -88,7 +88,20 @@
|
||||
$tq=mysql_query("SELECT * FROM award_awards WHERE external_identifier='$identifier' AND year='$year'");
|
||||
if($awardrecord=mysql_fetch_object($tq)) {
|
||||
echo i18n("Award already exists, updating info")."<br />";
|
||||
|
||||
//check if the sponsor exists, if not, add them
|
||||
$sponsorq=mysql_query("SELECT * FROM award_sponsors WHERE organization='".mysql_escape_string($award['sponsor'][0])."'");
|
||||
if($sponsorr=mysql_fetch_object($sponsorq)) {
|
||||
$sponsor_id=$sponsorr->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql_query("INSERT INTO award_sponsors (organization,year,notes,confirmed) VALUES ('".mysql_escape_string($award['sponsor'][0])."','$year','".mysql_escape_string("Imported from external source: $r->name")."','yes')");
|
||||
$sponsor_id=mysql_insert_id();
|
||||
}
|
||||
|
||||
mysql_query("UPDATE award_awards SET
|
||||
award_sponsors_id='$sponsor_id',
|
||||
name='".mysql_escape_string($award['name_en'][0])."',
|
||||
criteria='".mysql_escape_string($award['criteria_en'][0])."',
|
||||
postback='".mysql_escape_string($postback)."'
|
||||
@ -97,13 +110,15 @@
|
||||
AND external_identifier='".mysql_escape_string($identifier)."'
|
||||
AND year='$year'
|
||||
");
|
||||
//FIXME: update the prizes
|
||||
|
||||
//update the prizes
|
||||
if(is_array($award['prizes'][0]) && count($award['prizes'][0]['prize']>0))
|
||||
{
|
||||
$prizes=$award['prizes'][0]['prize'];
|
||||
$numprizes=count($prizes);
|
||||
echo i18n("Number of prizes: %1",array($numprizes))."<br />";
|
||||
$pq=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='$awardrecord->id'");
|
||||
//get a list of all the existing prizes
|
||||
$existingprizes=array();
|
||||
while($pr=mysql_fetch_object($pq)) {
|
||||
$existingprizes[$pr->external_identifier]=$pr;
|
||||
@ -165,7 +180,7 @@
|
||||
}
|
||||
else {
|
||||
//check if the sponsor exists, if not, add them
|
||||
$sponsorq=mysql_query("SELECT * FROM award_sponsors WHERE organization='".mysql_escape_string($award['sponsor'][0])."' AND year='$year'");
|
||||
$sponsorq=mysql_query("SELECT * FROM award_sponsors WHERE organization='".mysql_escape_string($award['sponsor'][0])."'");
|
||||
if($sponsorr=mysql_fetch_object($sponsorq)) {
|
||||
$sponsor_id=$sponsorr->id;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user