diff --git a/register_participants.inc.php b/register_participants.inc.php index 062dacb..707ffc9 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -326,11 +326,13 @@ function saveProjectData($data){ mysql_query("DELETE FROM safety WHERE registrations_id='{$_SESSION['registration_id']}' AND conferences_id='{$conference['id']}'"); //and add them back foreach($data['safetyquestions'] AS $q) { - mysql_query("INSERT INTO safety (registrations_id,safetyquestions_id,answer,conferences_id) VALUES ( - '{$_SESSION['registration_id']}', - '{$q['id']}', - '".mysql_real_escape_string($q['answer'])."', - '{$conference['id']}')"); + if($q['id']) { + mysql_query("INSERT INTO safety (registrations_id,safetyquestions_id,answer,conferences_id) VALUES ( + '{$_SESSION['registration_id']}', + '{$q['id']}', + '".mysql_real_escape_string($q['answer'])."', + '{$conference['id']}')"); + } } } diff --git a/register_participants_main.php b/register_participants_main.php index 51a291d..1014e7c 100644 --- a/register_participants_main.php +++ b/register_participants_main.php @@ -25,42 +25,31 @@ require_once("common.inc.php"); require_once("register_participants.inc.php"); require_once("projects.inc.php"); -$q = mysql_query("SELECT registrations.status AS status, registrations.id AS regid, users.id AS studentid, users.firstname FROM registrations, users " . - "WHERE users.id = {$_SESSION['users_id']} AND users.registrations_id = registrations.id"); + user_auth_required("participant"); -echo mysql_error(); + $u=user_load($_SESSION['users_id']); + $reg=getRegistration($u['registrations_id']); - if(mysql_num_rows($q)==0) - { - header("Location: register_participants.php?action=logout"); - exit; - - } - $r=mysql_fetch_object($q); send_header("Participant Registration - Summary"); +echo nl2br(print_r($reg,true)); //only display the named greeting if we have their name - if($r->firstname) - { - echo i18n("Hello %1",array($r->firstname)); + if($u['firstname']) { + echo i18n("Hello %1",array($u['firstname'])); echo "
"; } echo "
"; - if(registrationFormsReceived()) - { - + if(registrationFormsReceived()) { //now select their project number - $q=mysql_query("SELECT projectnumber FROM projects WHERE registrations_id='".$_SESSION['registration_id']."' AND conferences_id='".$conference['id']."'"); + $q=mysql_query("SELECT projectnumber FROM projects WHERE registrations_id='".$u['registrations_id']."' AND conferences_id='".$conference['id']."'"); $projectinfo=mysql_fetch_object($q); - if($r->status=="complete") - { + if($reg['status']=="complete") { echo i18n("Congratulations, you are successfully registered for the %1. No further changes may be made to any of your forms.",array($config['fairname'])); } - else if($r->status=="paymentpending") - { + else if($reg['status']=="paymentpending") { echo i18n("We have received your forms but are missing your registration fee. You are NOT registered for the fair until your registration fee has been received"); } @@ -69,8 +58,7 @@ echo mysql_error(); echo "  $projectinfo->projectnumber"; } - else - { + else { echo i18n("Please use the checklist below to complete your registration. Click on an item in the table to edit that information. When you have entered all information, the Status field will change to Complete"); } echo "
"; @@ -88,7 +76,7 @@ echo ""; @@ -118,8 +106,7 @@ echo "
"; echo ""; echo ""; //check to see if its complete - $statusstudent=studentStatus(); + $statusstudent=studentsStatus(); echo outputStatus($statusstudent); echo "
"; - if($config['participant_mentor']=="yes") - { + if($config['participant_mentor']=="yes") { //mentor information echo "
"; echo outputStatus($statusproject); echo "
"; echo ""; @@ -131,8 +118,7 @@ echo ""; } - else - { + else { //if mentorship isnt required, then assume its complete so the checks below will still work properly $statusmentor="complete"; } @@ -169,7 +155,7 @@ echo "
"; echo outputStatus($statusmentor); echo "
"; @@ -263,7 +249,7 @@ echo "
"; echo ""; echo ""; //check to see if its complete - $statusnamecheck=namecheckStatus($_SESSION['registration_id']); + $statusnamecheck=namecheckStatus($u['registrations_id']); echo outputStatus($statusnamecheck); echo "
"; } } - $q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$_SESSION['registration_id']."' AND conferences_id='{$conference['id']}'"); + $q=mysql_query("SELECT * FROM projects WHERE registrations_id='".$u['registrations_id']."' AND conferences_id='{$conference['id']}'"); $project=mysql_fetch_object($q); $nominatedawards=getSpecialAwardsNominatedForProject($project->id); $num=count($nominatedawards); @@ -320,7 +306,7 @@ echo "
"; { echo "

".i18n("Registration Fee Information")."

"; - list($regfee, $rfeedata) = computeRegistrationFee($_SESSION['registration_id']); + list($regfee, $rfeedata) = computeRegistrationFee($u['registrations_id']); $extra_after = ""; echo ""; diff --git a/user.inc.php b/user.inc.php index f1d91e6..910eedf 100644 --- a/user.inc.php +++ b/user.inc.php @@ -99,7 +99,15 @@ function user_load($users_id, $accounts_id = false) // get a list of all fields relevant to this user $fieldDat = user_get_fields(array_keys($u['roles'])); // we need to separate the fields that are in the users table from those in separate tables - $fields = array_unique(array_merge(array_keys($fieldDat), array('id', 'accounts_id', 'conferences_id'))); + + //if its a participant, we want the registrations_id as well + if(array_key_exists('participant', $u['roles'])){ + $startfields=array('id', 'accounts_id', 'conferences_id','registrations_id'); + } + else { + $startfields=array('id', 'accounts_id', 'conferences_id'); + } + $fields = array_unique(array_merge(array_keys($fieldDat), $startfields)); $userFields = array(); $q = mysql_query("DESCRIBE users"); while($row = mysql_fetch_assoc($q)){ @@ -113,7 +121,7 @@ function user_load($users_id, $accounts_id = false) accounts.email FROM users JOIN accounts ON accounts.id=users.accounts_id WHERE `users`.`id`='$users_id'"; - // echo $query=$query; +// echo "query=$query"; $q = mysql_query($query); echo mysql_error(); @@ -722,7 +730,7 @@ function user_save(&$u) $fields = array('salutation','firstname','lastname', 'phonehome','phonework','phonecell','fax','organization', 'address','address2','city','province','postalcode','sex', - 'firstaid', 'cpr', 'lang', 'notes'); + 'firstaid', 'cpr', 'lang', 'notes','birthdate'); /* Merge fields as necessary, build a big list of fields to save */ foreach($new_roles as $r) { @@ -1373,6 +1381,7 @@ $user_fields_map = array( 'phonehome' => array('phonehome'), 'phonecell' => array('phonecell'), 'birthdate' => array('birthdate'), + 'grade' => array('grade'), 'lang' => array('lang'), 'address' => array('address', 'address2', 'postalcode'), 'city' => array('city'), @@ -1393,6 +1402,8 @@ function user_fields_enabled($role) global $config, $user_fields_map; $ret = array('firstname','lastname'); $fields = $config["{$role}_personal_fields"]; + //for participants, grade is required + if($role=="participant") $ret[]="grade"; if($fields != '') { $fields = explode(',', $fields); foreach($fields as $f) { @@ -1411,6 +1422,8 @@ function user_fields_required($role) global $config, $user_fields_map; $ret = array('firstname','lastname'); $required = $config["{$role}_personal_required"]; + //for participants, grade is required + if($role=="participant") $ret[]="grade"; if($required != '') { $fields = explode(',', $required); foreach($fields as $f) { diff --git a/user_edit.inc.php b/user_edit.inc.php index 689c643..e0b51d7 100644 --- a/user_edit.inc.php +++ b/user_edit.inc.php @@ -125,10 +125,14 @@ function user_personal_info_status(&$u) $our_fields = array('salutation', 'firstname','lastname','address', 'address2','city','province','postalcode', 'phonehome','phonecell','language','sex', - 'firstaid','cpr'); + 'firstaid','cpr','birthdate','grade'); $required = array_intersect($our_fields, $required); foreach($required as $r) { + if($r=="birthdate") { + if($u[$r]=="0000-00-00" || !$u[$r]) + return "incomplete"; + } if(trim($u[$r]) == '') return 'incomplete'; } /* FIXME: somehow call the $role _status_update() function to update diff --git a/user_personal.php b/user_personal.php index b45e9f9..190171d 100644 --- a/user_personal.php +++ b/user_personal.php @@ -51,7 +51,7 @@ foreach(array_keys($u['roles']) as $r) { $our_fields = array('salutation', 'firstname','lastname','address', 'address2','city','province','postalcode', 'phonehome','phonecell','language','sex', - 'firstaid','cpr'); + 'firstaid','cpr','birthdate','grade'); $fields = array_intersect($our_fields, $fields); $required = array_intersect($our_fields, $required); @@ -173,6 +173,8 @@ if(count($u['roles']) > 1) { + +