Add APIDOC for the rest of the existing api

This commit is contained in:
james 2010-09-27 20:45:57 +00:00
parent 08340544d9
commit 0f9588cdf4

24
api.php
View File

@ -230,6 +230,10 @@ switch($request[0]) {
switch($request[1]) {
case "teams":
switch($request[2]) {
/* APIDOC: scienceolympics/teams/list
description(lists the schools science olympics teams)
return(teams array)
*/
case "list":
$q=mysql_query("SELECT id,name FROM so_teams WHERE schools_id='{$u['schools_id']}' AND conferences_id='{$conference['id']}'");
$ret['status']='ok';
@ -239,9 +243,15 @@ switch($request[0]) {
}
$ret['teams']=$teams;
break;
/* APIDOC: scienceolympics/teams/add
description(add a science olympics team to the logged in teacher's school)
post(teamname varchar(64))
return(team array);
*/
case "add":
if($_POST['teamname']) {
if(so_team_add($school_id,$conference['id'],$_POST['teamname'])) {
if($team=so_team_add($school_id,$conference['id'],$_POST['teamname'])) {
$ret['team']=$team;
$ret['status']="ok";
}
else {
@ -253,10 +263,16 @@ switch($request[0]) {
$ret['error']='teamname (varchar 64) is required';
}
break;
/* APIDOC: scienceolympics/teams/edit
description(edit a science olympics team)
post(id integer, teamname varchar(64))
return(team array);
*/
case "edit":
if($_POST['id'] && $_POST['teamname']) {
if(so_team_edit($school_id,$_POST['id'],$_POST['teamname'])) {
if($team=so_team_edit($school_id,$_POST['id'],$_POST['teamname'])) {
$ret['status']="ok";
$ret['team']=$team;
}
else {
$ret['status']='error';
@ -268,6 +284,10 @@ switch($request[0]) {
$ret['error']='id (integer), teamname (varchar 64) are required';
}
break;
/* APIDOC: scienceolympics/teams/delete
description(delete a science olympics team)
post(id integer)
*/
case "delete";
if($_POST['id']) {
if(so_team_delete($school_id,$_POST['id'])) {