From 74fe5db9f7739cecc79e5a8116dc202aee1a9008 Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 19 Oct 2008 15:46:43 +0000 Subject: [PATCH] - update the volunteer reg, so the volunteer_complete is automatically updated. - BUG: the user personal editor doesn't call the judge/volunteer/whatever_status_update() function, so if a user leaves their personal info to the end, they MUST load the whatever_main.php page so their overall status is updated correctly. --- volunteer.inc.php | 23 +++++++++++++++++++++-- volunteer_main.php | 10 ++-------- volunteer_position.php | 32 ++++++++++++++++---------------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/volunteer.inc.php b/volunteer.inc.php index 41cdecc..8706d8e 100644 --- a/volunteer.inc.php +++ b/volunteer.inc.php @@ -25,11 +25,11 @@ = 1) { @@ -37,4 +37,23 @@ function volunteer_status_position($u = false) } return "incomplete"; } + +function volunteer_status_update(&$u) +{ + if($u['load_full'] == false) { + echo "ERROR: volunteer_status_update() called without a full user."; + exit; + } + + if( user_personal_info_status($u) == 'complete' + && volunteer_status_position($u) == 'complete' ) + $u['volunteer_complete'] = 'yes'; + else + $u['volunteer_complete'] = 'no'; + + user_save($u); + return ($u['volunteer_complete'] == 'yes') ? 'complete' : 'incomplete'; + +} + ?> diff --git a/volunteer_main.php b/volunteer_main.php index 10aaff3..8835224 100644 --- a/volunteer_main.php +++ b/volunteer_main.php @@ -49,8 +49,6 @@ echo "
"; echo "
"; - $u = user_load($_SESSION['users_id']); - user_page_summary_begin(); user_page_summary_item("Contact Information", "user_personal.php", "user_personal_info_status", array($u)); @@ -58,12 +56,8 @@ "volunteer_position.php", "volunteer_status_position", array($u)); $overallstatus = user_page_summary_end(true); - /* A bit of a FIXME here, if a user completes everythign but doesn't refresh - this page, they will never be marked as complete. Not sure how to handle - this, it's kinda hackey to call EVERY status() fucntion within EACH page to - get teh overall status. */ - /* Change this to volunteer_status */ - user_update_complete($u, $overallstatus); + /* Update volunteer_status */ + volunteer_status_update($u); echo "
"; echo "
"; diff --git a/volunteer_position.php b/volunteer_position.php index 0ffe618..b59b91a 100644 --- a/volunteer_position.php +++ b/volunteer_position.php @@ -29,18 +29,9 @@ user_auth_required('volunteer'); - $u = user_load($_SESSION['users_id']); + $u = user_load($_SESSION['users_id'], true); - /* Load the user's volunteer position selections */ - - //send the header - $type = $_SESSION['users_type']; - send_header("{$user_what[$type]} - Volunteer Positions", - array("{$user_what[$type]} Registration" => "{$type}_main.php") - ); - - if($_POST['action']=="save") { $vals = ''; @@ -59,14 +50,14 @@ if(!in_array($id, $posns)) continue; if($vals != '') $vals .=','; - $vals .= "('{$_SESSION['users_id']}','$id','{$config['FAIRYEAR']}')"; + $vals .= "('{$u['id']}','$id','{$config['FAIRYEAR']}')"; } } /* Delete existing selections */ mysql_query("DELETE FROM volunteer_positions_signup WHERE - users_id='{$_SESSION['users_id']}' + users_id='{$u['id']}' AND year='{$config['FAIRYEAR']}' "); echo mysql_error(); @@ -79,20 +70,29 @@ } - echo notice(i18n("Volunteer Positions successfully updated")); + message_push(notice(i18n("Volunteer Positions successfully updated"))); } +/* update overall status */ +volunteer_status_update($u); + //output the current status $newstatus=volunteer_status_position($u); if($newstatus!='complete') { - echo error(i18n("Volunteer Position Selection Incomplete")); + message_push(error(i18n("Volunteer Position Selection Incomplete"))); } else { - echo happy(i18n("Volunteer Position Selection Complete")); + message_push(happy(i18n("Volunteer Position Selection Complete"))); } + //send the header + send_header("Volunteer Positions", + array("Volunteer Registration" => "volunteer_main.php") + ); + + echo "
\n"; echo "\n"; @@ -100,7 +100,7 @@ else /* Read current selections */ $q = "SELECT * FROM volunteer_positions_signup WHERE - users_id = '{$_SESSION['users_id']}' + users_id = '{$u['id']}' AND year='{$config['FAIRYEAR']}'"; $r = mysql_query($q); $checked_positions = array();