Quick touch-up on the user structure, adding a subset to the user role status for the participant role. Fixing also (I think) the problem with users always seeming to have the complete status

This commit is contained in:
jacob 2011-02-28 21:45:51 +00:00
parent 69bc561055
commit a773a76ed9
2 changed files with 24 additions and 15 deletions

View File

@ -316,21 +316,30 @@ function namecheckStatus($reg_id="")
return 'complete';
}
function participant_status_completion_details($u){
return array(
'namecheck' => namecheckStatus($regId),
'tour' => tourStatus($regId),
'spaward' => spawardStatus($regId),
'safety' => safetyStatus($regId),
'mentor' => mentorStatus($regId),
'project' => projectStatus($regId),
'emergencycontact' => emergencycontactStatus($regId),
'student' => studentStatus($regId)
);
}
function participant_status_update(&$u){
$regId = $u['registrations_id'];
if( namecheckStatus($regId) == 'complete' &&
tourStatus($regId) == 'complete' &&
spawardStatus($regId) == 'complete' &&
safetyStatus($regId) == 'complete' &&
mentorStatus($regId) == 'complete' &&
projectStatus($regId) == 'complete' &&
emergencycontactStatus($regId) == 'complete' &&
studentStatus($regId) == 'complete' &&
registrationFormsReceived($regId) // <-- returns true/false, not text
){
$u['roles']['participant']['complete'] = 'yes';
}else{
$u['roles']['participant']['complete'] = 'no';
$status = participant_status_completion_details($u);
$overall = 'complete';
$u['roles']['participant']['completesections'] = array();
foreach($status as $key => $val){
$u['roles']['participant']['completesections'][$key] = ($val == 'complete') ? 'yes':'no';
if($val != 'complete'){
$overall = 'incomplete';
}
}
return ($u['roles']['participant']['complete'] == 'yes') ? 'complete' : 'incomplete';
$u['roles']['participant']['complete'] = ($overall == 'complete') ? 'yes':'no';
return $overall;
}

View File

@ -690,7 +690,7 @@ function user_get_fields($userRoles = null){
// will have a function called <role>_status_update, which updates their status with the
// current session data and returns 'complete' or 'incomplete' accordingly.
// I love the fact that this remark took more characters than the function.
function user_check_role_complete($u, $role){
function user_check_role_complete(&$u, $role){
$func = $role . '_status_update';
if(function_exists($func)){
$result = $func($u); // that's right, func(u)!