- 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.
This commit is contained in:
dave 2008-10-19 15:46:43 +00:00
parent 7f1331d401
commit 74fe5db9f7
3 changed files with 39 additions and 26 deletions

View File

@ -25,11 +25,11 @@
<?
function volunteer_status_position($u = false)
function volunteer_status_position($u)
{
global $config;
/* See if they have selected something */
$q = "SELECT * FROM volunteer_positions_signup WHERE users_id='{$_SESSION['users_id']}'
$q = "SELECT * FROM volunteer_positions_signup WHERE users_id='{$u['id']}'
AND year='{$config['FAIRYEAR']}'";
$r = mysql_query($q);
if(mysql_num_rows($r) >= 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';
}
?>

View File

@ -49,8 +49,6 @@
echo "<br />";
echo "<br />";
$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 "<br />";
echo "<br />";

View File

@ -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 "<form name=\"personalform\" method=\"post\" action=\"volunteer_position.php\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\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();