Oops move registration into the righ tsection

This commit is contained in:
james 2011-03-02 23:56:13 +00:00
parent 9ff6a1cf58
commit 648e1bb031

122
api.php
View File

@ -877,6 +877,71 @@ switch($request[0]) {
}
break;
/* APIDOC: registration/view
description(registration information about the currently logged in users registration)
object(registration: {id,num,status,end,nummentors,students array of student,status array)
object(student: {id,accounts_id,username,firstname,lastname,complete)
return(registration array)
*/
case 'view':
$chk=api_user_auth_required('participant');
if($chk['status']!="ok") {
$ret['status']="error";
$ret['error']=$chk['error'];
break;
}
if(!$_SESSION['registrations_id']) {
$ret['status']="error";
$ret['error']="No registration has been created or joined yet";
break;
}
// be logged in as a student in order to create a project
$r=getRegistration($_SESSION['registrations_id']);
if($r) {
$ret['status']="ok";
$ret['registration']=$r;
}
else {
$ret['status'] = 'error';
$ret['error']="Invalid registration id";
}
break;
default:
/* APIDOC: registration/edit
description(update registration information. Updatable data: nummentors)
post(registration array)
return(registration array)
*/
case 'edit':
$chk=api_user_auth_required('participant');
if($chk['status']!="ok") {
$ret['status']="error";
$ret['error']=$chk['error'];
break;
}
if(!$_SESSION['registrations_id']) {
$ret['status']="error";
$ret['error']="No registration has been created or joined yet";
break;
}
// be logged in as a student in order to create a project
$r=json_decode($_POST['registration'],true);
if(is_array($r)) {
$ret['status']='ok';
$newreg=saveRegistrationData($r);
$ret['registration']=$newreg;
} else {
$ret['status']='error';
$ret['error']="registration array required";
}
break;
default:
$ret['status']="error";
$ret['error']="invalid registration API command ({$request[1]})";
@ -900,63 +965,6 @@ switch($request[0]) {
}
break;
case 'registration':
$chk=api_user_auth_required('participant');
if($chk['status']!="ok") {
$ret['status']="error";
$ret['error']=$chk['error'];
break;
}
if(!$_SESSION['registrations_id']) {
$ret['status']="error";
$ret['error']="No registration has been created or joined yet";
break;
}
switch($request[1]){
/* APIDOC: registration/view
description(registration information about the currently logged in users registration)
object(registration: {id,num,status,end,nummentors,students array of student,status array)
object(student: {id,accounts_id,username,firstname,lastname,complete)
return(registration array)
*/
case 'view':
// be logged in as a student in order to create a project
$r=getRegistration($_SESSION['registrations_id']);
if($r) {
$ret['status']="ok";
$ret['registration']=$r;
}
else {
$ret['status'] = 'error';
$ret['error']="Invalid registration id";
}
break;
default:
/* APIDOC: registration/edit
description(update registration information. Updatable data: nummentors)
post(registration array)
return(registration array)
*/
case 'edit':
// be logged in as a student in order to create a project
$r=json_decode($_POST['registration'],true);
if(is_array($r)) {
$ret['status']='ok';
$newreg=saveRegistrationData($r);
$ret['registration']=$newreg;
} else {
$ret['status']='error';
$ret['error']="registration array required";
}
break;
}
break;
case 'project':
$chk=api_user_auth_required('participant');
if($chk['status']!="ok") {