From 238c8a8ed7ed4afacd10ce94157ec877904374bd Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Thu, 29 Jun 2017 16:10:36 +1000 Subject: [PATCH] revert changes --- booking.earlyaccess_admin.inc | 2 +- booking.install | 21 +++++++++++++++------ booking.regn_form.inc | 9 ++++++++- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/booking.earlyaccess_admin.inc b/booking.earlyaccess_admin.inc index 319b3ca..dc7a373 100644 --- a/booking.earlyaccess_admin.inc +++ b/booking.earlyaccess_admin.inc @@ -27,7 +27,7 @@ function booking_earlyaccess_admin() { //get a list of all the early access codes for this event $codelist_query = db_select('booking_earlyaccess_codes', 'c'); - $codelist_query->leftJoin('booking_person', 'p', 'p.booking_earlyaccess_code = c.booking_earlyaccess_code'); + $codelist_query->leftJoin('booking_person', 'p', 'c.cid = p.booking_earlyaccess_code_id'); $codelist_query->condition('c.booking_eventid', $event->eid, '=') ->fields('c') ->fields('p') diff --git a/booking.install b/booking.install index a584dc2..1caeff6 100644 --- a/booking.install +++ b/booking.install @@ -631,7 +631,7 @@ function booking_update_7241() { */ function booking_update_7242() { //add field to booking_person table - $spec = array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE); + $spec = array('type' => 'int', 'length' => '11', 'not null' => FALSE); db_add_field('booking_person', 'booking_earlyaccess_code_id', $spec); //create new table to store the valid codes @@ -661,12 +661,9 @@ function booking_update_7243() { } /** -* Rename booking_earlyaccess_code_id in booking_person table to booking_earlyaccess_code +* Rename booking_regn_earlyaccess_codes table to booking_earlyaccess_codes */ function booking_update_7244() { - $spec = array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE); - db_change_field('booking_person', 'booking_earlyaccess_code_id', 'booking_earlyaccess_code', $spec); - db_drop_table('booking_regn_earlyaccess_codes'); //create new table to store the valid codes @@ -686,6 +683,18 @@ function booking_update_7244() { _booking_node_create_mysqlview(); } +/** +* Rename booking_earlyaccess_code back to booking_earlyaccess_code_id in booking_person table +*/ +function booking_update_7245() { + $spec = array('type' => 'int', 'length' => '11', 'not null' => FALSE); + db_change_field('booking_person', 'booking_earlyaccess_code', 'booking_earlyaccess_code_id', $spec); + //update the view to match the new table definition + _booking_node_create_mysqlview(); +} + + + /** * Implementation of hook_install(). */ @@ -756,7 +765,7 @@ function booking_schema() { 'nid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'booking_eventid' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE), 'booking_tempid' => array('type' => 'varchar', 'length' => '40', 'not null' => FALSE), - 'booking_earlyaccess_code' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE), + 'booking_earlyaccess_code_id' => array('type' => 'int', 'length' => '11', 'not null' => FALSE), 'booking_timestamp' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'), 'booking_firstname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), 'booking_lastname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), diff --git a/booking.regn_form.inc b/booking.regn_form.inc index addd0e0..594772c 100644 --- a/booking.regn_form.inc +++ b/booking.regn_form.inc @@ -1136,6 +1136,13 @@ function booking_form_submit($form, &$form_state) $payment_total_price = db_query("SELECT booking_price FROM {booking_price} where pid = :pid", array( ':pid' => $form_state['input']['booking_payment_id'] ))->fetchObject(); + + //lookup the primary key for the early access code, if it is in use + if ((variable_get('booking_enable_earlyaccess_codes', 0) == 1) && (!empty($form_state['input']['booking_earlyaccess_code']))) { + $earlyaccess_query = db_query("SELECT cid FROM {booking_earlyaccess_codes} where booking_earlyaccess_code = :code", + array(':code' => $values['booking_earlyaccess_code'])) + ->fetchObject(); + } //make a new node object $node = new stdClass(); @@ -1248,7 +1255,7 @@ function booking_form_submit($form, &$form_state) $node->booking_skills_language_details = empty($values['booking_skills_language_details']) ? 'N/A' : $values['booking_skills_language_details']; $node->booking_skills_other = empty($values['booking_skills_other']) ? 'N' : ($values['booking_skills_other'] == 1 ? 'Y' : 'N'); $node->booking_skills_other_details = empty($values['booking_skills_other_details']) ? 'N/A' : $values['booking_skills_other_details']; - $node->booking_earlyaccess_code = empty($values['booking_earlyaccess_code']) ? '' : $values['booking_earlyaccess_code']; + $node->booking_earlyaccess_code = empty($values['booking_earlyaccess_code']) ? '' : $earlyaccess_query->cid; //remove newlines from these fields so the CSV output doesn't get messed up $medical = empty($values['booking_medical_conditions']) ? 'N/A' : $values['booking_medical_conditions'];