forked from science-ation/science-ation
add numstudents API to the project object
also add a unique constraint on the user_roles table (user_id,role_id)
This commit is contained in:
parent
7254d983d8
commit
cbfd66bb28
@ -1 +1 @@
|
||||
233
|
||||
234
|
||||
|
2
db/db.update.234.sql
Normal file
2
db/db.update.234.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE `registrations` ADD `numstudents` TINYINT( 4 ) NULL DEFAULT NULL AFTER `nummentors`;
|
||||
ALTER TABLE `user_roles` ADD UNIQUE ( `users_id` , `roles_id`);
|
@ -84,7 +84,17 @@ function studentsStatus($reg_id="") {
|
||||
if($reg_id) $rid=$reg_id;
|
||||
else $rid=$_SESSION['registration_id'];
|
||||
|
||||
$q=mysql_query("SELECT * FROM users WHERE registrations_id='$rid' AND conferences_id='".$conference['id']."'");
|
||||
//get the num students from the registrations table
|
||||
$q=mysql_query("SELECT numstudents FROM registrations WHERE id='$rid'");
|
||||
$r=mysql_fetch_object($q);
|
||||
$numstudents=$r->numstudents;
|
||||
|
||||
//select all the users currently with this registration id
|
||||
$q=mysql_query("SELECT id FROM users WHERE registrations_id='$rid' AND conferences_id='".$conference['id']."'");
|
||||
|
||||
//if we don't have what we said we were gonna have, return incomplete
|
||||
if($numstudents!=mysql_num_rows($q))
|
||||
return "incomplete";
|
||||
|
||||
//if we dont have the minimum, return incomplete
|
||||
if(mysql_num_rows($q)<$config['minstudentsperproject'])
|
||||
|
@ -375,6 +375,16 @@ function saveProjectData($data,$registrations_id=null){
|
||||
}
|
||||
}
|
||||
|
||||
//and update numstudents in registrations, yea, i know its not in the projects table
|
||||
if(isset($data['numstudents'])) {
|
||||
if($data['numstudents']==null) {
|
||||
mysql_query("UPDATE registrations SET numstudents=NULL WHERE id='{$rid}'");
|
||||
}
|
||||
else {
|
||||
mysql_query("UPDATE registrations SET numstudents='".intval($data['numstudents'])."' WHERE id='{$rid}'");
|
||||
}
|
||||
}
|
||||
|
||||
if($message == ''){
|
||||
$message = 'success';
|
||||
}
|
||||
@ -473,7 +483,7 @@ function getRegistrationsId($user){
|
||||
}
|
||||
function getRegistration($id) {
|
||||
global $conference;
|
||||
$q=mysql_query("SELECT id,num,start,status,end,nummentors FROM registrations WHERE id='$id' AND conferences_id='{$conference['id']}'");
|
||||
$q=mysql_query("SELECT id,num,start,status,end,nummentors,numstudents FROM registrations WHERE id='$id' AND conferences_id='{$conference['id']}'");
|
||||
$reg=mysql_fetch_assoc($q);
|
||||
if(!$reg) return null;
|
||||
|
||||
@ -493,7 +503,9 @@ function getRegistration($id) {
|
||||
//we'll also load it on getProejct, and save it on saveProjectData
|
||||
//even though its in the registrations table not the projects table
|
||||
$p['nummentors']=$reg['nummentors'];
|
||||
$p['numstudents']=$reg['numstudents'];
|
||||
unset($reg['nummentors']);
|
||||
unset($reg['numstudents']);
|
||||
|
||||
$reg['project']=$p;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user