logic change for early access

This commit is contained in:
2017-06-26 22:30:11 +10:00
parent f951c6bc9b
commit b530dba1ad

View File

@@ -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',