forked from science-ation/science-ation
Set prize external_identifier on award download properly. Send proper xml array (prizes[0]prize[0], not prizes[0]prizes[0]) to ysc servers. Handle postback url properly (typo)
This commit is contained in:
parent
7cd9f21434
commit
80ff166203
@ -193,6 +193,8 @@ case 'check':
|
|||||||
unset($existingprizes[$ep['prize']]);
|
unset($existingprizes[$ep['prize']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!array_key_exists('identifier', $prize)) $prize['identifier'] = $prize['prize_en'];
|
||||||
|
|
||||||
mysql_query("UPDATE award_prizes SET
|
mysql_query("UPDATE award_prizes SET
|
||||||
cash='".intval($prize['cash'])."',
|
cash='".intval($prize['cash'])."',
|
||||||
scholarship='".intval($prize['scholarship'])."',
|
scholarship='".intval($prize['scholarship'])."',
|
||||||
@ -200,6 +202,7 @@ case 'check':
|
|||||||
prize='".mysql_escape_string($prize['prize_en'])."',
|
prize='".mysql_escape_string($prize['prize_en'])."',
|
||||||
number='".intval($prize['number'])."',
|
number='".intval($prize['number'])."',
|
||||||
`order`='".intval($prize['ord'])."',
|
`order`='".intval($prize['ord'])."',
|
||||||
|
external_identifier='".mysql_real_escape_string(stripslashes($prize['identifier']))."',
|
||||||
trophystudentkeeper='".intval($prize['trophystudentkeeper'])."',
|
trophystudentkeeper='".intval($prize['trophystudentkeeper'])."',
|
||||||
trophystudentreturn='".intval($prize['trophystudentreturn'])."',
|
trophystudentreturn='".intval($prize['trophystudentreturn'])."',
|
||||||
trophyschoolkeeper='".intval($prize['trophyschoolkeeper '])."',
|
trophyschoolkeeper='".intval($prize['trophyschoolkeeper '])."',
|
||||||
|
@ -83,7 +83,7 @@ function get_winners($awardid)
|
|||||||
$winners=array( 'prizes' => array(),
|
$winners=array( 'prizes' => array(),
|
||||||
'award_name' => $award['name'],
|
'award_name' => $award['name'],
|
||||||
'external_identifier' => $award['external_identifier'],
|
'external_identifier' => $award['external_identifier'],
|
||||||
'postback' => $award['external_postback']);
|
'external_postback' => $award['external_postback']);
|
||||||
|
|
||||||
/* Get the prizes */
|
/* Get the prizes */
|
||||||
$q=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='{$award['id']}'");
|
$q=mysql_query("SELECT * FROM award_prizes WHERE award_awards_id='{$award['id']}'");
|
||||||
@ -139,7 +139,7 @@ function get_winners($awardid)
|
|||||||
/* Save the prize info => projects */
|
/* Save the prize info => projects */
|
||||||
$winners['prizes'][$prize['prize']] = array(
|
$winners['prizes'][$prize['prize']] = array(
|
||||||
'xml_type'=>'prize', /* For ysc compatability */
|
'xml_type'=>'prize', /* For ysc compatability */
|
||||||
'identifier'=>$prize['prize'], /* for ysc compatability */
|
'identifier'=>$prize['external_identifier'], /* for ysc compatability */
|
||||||
'projects'=>$prizewinners);
|
'projects'=>$prizewinners);
|
||||||
}
|
}
|
||||||
return $winners;
|
return $winners;
|
||||||
@ -161,11 +161,15 @@ case 'award_upload':
|
|||||||
echo notice(i18n('No winners selected for this award'));
|
echo notice(i18n('No winners selected for this award'));
|
||||||
} else {
|
} else {
|
||||||
if($fair['type'] == 'ysc') {
|
if($fair['type'] == 'ysc') {
|
||||||
|
$w = array();
|
||||||
|
foreach($winners['prizes'] as $prize_name=>$prize) {
|
||||||
|
$w[] = $prize;
|
||||||
|
}
|
||||||
$req=array("awardwinners"=>array(
|
$req=array("awardwinners"=>array(
|
||||||
"username"=>$fair['username'],
|
"username"=>$fair['username'],
|
||||||
"password"=>$fair['password'],
|
"password"=>$fair['password'],
|
||||||
"identifier"=>$winners['external_identifier'],
|
"identifier"=>$winners['external_identifier'],
|
||||||
"prizes"=>$winners,
|
"prizes"=>$w,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$url = $winners['external_postback'];
|
$url = $winners['external_postback'];
|
||||||
@ -181,9 +185,14 @@ case 'award_upload':
|
|||||||
$data = curl_query($fair, $req, $url);
|
$data = curl_query($fair, $req, $url);
|
||||||
|
|
||||||
if($data['error'] != 0) {
|
if($data['error'] != 0) {
|
||||||
echo error("Server said: $data");
|
echo error("Server said: ".htmlspecialchars(print_r($data,true)));
|
||||||
} else {
|
} else {
|
||||||
|
if(is_array($data['notice']))
|
||||||
echo notice("{$fair['name']} server said: <pre>".join("\n", $data['notice'])."</pre>");
|
echo notice("{$fair['name']} server said: <pre>".join("\n", $data['notice'])."</pre>");
|
||||||
|
else if(is_array($data['message']))
|
||||||
|
echo notice("{$fair['name']} server said: <pre>".join("\n", $data['message'])."</pre>");
|
||||||
|
else
|
||||||
|
echo notice("{$fair['name']} server said: <pre>".htmlspecialchars(print_r($data,true))."</pre>");
|
||||||
echo happy(i18n("Upload completed successfully"));
|
echo happy(i18n("Upload completed successfully"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// debug_("Curl Send: (type:{$fair['type']}=>$url) $str");
|
// debug_("Curl Send: (type:{$fair['type']}=>$url ysc_url=>$ysc_url) $str");
|
||||||
|
|
||||||
$ch = curl_init(); /// initialize a cURL session
|
$ch = curl_init(); /// initialize a cURL session
|
||||||
curl_setopt ($ch, CURLOPT_URL, $url);
|
curl_setopt ($ch, CURLOPT_URL, $url);
|
||||||
|
Loading…
Reference in New Issue
Block a user