diff --git a/booking.admin.inc b/booking.admin.inc index 05da549..fc709d3 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -9,6 +9,16 @@ function booking_admin() //regenerate all our menu hooks when loading this form menu_rebuild(); + //create the mysql view booking_person_view if necessary + $sqlview_check = db_query("SELECT 1 FROM {booking_person_view}")->fetchAssoc(); + if (! $sqlview_check) { + watchdog('booking_debug', "SQL View booking_person_view check does not exist"); + _booking_node_create_mysqlview(); + } + else { + watchdog('booking_debug', "
SQL View booking_person_view check\n@info
", array('@info' => print_r( $sqlview_check, true))); + } + $form = array(); $form['email'] = array( diff --git a/booking.install b/booking.install index e22342b..daf4e9f 100644 --- a/booking.install +++ b/booking.install @@ -531,37 +531,42 @@ function booking_update_7232() { db_change_field('booking_person', 'booking_event_id', 'booking_eventid', $spec); } +/** +* Ensure SQL View booking_person_view is created +*/ +function booking_update_7233() { + _booking_node_create_mysqlview(); +} + /** * Implementation of hook_install(). */ function booking_install() { - //create the sql view we use - _booking_node_create_mysqlview(); - // Create some sample data // TODO: Set default values for the config pages too -$result = db_insert('booking_price') - ->fields(array( - 'booking_eventid' => 1, - 'booking_price' => '50.00', - 'booking_price_descrip' => 'Deposit', - 'booking_buttonid' => '', - 'booking_price_active' => 1, - 'booking_depositonly' => 1, - )) - ->execute(); - -$result = db_insert('booking_event') - ->fields(array( - 'booking_eventname' => 'Sample Event', - 'booking_event_active' => 1, - 'booking_register_open' => 1312207199, - 'booking_register_close' => 1340459999, - 'booking_earlybird_close' => 1328018399, - )) - ->execute(); - - //earlybird close is 31st Jan 2012 at 13:59:59 UTC + $result = db_insert('booking_price') + ->fields(array( + 'booking_eventid' => 1, + 'booking_price' => '50.00', + 'booking_price_descrip' => 'Deposit', + 'booking_buttonid' => '', + 'booking_price_active' => 1, + 'booking_depositonly' => 1, + )) + ->execute(); + //earlybird close is 31st Jan 2012 at 13:59:59 UTC + $result = db_insert('booking_event') + ->fields(array( + 'booking_eventname' => 'Sample Event', + 'booking_event_active' => 1, + 'booking_register_open' => 1312207199, + 'booking_register_close' => 1340459999, + 'booking_earlybird_close' => 1328018399, + )) + ->execute(); + + //create the sql view booking_person_view when first installing this module + _booking_node_create_mysqlview(); } /** diff --git a/booking.travel.inc b/booking.travel.inc index a52c05e..d99cd50 100644 --- a/booking.travel.inc +++ b/booking.travel.inc @@ -69,7 +69,7 @@ function booking_travel_page() ); //actual form $return_array[] = array( - 'form' => drupal_get_form('travel_form', true, $node->nid) + 'form' => drupal_get_form('travel_form', true, $node, $tokens) ); //text after form /* @@ -92,7 +92,7 @@ function booking_travel_page() } -function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0) +function travel_form($node, &$form_state, $inserting = FALSE, $node = NULL, $tokens = NULL) { global $event; date_default_timezone_set(date_default_timezone(FALSE)); @@ -105,7 +105,7 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0) $transport_type_options = array( 'Driving' => 'Driving', //'Train' => 'Train', - 'Flying' => 'Flying' + 'Flying' => 'Flying', ); //there's already info in $node so use that @@ -118,9 +118,9 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0) } //get info about this person from the relevant node id - $person = db_query("SELECT booking_dietary, booking_medical_conditions, booking_bf_gf_nid, booking_partner_id, booking_room_mate1 " . "FROM {booking_person} " . "WHERE nid = :nid ", array( - ':nid' => $nid <> 0 ? $nid : $data->booking_person_nid - ))->fetchObject(); + $person = db_query("SELECT booking_dietary, booking_medical_conditions, booking_bf_gf_nid, booking_partner_id, booking_room_mate1 " . + "FROM {booking_person} " . "WHERE nid = :nid ", + array(':nid' => $node->nid <> NULL ? $node->nid : $data->booking_person_nid))->fetchObject(); if ($person) { $booking_dietary = $person->booking_dietary; @@ -134,12 +134,12 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0) //store the node id $form['personid'] = array( '#type' => 'hidden', - '#value' => $nid + '#value' => $node->nid, ); $form['travel'] = array( '#type' => 'fieldset', - '#title' => 'Travel details' + '#title' => 'Travel details', ); $form['travel']['booking_transport_type'] = array( '#type' => 'radios', @@ -298,14 +298,17 @@ function travel_form($node, &$form_state, $inserting = FALSE, $nid = 0) '#default_value' => !empty($data->booking_dietary) ? $data->booking_dietary : $booking_dietary ); } - $form['requirements']['booking_medical_conditions'] = array( - '#type' => 'textfield', - '#title' => t('Please describe any medical condition we need to know about.'), - '#description' => t('This field contains information you entered when you registered.'), - '#maxlength' => 180, - '#required' => FALSE, - '#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : $booking_medical_conditions - ); + //display the medical conditions question if it is enabled + if (variable_get('booking_enable_medcond', 0) == 1) { + $form['requirements']['booking_medical_conditions'] = array( + '#type' => 'textfield', + '#title' => t('Please describe any medical condition we need to know about.'), + '#description' => t('This field contains information you entered when you registered.'), + '#maxlength' => 180, + '#required' => FALSE, + '#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : $booking_medical_conditions + ); + } //only show the room mate field if we're allowed to if (variable_get('booking_enable_roommate', 0) == 1 || $inserting == FALSE) { //married people won't need to select a room mate