diff --git a/api.php b/api.php
index 7254383b..bfc9523a 100644
--- a/api.php
+++ b/api.php
@@ -874,7 +874,6 @@ switch($request[0]) {
case 'add':
// be logged in as a student in order to create a project
$user = user_load($_SESSION['users_id']);
- $ret['userdat'] = $user;
if(!$user || !in_array('participant', $_SESSION['roles'])){
$ret['status'] = 'error';
$ret['error'] = "You must be logged in as a participant to create a project";
@@ -899,7 +898,7 @@ switch($request[0]) {
// if we got this far, then all's good and we can return the project data
$ret['status'] = 'ok';
- $ret['project'] = getProject($regId);
+ $ret['project'] = getProject($_SESSION['users_id']);
break;
/* APIDOC: project/view
@@ -908,7 +907,7 @@ switch($request[0]) {
*/
case 'view':
if($u=user_load($_SESSION['users_id'])) {
- $p=getProject(getRegistrationsId($_SESSION['users_id']));
+ $p=getProject($_SESSION['users_id']);
if(is_array($p)) {
$ret['status'] = 'ok';
$ret['project'] = $p;
diff --git a/register_participants.inc.php b/register_participants.inc.php
index cc8a865d..d88e1114 100644
--- a/register_participants.inc.php
+++ b/register_participants.inc.php
@@ -677,15 +677,32 @@ function getRegistrationsId($user){
return $result['registrations_id'];
}
-function getProject($registrations_id){
+function getProject($userId){
global $conference;
+
+ $userid = intval($userId);
+ $result = mysql_fetch_assoc(mysql_query("SELECT registrations_id FROM users WHERE id = $userId"));
+ if(!is_array($result)){
+ return "register_participants.inc.php::getProject -> User not found";
+ }
+ $regId = $result['registrations_id'];
// FIXME - in the future, this should be able to handle a many-to-many
// relationship in projects to registrations (so remove that LIMIT 1)
$fields = implode(',', array(
- 'id', 'projectdivisions_id', 'title', 'language', 'req_electricity',
- 'registrations_id', 'req_table', 'req_special', 'summary'
+ 'projects.id',
+ 'registrations.num',
+ 'projects.projectdivisions_id',
+ 'projects.title',
+ 'projects.language',
+ 'projects.req_electricity',
+ 'projects.registrations_id',
+ 'projects.req_table',
+ 'projects.req_special',
+ 'projects.summary'
));
- $q = mysql_query("SELECT $fields FROM projects WHERE registrations_id='$registrations_id' AND conferences_id='".$conference['id']."' LIMIT 1");
+ $q = mysql_query("SELECT $fields FROM projects
+ JOIN registrations ON registrations.id = projects.registrations_id
+ WHERE projects.registrations_id='$regId' AND projects.conferences_id='".$conference['id']."' LIMIT 1");
if(mysql_error()) {
$returnval = "register_participants.inc.php::getProject -> " . $returnval;
}else{
diff --git a/testapi.php b/testapi.php
index 080f2323..4fd13a33 100644
--- a/testapi.php
+++ b/testapi.php
@@ -107,6 +107,8 @@ email address: