forked from science-ation/science-ation
Added code preventing users from creating more than one registration/project
This commit is contained in:
parent
3c0151263f
commit
340a45127b
1
api.php
1
api.php
@ -875,6 +875,7 @@ switch($request[0]) {
|
|||||||
case 'add':
|
case 'add':
|
||||||
// be logged in as a student in order to create a project
|
// be logged in as a student in order to create a project
|
||||||
$user = user_load($_SESSION['users_id']);
|
$user = user_load($_SESSION['users_id']);
|
||||||
|
$ret['userdat'] = $user;
|
||||||
if(!$user || !in_array('participant', $_SESSION['roles'])){
|
if(!$user || !in_array('participant', $_SESSION['roles'])){
|
||||||
$ret['status'] = 'error';
|
$ret['status'] = 'error';
|
||||||
$ret['error'] = "You must be logged in as a participant to create a project";
|
$ret['error'] = "You must be logged in as a participant to create a project";
|
||||||
|
@ -605,13 +605,26 @@ function getNewRegNum(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add a registration record and return it's unique "num" id
|
// add a registration record and return it's unique "num" id
|
||||||
//FIXME - this should probably do a check to see if the user
|
// returns an error message if the user is alredy registered
|
||||||
// was connected to another project already, and either:
|
|
||||||
// a) check to see if anyone else is connected to it, and delete it if not
|
|
||||||
// b) don't let them create a new one without explicitly disassociating with the other
|
|
||||||
function addRegistration($userId){
|
function addRegistration($userId){
|
||||||
global $conference;
|
global $conference;
|
||||||
|
|
||||||
|
// first we make sure that they don't already have a project on the go
|
||||||
|
$query = mysql_query("SELECT * FROM users WHERE id = $userId");
|
||||||
|
$err = mysql_error();
|
||||||
|
if($err){
|
||||||
|
return "register_participants.inc.php::addRegistration -> " . $err;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = mysql_fetch_assoc($query);
|
||||||
|
if(!$row){
|
||||||
|
return "register_participants.inc.php::addRegistration -> user not found";
|
||||||
|
}
|
||||||
|
|
||||||
|
if($row['registrations_id'] != null){
|
||||||
|
return "register_participants.inc.php::addRegistration -> user already has a project registered";
|
||||||
|
}
|
||||||
|
|
||||||
// create the new registration record, and assign a random/unique registration number.
|
// create the new registration record, and assign a random/unique registration number.
|
||||||
$regnum = getNewRegNum();
|
$regnum = getNewRegNum();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user