@@ -48,102 +48,108 @@ if (isset($session->groups[$permission])) {
$apiResult=curl_exec($apiReq);
if($apiResult===FALSE){
$mode='error';
$smarty->assign("error_text","An error occurred communicating with the SUSU API. Please try again later.");
$smarty->assign("error_text","An error occurred communicating with the SUSU API.");
}else{
// Ostensibly we now have a valid search result from the SU - go to work
$xml=newSimpleXMLElement($apiResult);
$ismember=$xml[0];
if($ismember=="true"){
//Yay, we have a student who has paid and needs to be signed up.
//Check they don't have a signup slip already
$query="SELECT transactionid, signupid FROM transactions WHERE cardNumber = ?;";
$qres=$sucsDB->Execute($query,$sid);
if($qres->RecordCount()==0){
// No transaction, but might have unused signup slip. If so, retrieve values.
$query="SELECT id, username, password FROM signup WHERE sid=?;";
$qres=$sucsDB->Execute($query,array($sid[0]));
if($qres&&$qres->RecordCount()>0){
if($qres->RecordCount()>1){
$mode='error';
$smarty->assign("error_text","Student has multiple signup slips in the DB. Bork! Bork! Bork!");
}elseif(!empty($qres->fields['username'])){
$mode='error';
$smarty->assign("error_text","Student hasn't tried to use the SU signup component (No transaction in DB), but has a previously used Signup Slip with username ".$qres->fields['username'].".<br />Is this a renewal? If not, ask an admin to generate a new signup slip for this student");
//TODO: Add option to generate new signup slip?
libxml_use_internal_errors(true);
$xml=simplexml_load_string($apiResult);
if(!$xml||isset($xml->head->title)){
$mode='error';
$smarty->assign("error_text","An error occurred communicating with the SUSU API");
}else{
$ismember=$xml[0];
if($ismember=="true"){
//Yay, we have a student who has paid and needs to be signed up.
//Check they don't have a signup slip already
$query="SELECT transactionid, signupid FROM transactions WHERE cardNumber = ?;";
$qres=$sucsDB->Execute($query,$sid);
if($qres->RecordCount()==0){
// No transaction, but might have unused signup slip. If so, retrieve values.
$query="SELECT id, username, password FROM signup WHERE sid=?;";
$qres=$sucsDB->Execute($query,array($sid[0]));
if($qres&&$qres->RecordCount()>0){
if($qres->RecordCount()>1){
$mode='error';
$smarty->assign("error_text","Student has multiple signup slips in the DB. Bork! Bork! Bork!");
}elseif(!empty($qres->fields['username'])){
$mode='error';
$smarty->assign("error_text","Student hasn't tried to use the SU signup component (No transaction in DB), but has a previously used Signup Slip with username ".$qres->fields['username'].".<br />Is this a renewal? If not, ask an admin to generate a new signup slip for this student");
$smarty->assign("error_text","An error occurred generating a signup ID. Report the following message to the admins:<br /><pre>".$sucsDB->ErrorMsg()."</pre>");
$smarty->assign("error_text","An error occurred generating a signup ID. Report the following message to the admins:<br /><pre>".$sucsDB->ErrorMsg()."</pre>");
$smarty->assign("error_text","An error occurred generating a signup ID. Report the following message to the admins:<br /><pre>".$sucsDB->ErrorMsg()."</pre>");
}else{
$id=$qres->fields['id'];
$query="UPDATE transactions SET signupid=? WHERE transactionid=?;";
$qres=$sucsDB->Execute($query,array($id,$tid));
$smarty->assign('slipid',$id);
$smarty->assign('slippass',$pass);
$smarty->assign('sid',$sid[0]);
}
$qres=$sucsDB->Execute($query,$attribs);
if(!$qres){
$mode="error";
$smarty->assign("error_text","An error occurred generating a signup ID. Report the following message to the admins:<br /><pre>".$sucsDB->ErrorMsg()."</pre>");
}else{
$id=$qres->fields['id'];
$query="UPDATE transactions SET signupid=? WHERE transactionid=?;";
$qres=$sucsDB->Execute($query,array($id,$tid));
}else{
$query="SELECT username, password FROM signup WHERE id=?;";
$qres=$sucsDB->Execute($query,array($id));
if(!$qres){
$mode="error";
$smarty->assign("error_text","The user appears to have generated a signup ID using the SU Signup system (Slip ID: ".$id."), but the password for that slip can't be retrieved.<br />Request assistance.");
}elseif($qres->fields['username']!==NULL){
$mode="error";
$smarth->assign("error_text","This user appears to have completed signup, with username <strong>".$qres->fields['username']."</strong><br />Check that this user exists, and offer to reset their password if necessary.");
}
$pass=$qres->fields['password'];
$smarty->assign('slipid',$id);
$smarty->assign('slippass',$pass);
$smarty->assign('sid',$sid[0]);
}
}
}else{
$query="SELECT username, password FROM signup WHERE id=?;";
$qres=$sucsDB->Execute($query,array($id));
if(!$qres){
$mode="error";
$smarty->assign("error_text","The user appears to have generated a signup ID using the SU Signup system (Slip ID: ".$id."), but the password for that slip can't be retrieved.<br />Request assistance.");
}elseif($qres->fields['username']!==NULL){
$mode="error";
$smarth->assign("error_text","This user appears to have completed signup, with username <strong>".$qres->fields['username']."</strong><br />Check that this user exists, and offer to reset their password if necessary.");
}
$pass=$qres->fields['password'];
if(!$mode=='error'){
//Right, this should be the point where we hand off to signup
$smarty->assign('slipid',$id);
$smarty->assign('slippass',$pass);
$smarty->assign('sid',$sid[0]);
}
}
if(!$mode=='error'){
//Right, this should be the point where we hand off to signup
$smarty->assign('slipid',$id);
$smarty->assign('slippass',$pass);
$smarty->assign('sid',$sid[0]);
}else{
$mode='error';
$smarty->assign("error_text","Student does not appear to have paid. Extract fees");
}
}else{
$mode='error';
$smarty->assign("error_text","Student does not appear to have paid. Extract fees");
}
}
}
...
...
@@ -173,27 +179,32 @@ if (isset($session->groups[$permission])) {
curl_setopt($apiReq,CURLOPT_RETURNTRANSFER,TRUE);
$apiResult=curl_exec($apiReq);
$xml=newSimpleXMLElement($apiResult);
$ismember=$xml[0];
$user=posix_getpwnam($session->username);
if($ismember!="true"){
libxml_use_internal_errors(true);
$xml=simplexml_load_string($apiResult);
if(!$xml||isset($xml->head->title)){
$mode='error';
$smarty->assign('error_text','Member does not appear to have paid via the SU system. Use the old renewals system if they have paid using some other method');;
$smarty->assign("error_text","An error occurred communicating with the SUSU API.");
$smarty->assign('error_text','Member does not appear to have paid via the SU system. Use the old renewals system if they have paid using some other method');;