diff --git a/db/db.code.version.txt b/db/db.code.version.txt
index 9be0dc9..bf18240 100644
--- a/db/db.code.version.txt
+++ b/db/db.code.version.txt
@@ -1 +1 @@
-228
+229
diff --git a/db/db.update.229.sql b/db/db.update.229.sql
new file mode 100644
index 0000000..f376fc4
--- /dev/null
+++ b/db/db.update.229.sql
@@ -0,0 +1 @@
+ALTER TABLE `emergencycontact` ADD `users_id` INT NULL DEFAULT NULL AFTER `registrations_id`;
diff --git a/register_participants_emergencycontact.php b/register_participants_emergencycontact.php
index eb1c472..90bed9a 100644
--- a/register_participants_emergencycontact.php
+++ b/register_participants_emergencycontact.php
@@ -22,113 +22,37 @@
*/
?>
- require("common.inc.php");
- include "register_participants.inc.php";
- include "user.inc.php";
-
- //authenticate based on email address and registration number from the SESSION
- if(!$_SESSION['email'])
- {
- header("Location: register_participants.php");
- exit;
- }
- if(!$_SESSION['registration_number'])
- {
- header("Location: register_participants.php");
- exit;
- }
+require("common.inc.php");
+include "register_participants.inc.php";
+include "user.inc.php";
- $q=mysql_query("SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students ".
- "WHERE students.email='".$_SESSION['email']."' ".
- "AND registrations.num='".$_SESSION['registration_number']."' ".
- "AND registrations.id='".$_SESSION['registration_id']."' ".
- "AND students.registrations_id=registrations.id ".
- "AND registrations.conferences_id=".$conference['id']." ".
- "AND students.conferences_id=".$conference['id']);
-echo mysql_error();
+$edit_id = isset($_GET['users_id']) ? intval($_GET['users_id']) : $_SESSION['users_id'];
+if($edit_id != $_SESSION['users_id'])
+ user_auth_required('admin');
+else
+ user_auth_required();
- if(mysql_num_rows($q)==0)
- {
- header("Location: register_participants.php");
- exit;
-
- }
- $authinfo=mysql_fetch_object($q);
- //send the header
- send_header("Participant Registration - Emergency Contact Information");
+if(array_key_exists('action', $_POST)){
+ switch($_POST['action']){
+ case 'save':
+ saveData();
+ break;
+ }
+}
- echo "<< ".i18n("Back to Participant Registration Summary")."
";
- echo "
";
+send_header("Participant Registration - Emergency Contact Information");
- $studentstatus=studentStatus();
- if($studentstatus!="complete")
- {
+echo "<< ".i18n("Back to Participant Registration Summary")."
";
+echo "
";
+
+$studentstatus=studentStatus();
+if($studentstatus!="complete")
+{
echo error(i18n("Please complete the Student Information Page first"));
send_footer();
exit;
- }
-
-
- if($_POST['action']=="save")
- {
- if(registrationFormsReceived()) {
- echo error(i18n("Cannot make changes to forms once they have been received by the fair"));
- }
- else if(registrationDeadlinePassed()) {
- echo error(i18n("Cannot make changes to forms after registration deadline"));
- }
- else {
- //first, lets make sure this emergency contact really does belong to them
- foreach($_POST['ids'] AS $id)
- {
- $q=mysql_query("SELECT * FROM emergencycontact WHERE id='$id' AND registrations_id='".$_SESSION['registration_id']."' AND conferences_id='".$conference['id']."'");
- if(mysql_num_rows($q)==1) {
- $e=stripslashes($_POST['email'][$id]);
- if($_POST['relation'][$id]=="Parent" && $e && user_valid_email($e)) {
- if($u=user_load_by_email($e)) {
- $u['firstname']=stripslashes($_POST['firstname'][$id]);
- $u['lastname']=stripslashes($_POST['lastname'][$id]);
- $u['phonehome']=stripslashes($_POST['phone1'][$id]);
- $u['phonework']=stripslashes($_POST['phone2'][$id]);
- $u['email']=$e;
- $u['types'][]="parent";
- user_save($u);
- }
- else {
- $u=user_create("parent",$e);
- $u['firstname']=stripslashes($_POST['firstname'][$id]);
- $u['lastname']=stripslashes($_POST['lastname'][$id]);
- $u['phonehome']=stripslashes($_POST['phone1'][$id]);
- $u['phonework']=stripslashes($_POST['phone2'][$id]);
- $u['email']=$e;
- user_save($u);
- }
- }
-
- mysql_query("UPDATE emergencycontact SET ".
- "firstname='".mysql_escape_string(stripslashes($_POST['firstname'][$id]))."', ".
- "lastname='".mysql_escape_string(stripslashes($_POST['lastname'][$id]))."', ".
- "relation='".mysql_escape_string(stripslashes($_POST['relation'][$id]))."', ".
- "phone1='".mysql_escape_string(stripslashes($_POST['phone1'][$id]))."', ".
- "phone2='".mysql_escape_string(stripslashes($_POST['phone2'][$id]))."', ".
- "phone3='".mysql_escape_string(stripslashes($_POST['phone3'][$id]))."', ".
- "phone4='".mysql_escape_string(stripslashes($_POST['phone4'][$id]))."', ".
- "email='".mysql_escape_string(stripslashes($_POST['email'][$id]))."' ".
- "WHERE id='$id'");
- echo mysql_error();
- echo notice(i18n("Emergency contact information successfully updated"));
- }
- else
- {
- echo error(i18n("Invalid emergency contact to update (%1)"),array($id));
- }
- }
- }
- }
-
-
-
+}
//output the current status
$newstatus=emergencycontactStatus();
if($newstatus!="complete")
@@ -140,8 +64,9 @@ else if($newstatus=="complete")
echo happy(i18n("Emergency Contact Information Complete"));
}
-
-$sq=mysql_query("SELECT id,firstname,lastname FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND conferences_id='".$conference['id']."'");
+$user = user_load($_SESSION['users_id']);
+$registrations_id = $user['registrations_id'];
+$sq=mysql_query("SELECT id,firstname,lastname FROM users WHERE registrations_id='$registrations_id' AND conferences_id='".$conference['id']."'");
$numstudents=mysql_num_rows($sq);
echo "
".i18n("First Name").": | firstname\" />".REQUIREDFIELD." | "; - echo "".i18n("Last Name").": | lastname\" />".REQUIREDFIELD." | "; + echo "".i18n("First Name").": | ".REQUIREDFIELD." | "; + echo "".i18n("Last Name").": | ".REQUIREDFIELD." | "; echo "
".i18n("Relation").": | "; - echo " \n"; - echo REQUIREDFIELD." | "; - echo "".i18n("Email Address").": | email\" /> | "; + echo " \n"; + echo REQUIREDFIELD.""; + echo "".i18n("Email Address").": | "; echo " | ||
".i18n("Phone 1").": | phone1\" />".REQUIREDFIELD." | "; - echo "".i18n("Phone 2").": | phone2\" /> | "; + echo "".i18n("Phone 1").": | ".REQUIREDFIELD." | "; + echo "".i18n("Phone 2").": | "; echo " |
".i18n("Phone 3").": | phone3\" /> | "; - echo "".i18n("Phone 4").": | phone4\" /> | "; + echo "".i18n("Phone 3").": | "; + echo " | ".i18n("Phone 4").": | "; echo " |