From b530dba1ad80492667b64390f2529b4aa4eaed1d Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 26 Jun 2017 22:30:11 +1000 Subject: [PATCH] logic change for early access --- booking.regn_form.inc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/booking.regn_form.inc b/booking.regn_form.inc index af76ba1..2b958f2 100644 --- a/booking.regn_form.inc +++ b/booking.regn_form.inc @@ -17,8 +17,11 @@ function booking_register_page() //figure out if we're allowed to accept bookings $booking_times = db_query("SELECT booking_register_open, booking_register_close FROM {booking_event} where eid = :eid", array(':eid' => $event->eid))->fetchObject(); + + $allowed_time_check = ($booking_times->booking_register_open < time()) && ($booking_times->booking_register_close > time()); + $earlyaccess_time_check = ($booking_times->booking_register_close > time()) && variable_get('booking_enable_earlyaccess_codes', 0) == 1); - if ($booking_times->booking_register_open < time() && $booking_times->booking_register_close > time()) { + if ($allowed_time_check || $earlyaccess_time_check) { //we are within the allowed timeframe for registrations //check if this registration will be on the waiting list if (_booking_check_bookings_full() == True) { @@ -34,7 +37,7 @@ function booking_register_page() ) ); $return_array[] = array( - 'form' => drupal_get_form('booking_form', true) + 'form' => drupal_get_form('booking_form', true, true) ); } elseif ($booking_times->booking_register_close < time()) { //too late to register @@ -59,7 +62,7 @@ function booking_register_page() return $return_array; } -function booking_form($node, &$form_state, $inserting = FALSE) +function booking_form($node, &$form_state, $inserting = FALSE, $early_access_allowed = FALSE) { global $event; @@ -119,14 +122,14 @@ function booking_form($node, &$form_state, $inserting = FALSE) // ------- form starts here --------- //add new feature for early registration access - if ($inserting == TRUE && variable_get('booking_enable_earlyaccess_codes', 0) == 1) { + if ($early_access_allowed) { $form['early-access'] = array( '#type' => 'fieldset', '#title' => 'Early Registration Code' ); $form['early-access']['booking_earlyaccess_explanation'] = array( '#type' => 'container', - '#children' => "If you have been given an early access code for registration, please enter it below. Note that this code can only be used once, so don't pass it along to your friends!", + '#children' => "If you have been given an early access code for registration, please enter it below. Note that this code can only be used once, so don't pass it along to your friends! Without this code, your registration will not be accepted.", ); $form['early-access']['booking_regn_earlyaccess_code'] = array( '#type' => 'textfield',