Oops - removed debug output from the project/new api.

Updated getProject to take userId as a parameter, rather than the registration number.
This commit is contained in:
jacob 2011-02-18 20:48:56 +00:00
parent 40e139b7a1
commit f785a71be2
3 changed files with 25 additions and 7 deletions

@ -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;

@ -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{

@ -107,6 +107,8 @@ email address: <input type="text" name="email"></input><br/>
</form>
<h2>Project related commands</h2>
<h3>Start a new project</h3>
<a href="api/project/add">start a new project</a><br/>
<h3>Join a project</h3>
<form method = "post" action = "api/project/join">
<label>project e-mail address:<input type="text" name="email"></input></label><br/>