From a773a76ed912c3d21024e75fb596710c6213bdd8 Mon Sep 17 00:00:00 2001 From: jacob Date: Mon, 28 Feb 2011 21:45:51 +0000 Subject: [PATCH] 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 --- participant.inc.php | 37 +++++++++++++++++++++++-------------- user.inc.php | 2 +- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/participant.inc.php b/participant.inc.php index 08656ed..afd8f70 100644 --- a/participant.inc.php +++ b/participant.inc.php @@ -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; } diff --git a/user.inc.php b/user.inc.php index 999c904..5caa291 100644 --- a/user.inc.php +++ b/user.inc.php @@ -690,7 +690,7 @@ function user_get_fields($userRoles = null){ // will have a function called _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)!