forked from science-ation/science-ation
Update to user_load to ensure that the roles statuses are directly checked upon loading the user.
This commit is contained in:
parent
86ab58acac
commit
e538262cc6
9
api.php
9
api.php
@ -367,16 +367,13 @@ switch($request[0]) {
|
||||
$_SESSION['email']=$a['email'];
|
||||
$_SESSION['accounts_id']=$accounts_id;
|
||||
$_SESSION['superuser'] = ($a['superuser'] == 'yes') ? 'yes' : 'no';
|
||||
$_SESSION['roles']=array();
|
||||
|
||||
if(!$cid) $cid=$_SESSION['conferences_id'];
|
||||
$u = user_load(null, $accounts_id);
|
||||
|
||||
if(is_array($u)){
|
||||
$_SESSION['users_id'] = $u['id'];
|
||||
foreach($u['roles'] as $role){
|
||||
$_SESSION['roles'][] = $role;
|
||||
}
|
||||
$_SESSION['roles'] = $u['roles'];
|
||||
$p = getProject($u['id']);
|
||||
if(is_array($p)) {
|
||||
$_SESSION['registration_id'] = $p['registrations_id'];
|
||||
@ -385,8 +382,10 @@ switch($request[0]) {
|
||||
$_SESSION['error'] = "project not found";
|
||||
|
||||
}
|
||||
else
|
||||
else{
|
||||
$_SESSION['roles']=array();
|
||||
$_SESSION['error'] = "user not found";
|
||||
}
|
||||
|
||||
$ret['conferences_id']=$cid;
|
||||
$ret['status']="ok";
|
||||
|
@ -305,7 +305,6 @@ function namecheckStatus($reg_id="")
|
||||
global $conference;
|
||||
if($reg_id) $rid=$reg_id;
|
||||
else $rid=$_SESSION['registration_id'];
|
||||
|
||||
$q = mysql_query("SELECT namecheck_complete FROM users WHERE registrations_id = $rid AND conferences_id = '{$conference['id']}'");
|
||||
|
||||
while($s=mysql_fetch_object($q)) {
|
||||
@ -317,7 +316,8 @@ function namecheckStatus($reg_id="")
|
||||
}
|
||||
|
||||
function participant_status_completion_details($u){
|
||||
$regId = $u['registrations_id'];
|
||||
$p = getProject($u['id']);
|
||||
$regId = $p['registrations_id'];
|
||||
return array(
|
||||
'namecheck' => namecheckStatus($regId),
|
||||
'tour' => tourStatus($regId),
|
||||
|
14
user.inc.php
14
user.inc.php
@ -86,13 +86,6 @@ function user_load($users_id, $accounts_id = false)
|
||||
$u['roles'][$roledata['type']] = $roledata;
|
||||
}
|
||||
|
||||
if(count($u['roles']) == 0) {
|
||||
/* No roles, that's ok actually, the previous logic here was that
|
||||
* a user without roles is deleted.. but.. this could happen for
|
||||
* new users, or if someone deletes all their roles before adding
|
||||
* a new role */
|
||||
}
|
||||
|
||||
// not sure if this is the best place to add it, but if the user is a student, add their emergency contacts
|
||||
if(array_key_exists('participant', $u['roles'])){
|
||||
$u['emergencycontacts'] = array();
|
||||
@ -276,6 +269,13 @@ function user_load($users_id, $accounts_id = false)
|
||||
|
||||
}
|
||||
|
||||
// the role completion check must be done at this end of the code, because
|
||||
// the check itself depends on other elements of the user object being defined
|
||||
foreach($u['roles'] as $roleType => $data){
|
||||
user_check_role_complete($u, $roleType);
|
||||
}
|
||||
|
||||
|
||||
/* Do this assignment without recursion :) */
|
||||
unset($u['orig']);
|
||||
$orig = $u;
|
||||
|
Loading…
Reference in New Issue
Block a user