forked from science-ation/science-ation
Quick fixes:
1) desk and outlet information no longer required when saving a project if they're not required in the config 2) Updated the project/save api to have consistent return value with other api functions
This commit is contained in:
parent
82746f754b
commit
d10d5f3835
2
api.php
2
api.php
@ -992,7 +992,7 @@ switch($request[0]) {
|
||||
if($message == 'success'){
|
||||
$ret['status'] = 'ok';
|
||||
//FIXME: this should getProject or something to reload whats actually in the database instead of just returning what they gave us
|
||||
$ret['project'] = $project;
|
||||
$ret['project'] = getProject($_SESSION['users_id']);
|
||||
}else{
|
||||
$ret['status'] = 'error';
|
||||
$ret['error'] = $message;
|
||||
|
@ -521,10 +521,16 @@ This section is for project/registration related functions **/
|
||||
|
||||
function saveProjectData($data){
|
||||
global $conference, $config;
|
||||
$requiredFields = array('project_id', 'summary', 'title', 'projectdivisions_id', 'language', 'req_table', 'req_electricity', 'summary');
|
||||
$requiredFields = array('project_id', 'summary', 'title', 'projectdivisions_id', 'language');
|
||||
if($config['participant_short_title_enable'] == 'yes'){
|
||||
$requiredFields[] = 'shorttitle';
|
||||
}
|
||||
if($config['participant_project_table'] == 'yes'){
|
||||
$requiredFields[] = 'req_table';
|
||||
}
|
||||
if($config['participant_project_electricity'] == 'yes'){
|
||||
$requiredFields[] = 'req_electricity';
|
||||
}
|
||||
$missingFields = array();
|
||||
foreach($requiredFields as $field){
|
||||
if(!array_key_exists($field, $data)){
|
||||
@ -735,6 +741,7 @@ function addProject($registrations_id){
|
||||
// perhaps a bit of a misnomer as it's actually the registration that's being joined, but meh.
|
||||
// return 'ok' on success, error message on failure
|
||||
function joinProject($registration_number, $email){
|
||||
global $config;
|
||||
$uid = $_SESSION['users_id'];
|
||||
if(getRegistrationsId($uid) !== null){
|
||||
return 'register_participants.inc.php::joinProject -> you are already registered for a project';
|
||||
@ -755,9 +762,15 @@ function joinProject($registration_number, $email){
|
||||
|
||||
$registration_id = $result['id'];
|
||||
|
||||
// let's see if this project already has the maximum number of students on it
|
||||
$ucount = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM users WHERE registrations_id = $registration_id"));
|
||||
if($ucount[0] >= $config['maxstudentsperproject']){
|
||||
return "register_participants.inc.php::joinProject -> the specified project already has the maxiumum number of students assigned to it";
|
||||
}
|
||||
|
||||
// ok, if we've made it this far, they've correctly added the info that we verify with. Go ahead
|
||||
// and add them to the registration
|
||||
$result = mysql_query("UPDATE users SET registrations_id = $registration_id WHERE id = $uid");
|
||||
mysql_query("UPDATE users SET registrations_id = $registration_id WHERE id = $uid");
|
||||
if(mysql_error()){
|
||||
return "register_participants.inc.php::joinProject -> " . mysql_error();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user