diff --git a/api.php b/api.php index bfc9523..9ed2709 100644 --- a/api.php +++ b/api.php @@ -966,20 +966,17 @@ switch($request[0]) { break; /* APIDOC: project/remove - post(registration_number integer) + post(registrations_id integer) description(remove the current user from an existing project. If no other users are in the project, then it is deleted.) */ case 'remove': - $ret['status'] = "error"; - $ret['error'] = $_GET['request'] . " functionality not yet implemented"; - /* - if(!array_key_exists('registration_number', $_POST)){ + if(!array_key_exists('registrations_id', $_POST)){ $ret['status'] = 'error'; - $ret['error'] = 'registration_number (integer) is required'; + $ret['error'] = 'registrations_id (integer) is required'; break; } - $result = removeProject($_POST['registration_number']); + $result = removeProject($_POST['registrations_id']); if($result != 'ok'){ $ret['status'] = "error"; $ret['error'] = $result; @@ -987,7 +984,6 @@ switch($request[0]) { } $ret['status'] = 'ok'; - */ break; case 'mentor': diff --git a/register_participants.inc.php b/register_participants.inc.php index d88e111..0ff7469 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -764,31 +764,52 @@ function joinProject($registration_number, $email){ // disassociate the active user from the specified project registration. If the registration no longer // has any users connected to it, delete it, and any projects tied to it -/* -function removeProject($registration_id){ +function removeProject($registrations_id){ // make sure this user is indeed connected to the specified project $uid = $_SESSION['users_id']; $regId = getRegistrationsId($uid); - $registration_number = intval($registration_number); - if($regId != $registration_number){ + $registrations_id = intval($registrations_id); + if($regId != $registrations_id){ return 'register_participants.inc.php::removeProject -> you are not connected to that project'; } - mysql_query("UPDATE users SET registrations_id = null WHERE ud = $uid"); + mysql_query("UPDATE users SET registrations_id = null WHERE id = $uid"); if(mysql_error()){ return "register_participants.inc.php::removeProject -> " . mysql_error(); } // now let's see if anyone else is connected to that registration - $q = mysql_query("SELECT COUNT(*) AS tally FROM users WHERE registrations_id = $registration_number"); + $q = mysql_query("SELECT COUNT(*) AS tally FROM users WHERE registrations_id = $registrations_id"); $result = mysql_fetch_assoc($q); if($result['tally'] == 0){ //nobody wants the poor lonely registration. Let's put it out of it's misery - mysql_query("DELETE FROM registrations WHERE num = $registration_number"); - mysql_query("DELETE FROM projects WHERE registrations_id + + mysql_query("DELETE FROM registrations WHERE id = $registrations_id"); + if(mysql_error()){ + return "register_participants.inc.php::removeProject -> " . mysql_error(); + } + + $projIds = array(); + $q = mysql_query("SELECT id FROM projects WHERE registrations_id = $registrations_id"); + while($row = mysql_fetch_assoc($q)){ + $projIds[] = $row['id']; + } + if(count($projIds) > 0){ + mysql_query("DELETE FROM project_specialawards_link + WHERE projects_id IN(" . implode('.', $projIds) . ")"); + if(mysql_error()){ + return "register_participants.inc.php::removeProject -> " . mysql_error(); + } + } + + mysql_query("DELETE FROM projects WHERE registrations_id = $registrations_id"); + if(mysql_error()){ + return "register_participants.inc.php::removeProject -> " . mysql_error(); + } + } return 'ok'; } -*/ + ?> diff --git a/testapi.php b/testapi.php index 4fd13a3..c4ffe31 100644 --- a/testapi.php +++ b/testapi.php @@ -63,6 +63,7 @@ include "common.inc.php"; API Documentation
Registration Group/Fields Dictionary Documentation
+

General Commands

Login @@ -90,6 +91,7 @@ Date List +

Account Settings

Edit account information
Username:
@@ -106,16 +108,26 @@ email address:
+

Project related commands

+

Start a new project

start a new project
+

Join a project


-
+
+

Leave a project

+
+
+ +
+ +

Teacher Specific Commands

Science Olympic Teams List
@@ -135,6 +147,7 @@ email address:
+

User Stuff

View the user
@@ -160,8 +173,7 @@ role id:
- - +

Event Schedule

Schedule Listing
@@ -181,6 +193,7 @@ Schedule ID: +

Roles

Get a list of roles for this conference
@@ -199,6 +212,7 @@ Remove a role from this account +

Registration Fields

View the dictionary of registration fields   View Documentation Generated by this API call
@@ -212,6 +226,7 @@ foreach($roles AS $role=>$r) { +

Schools

School Listing
@@ -222,6 +237,7 @@ foreach($roles AS $role=>$r) { +

Session Variables