1482 lines
68 KiB
PHP
1482 lines
68 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Handle user registrations
|
|
*/
|
|
function booking_register_page()
|
|
{
|
|
//get some configuration information
|
|
global $event;
|
|
$output = "";
|
|
$return_array = array();
|
|
|
|
//set the page title
|
|
$bookingTitle = !empty($event->booking_eventname) ? $event->booking_eventname : 'Event';
|
|
drupal_set_title($bookingTitle . ' Booking Form');
|
|
|
|
//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);
|
|
$before_regn_open_check = ($booking_times->booking_register_open > 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) {
|
|
$output = token_replace(variable_get('booking_registration_waiting_intro_text'), booking_define_tokens());
|
|
} else {
|
|
//watchdog('booking', 'Booking registration form intro text: @info', array('@info' => var_export(variable_get('booking_registration_intro_text'), TRUE)));
|
|
$output = token_replace(variable_get('booking_registration_intro_text'), booking_define_tokens());
|
|
}
|
|
$return_array[] = array(
|
|
'paragraph' => array(
|
|
'#type' => 'markup',
|
|
'#markup' => $output
|
|
)
|
|
);
|
|
$return_array[] = array(
|
|
'form' => drupal_get_form('booking_form', true)
|
|
);
|
|
} elseif ($booking_times->booking_register_close < time()) {
|
|
//too late to register
|
|
$output = token_replace(variable_get('default_into_regn_closed_text'), booking_define_tokens());
|
|
$return_array[] = array(
|
|
'paragraph' => array(
|
|
'#type' => 'markup',
|
|
'#markup' => $output
|
|
)
|
|
);
|
|
} else {
|
|
//too early to register
|
|
$output = token_replace(variable_get('default_into_regn_not_opened_text'), booking_define_tokens());
|
|
$return_array[] = array(
|
|
'paragraph' => array(
|
|
'#type' => 'markup',
|
|
'#markup' => $output
|
|
)
|
|
);
|
|
}
|
|
|
|
return $return_array;
|
|
}
|
|
|
|
function booking_form($node, &$form_state, $inserting = FALSE)
|
|
{
|
|
global $event;
|
|
$status_options = array();
|
|
$payment_type_options = array();
|
|
$partner_options = array();
|
|
date_default_timezone_set(date_default_timezone(FALSE));
|
|
|
|
//calculate what years to show in the date of birth field
|
|
//along with some fudge factors to handle dates partway through the year
|
|
$min_dob_years = _booking_year_offset(variable_get('booking_min_dob', '1970-01-01 00:00:00')) + 1;
|
|
$max_dob_years = _booking_year_offset(variable_get('booking_max_dob', '1970-01-01 00:00:00')) - 1;
|
|
$date_year_range = "-" . $min_dob_years . ':-' . $max_dob_years;
|
|
|
|
//determine whether loading saved node or form submission
|
|
if (!empty($node)) {
|
|
$data = $node;
|
|
//watchdog('booking', 'Booking registration form loading data from saved node: @info', array('@info' => var_export($node, TRUE)));
|
|
} else {
|
|
$data = $form_state['input'];
|
|
//watchdog('booking', 'Booking registration form loading data from form submission: @info', array('@info' => var_export($form_state, TRUE)));
|
|
}
|
|
|
|
$price_query = db_select('booking_price', 'p');
|
|
$db_and = db_and()->condition('p.booking_eventid', $event->eid, '=')
|
|
->condition('p.booking_price_active', 1, '=')
|
|
->condition('p.booking_depositonly', 0, '=');
|
|
$price_query->condition($db_and);
|
|
$price_query->fields('p');
|
|
$result = $price_query->execute();
|
|
|
|
//figure out if we're in the earlybird rate section and use that for determining pricing
|
|
// Registrations are open and before early bird closes
|
|
$earlybird_check = (($event->booking_register_open <= time()) && ($event->booking_earlybird_close > time()));
|
|
// Early access is allowed and the time now is before registrations would normally open
|
|
$earlyaccess_check = ((variable_get('booking_enable_earlyaccess_codes', 0) == 1) && ($event->booking_register_open > time()));
|
|
|
|
// discounted payments is allowed if:
|
|
// - early access allowed and before registrations start
|
|
// - early access not allowed and after earlybird start but before earlybird finish
|
|
$early_payment_flag = $earlybird_check || $earlyaccess_check;
|
|
|
|
foreach ($result as $row) {
|
|
$price = $early_payment_flag == TRUE ? $row->booking_price : $row->booking_late_price;
|
|
$discount_suffix = $early_payment_flag == TRUE ? " - discounted rate" : "";
|
|
$payment_type_options[$row->pid] = $row->booking_price_descrip . ' ($' . $price . ')' . $discount_suffix;
|
|
}
|
|
|
|
// ------- form starts here ---------
|
|
|
|
//add new feature for early registration access
|
|
if ($inserting == TRUE && $earlyaccess_check) {
|
|
$form['early-access'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Early Registration Code'
|
|
);
|
|
$form['early-access']['booking_earlyaccess_feedback_wrapper'] = array(
|
|
'#markup' => '<div id="booking_earlyaccess_feedback_wrapper">If you have been given an early-access code for registration, please enter it below. ' .
|
|
'Without this code, your registration will not be accepted.<br />' .
|
|
'<p><strong>NOTE: each early-access code can only be used once, so don\'t pass it along to your friends!</strong></p></div><br />',
|
|
);
|
|
$form['early-access']['booking_earlyaccess_code'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Unique Early-Access Code'),
|
|
'#maxlength' => 45,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_earlyaccess_code) ? $data->booking_earlyaccess_code : '',
|
|
'#ajax' => array(
|
|
'event' => 'change',
|
|
'wrapper' => 'booking_earlyaccess_feedback_wrapper',
|
|
'callback' => 'booking_earlyaccess_feedback_callback',
|
|
),
|
|
);
|
|
$form['booking_earlyaccess'] = array(
|
|
'#type' => 'hidden',
|
|
'#value' => 1
|
|
);
|
|
}
|
|
|
|
$form['your-details'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Personal details'
|
|
);
|
|
|
|
//add a fieldset for data only admins can see
|
|
if ($inserting == FALSE) {
|
|
$form['internal-details'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Internal Details'
|
|
);
|
|
}
|
|
|
|
$form['your-details']['booking_firstname'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('First Name'),
|
|
'#maxlength' => 45,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_firstname) ? $data->booking_firstname : ''
|
|
);
|
|
$form['your-details']['booking_lastname'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Last Name'),
|
|
'#maxlength' => 45,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_lastname) ? $data->booking_lastname : ''
|
|
);
|
|
|
|
$form['your-details']['booking_gender'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Gender'),
|
|
'#required' => TRUE,
|
|
'#default_value' => variable_get('booking_gender', empty($data->booking_gender) ? variable_get('booking_default_gender') : $data->booking_gender),
|
|
'#options' => _booking_gender_options()
|
|
);
|
|
|
|
//If we're loading this from an existing node, we need to convert the timestamp into the proper format
|
|
$form['your-details']['booking_dob'] = array(
|
|
'#type' => 'date_select',
|
|
'#title' => t('Date of Birth'),
|
|
'#default_value' => empty($data->booking_dob) ? '' : date("Y-m-d H:i:s", $data->booking_dob),
|
|
'#required' => TRUE,
|
|
'#date_format' => 'd/m/Y',
|
|
'#date_label_position' => 'within',
|
|
'#date_year_range' => '-60:-10'
|
|
//'#date_year_range' => $date_year_range,
|
|
);
|
|
|
|
//override our generous date year range if this is a new form submission and that feature is enabled
|
|
if ($inserting == TRUE && variable_get('booking_enable_min_age_restriction', 1) == 1) {
|
|
$form['your-details']['booking_dob']['#date_year_range'] = $date_year_range;
|
|
}
|
|
|
|
$early_description_text = t("Please note that this is the discounted payment rate. For more information about payment rates, please see !theweek page.",
|
|
array('!theweek' => l('The Week', 'the-week/whats-happening')));
|
|
$form['your-details']['booking_payment_id'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Choose your payment type'),
|
|
'#description' => $early_payment_flag == TRUE ? $early_description_text : "",
|
|
'#default_value' => $inserting != TRUE ? $data->booking_payment_id : variable_get('booking_payment_id', 'worker'),
|
|
'#options' => $payment_type_options,
|
|
);
|
|
|
|
// The status field should not be visible unless this registration is being updated...i.e. not at actual registration time...
|
|
if ($inserting != TRUE) {
|
|
$form['internal-details']['booking_comment_field'] = array(
|
|
'#type' => 'textarea',
|
|
'#title' => t('Comments relating to this registration. Internal only.'),
|
|
'#cols' => 60,
|
|
'#rows' => 5,
|
|
'#resizable' => TRUE,
|
|
'#required' => FALSE,
|
|
'#attributes' => array(
|
|
'maxlength' => 1000
|
|
),
|
|
'#default_value' => !empty($data->booking_comment_field) ? $data->booking_comment_field : ''
|
|
);
|
|
|
|
$form['internal-details']['booking_status'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Registration Status'),
|
|
'#options' => _booking_status_generate(),
|
|
'#default_value' => !empty($data->booking_status) ? $data->booking_status : ''
|
|
);
|
|
|
|
$form['internal-details']['booking_welfare_required'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Welfare Required?'),
|
|
'#description' => t('Select to mark this attendee as requiring special financial consideration'),
|
|
'#default_value' => (!empty($data->booking_welfare_required) && $data->booking_welfare_required == 'Y') ? 1 : 0
|
|
);
|
|
|
|
$form['internal-details']['booking_committee_member'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Committee Member?'),
|
|
'#description' => t('Select to identify this attendee as being on the committee'),
|
|
'#default_value' => (!empty($data->booking_committee_member) && $data->booking_committee_member == 'Y') ? 1 : 0
|
|
);
|
|
|
|
$form['internal-details']['booking_amount_paid'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Amount Paid'),
|
|
'#maxlength' => 10,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_amount_paid) ? $data->booking_amount_paid : ''
|
|
);
|
|
|
|
$form['internal-details']['booking_total_pay_reqd'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Total Amount Due'),
|
|
'#maxlength' => 10,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_total_pay_reqd) ? $data->booking_total_pay_reqd : '0.00'
|
|
);
|
|
$form['internal-details']['booking_payment_complete'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Payment Completed?'),
|
|
'#description' => t('Select to mark this attendee as having fully paid'),
|
|
'#default_value' => (!empty($data->booking_payment_complete) && $data->booking_payment_complete == 'Y') ? 1 : 0
|
|
);
|
|
//refund info
|
|
$form['internal-details']['booking_refund_processed'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Refund Processed?'),
|
|
'#description' => t('Select to mark the processing of any applicable refund as complete'),
|
|
'#default_value' => (!empty($data->booking_refund_processed) && $data->booking_refund_processed == 'Y') ? 1 : 0
|
|
);
|
|
$form['internal-details']['booking_refund_due'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Refund Amount Due'),
|
|
'#maxlength' => 10,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_refund_due) ? $data->booking_refund_due : '0.00'
|
|
);
|
|
|
|
} //end inserting check for admin-only fields
|
|
|
|
//tshirts
|
|
if (variable_get('booking_enable_tshirts', 0) == 1) {
|
|
$form['your-details']['booking_shirt_size'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t(variable_get('booking_tshirts_text_definition', 'Preferred hoodie size')),
|
|
'#required' => FALSE,
|
|
'#default_value' => variable_get('booking_shirt_size', empty($data->booking_shirt_size) ? '' : $data->booking_shirt_size),
|
|
'#options' => _get_tshirt_options()
|
|
);
|
|
} //end enable tshirts check
|
|
|
|
$form['your-details']['booking_ecclesia'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Ecclesia'),
|
|
'#maxlength' => 100,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_ecclesia) ? $data->booking_ecclesia : ''
|
|
);
|
|
$form['your-details']['booking_baptised'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I am baptised'),
|
|
'#default_value' => (!empty($data->booking_baptised) && $data->booking_baptised == 'Y') ? 1 : 0
|
|
);
|
|
|
|
if (variable_get('booking_allow_couples', 0) == 1) {
|
|
$form['your-details']['booking_married'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I am married'),
|
|
'#default_value' => (!empty($data->booking_married) && $data->booking_married == 'Y') ? 1 : 0
|
|
);
|
|
$form['your-details']['booking_partner_name'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('If your partner is coming to !event also, please enter their name here. They must register and pay seperately.', array(
|
|
'!event' => $event->booking_eventname
|
|
)),
|
|
'#maxlength' => 120,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
// Only show this field when the 'booking_married' checkbox is enabled.
|
|
'visible' => array(
|
|
':input[name="booking_married"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
),
|
|
'#default_value' => !empty($data->booking_partner_name) ? $data->booking_partner_name : ''
|
|
);
|
|
|
|
if (variable_get('booking_ask_dependant_children', 0) == 1) {
|
|
$form['your-details']['booking_dependant_children'] = array(
|
|
'#type' => 'radios',
|
|
'#title' => t('Are you bringing dependant children to study week?'),
|
|
'#options' => array(
|
|
0 => t('No'),
|
|
t('Yes')
|
|
),
|
|
'#default_value' => (!empty($data->booking_dependant_children) && $data->booking_dependant_children == 'Y') ? 1 : 0,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
// Only show this field when the 'booking_married' checkbox is enabled.
|
|
'visible' => array(
|
|
':input[name="booking_married"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
)
|
|
);
|
|
|
|
$form['your-details']['booking_dependant_children_warning'] = array(
|
|
'#type' => 'container',
|
|
'#children' => variable_get('booking_dependant_children_text_definition', "<b>Please note that only one dependant child under the age of two is allowed.</b>"),
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_dependant_children"]' => array(
|
|
'value' => 1
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
if ($inserting == TRUE) {
|
|
$form['your-details']['booking_partner_id'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('If your partner has already registered for !event, please enter their registration id (number only) from the email they were sent. Otherwise, leave blank', array(
|
|
'!event' => $event->booking_eventname
|
|
)),
|
|
'#maxlength' => 15,
|
|
'#size' => 4,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
// Only show this field when the 'booking_married' checkbox is enabled.
|
|
'visible' => array(
|
|
':input[name="booking_married"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
),
|
|
'#default_value' => !empty($data->booking_partner_name) ? $data->booking_partner_name : ''
|
|
);
|
|
} else //not inserting so allow administrator to choose a person
|
|
{
|
|
//add the empty element first
|
|
$partner_options[] = '';
|
|
|
|
//get a list of possible partners
|
|
$partners = db_query("SELECT nid, booking_firstname, booking_lastname, booking_partner_id FROM {booking_person} " . "where booking_eventid = :eid and booking_married='Y' order by booking_lastname, booking_firstname", array(
|
|
':eid' => $event->eid
|
|
));
|
|
|
|
//convert that into an array
|
|
foreach ($partners as $row) {
|
|
$partner_options[$row->nid] = $row->booking_firstname . ' ' . $row->booking_lastname;
|
|
}
|
|
//create a select field
|
|
$form['internal-details']['booking_partner_id'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Choose Spouse'),
|
|
'#default_value' => $data->booking_partner_id,
|
|
'#options' => $partner_options
|
|
);
|
|
|
|
//add the boyfriend/girlfriend field in here too
|
|
$form['internal-details']['booking_bf_gf_nid'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Registration ID of Boyfriend/Girlfriend to be placed in the same discussion groups as you.'),
|
|
'#maxlength' => 15,
|
|
'#size' => 4,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_bf_gf_nid) ? $data->booking_bf_gf_nid : ''
|
|
);
|
|
|
|
$form['internal-details']['booking_keepseparate_id'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Registration ID of a person to keep separate when calculating discussion groups. Only a site administrator may set this.'),
|
|
'#maxlength' => 15,
|
|
'#size' => 4,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_keepseparate_id) ? $data->booking_keepseparate_id : ''
|
|
);
|
|
|
|
}
|
|
} //end allow couples check
|
|
|
|
//watchdog('booking', 'Booking registration form payment type: @info. Payment id: !id',
|
|
// array('@info' => $payment_type_options[$data->booking_payment_id], '!id' => $data->booking_payment_id ));
|
|
|
|
//only show the booking agreement tickbox if the node is being created, since this value isn't stored anywhere
|
|
if ($inserting == TRUE) {
|
|
$form['your-details']['booking_agreement'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Aims and Expectations'),
|
|
'#default_value' => empty($data->booking_agreement) ? 0 : $data->booking_agreement,
|
|
'#title' => token_replace(variable_get('booking_registration_aims_rules_checkbox'), booking_define_tokens()),
|
|
'#description' => token_replace(variable_get('booking_registration_aims_rules_text'), booking_define_tokens())
|
|
);
|
|
} else {
|
|
//not inserting
|
|
$form['booking_agreement'] = array(
|
|
'#type' => 'hidden',
|
|
'#value' => 1
|
|
);
|
|
|
|
$form['internal-details']['booking_barcode'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Barcode'),
|
|
'#maxlength' => 30,
|
|
'#size' => 30,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_barcode) ? $data->booking_barcode : ''
|
|
);
|
|
|
|
$form['internal-details']['booking_qrcode_url'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('QR Code URL'),
|
|
'#maxlength' => 500,
|
|
'#size' => 100,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_qrcode_url) ? $data->booking_qrcode_url : ''
|
|
);
|
|
|
|
$form['internal-details']['booking_luckynum'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Lucky Number'),
|
|
'#maxlength' => 30,
|
|
'#size' => 30,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_luckynum) ? $data->booking_luckynum : ''
|
|
);
|
|
|
|
$form['internal-details']['booking_readinggroup'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Reading Group Allocation'),
|
|
'#maxlength' => 100,
|
|
'#default_value' => !empty($data->booking_readinggroup) ? $data->booking_readinggroup : ''
|
|
);
|
|
} //end not-inserting check
|
|
|
|
|
|
$form['contact-details'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Contact details'
|
|
);
|
|
$form['contact-details']['booking_email'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('E-mail address'),
|
|
'#maxlength' => 100,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_email) ? $data->booking_email : ''
|
|
);
|
|
|
|
// Only confirm email address if the user is typing in their details
|
|
if ($inserting == TRUE) {
|
|
$form['contact-details']['booking_email_confirm'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Confirm e-mail address'),
|
|
'#maxlength' => 100,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_email_confirm) ? $data->booking_email_confirm : ''
|
|
);
|
|
}
|
|
|
|
$form['contact-details']['booking_phone'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Home Phone Number'),
|
|
'#maxlength' => 30,
|
|
'#size' => 35,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_phone) ? $data->booking_phone : ''
|
|
);
|
|
$form['contact-details']['booking_mobile'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Mobile Phone Number'),
|
|
'#size' => 35,
|
|
'#maxlength' => 30,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_mobile) ? $data->booking_mobile : ''
|
|
);
|
|
|
|
$form['contact-details']['booking_street'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Street Address'),
|
|
'#maxlength' => 50,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_street) ? $data->booking_street : ''
|
|
);
|
|
$form['contact-details']['booking_suburb'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Suburb'),
|
|
'#maxlength' => 50,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_suburb) ? $data->booking_suburb : ''
|
|
);
|
|
|
|
|
|
if ($inserting == TRUE) {
|
|
$form['contact-details']['booking_state'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('State'),
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_state) ? $data->booking_state : variable_get('booking_default_state', 'NSW'),
|
|
'#options' => _booking_state_options()
|
|
);
|
|
$form['contact-details']['booking_other_state'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please specify state'),
|
|
'#maxlength' => 50,
|
|
'#states' => array(
|
|
// Only show this field when the 'booking_state' is set to other.
|
|
'visible' => array(
|
|
':input[name="booking_state"]' => array(
|
|
'value' => 'Other'
|
|
)
|
|
)
|
|
),
|
|
'#default_value' => ''
|
|
);
|
|
} else {
|
|
//when modifying the node just show the textfield
|
|
$form['contact-details']['booking_state'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('State'),
|
|
'#maxlength' => 50,
|
|
'#default_value' => !empty($data->booking_state) ? $data->booking_state : ''
|
|
);
|
|
}
|
|
|
|
|
|
$form['contact-details']['booking_postcode'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Postal/Zip code'),
|
|
'#maxlength' => 8,
|
|
'#size' => 10,
|
|
'#required' => TRUE,
|
|
'#default_value' => !empty($data->booking_postcode) ? $data->booking_postcode : ''
|
|
);
|
|
$form['contact-details']['booking_country'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t('Country'),
|
|
'#required' => TRUE,
|
|
'#default_value' => variable_get('booking_country', empty($data->booking_country) ? variable_get('booking_default_country') : $data->booking_country),
|
|
'#options' => _booking_country_options()
|
|
);
|
|
|
|
//emergency contact details
|
|
$form['emergency'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Emergency Contact Details',
|
|
'#description' => 'Please enter contact details for use in case of emergency'
|
|
);
|
|
|
|
if (variable_get('booking_enable_medicare', 1) == 1) {
|
|
$medicare_required_check = (variable_get('booking_enforce_medicare_verification', 1) == 1) && $inserting;
|
|
$form['emergency']['booking_medicare'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Your Medicare Number'),
|
|
'#maxlength' => 15,
|
|
'#size' => 15,
|
|
'#required' => FALSE,
|
|
//'#required' => $medicare_required_check,
|
|
'#default_value' => empty($data->booking_medicare) ? '' : $data->booking_medicare
|
|
);
|
|
}
|
|
$form['emergency']['booking_guardian_name'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Emergency Contact Name'),
|
|
'#maxlength' => 100,
|
|
'#required' => TRUE,
|
|
'#default_value' => empty($data->booking_guardian_name) ? '' : $data->booking_guardian_name
|
|
);
|
|
$form['emergency']['booking_guardian_type'] = array(
|
|
'#type' => 'radios',
|
|
'#title' => t('Relation to you'),
|
|
'#options' => _booking_get_emergency_contact_types(),
|
|
'#default_value' => empty($data->booking_guardian_type) ? 'parent' : $data->booking_guardian_type,
|
|
'#required' => TRUE
|
|
);
|
|
|
|
//confirm the guardians email address if the user is entering details
|
|
//this isn't saved to the database
|
|
if ($inserting == TRUE) {
|
|
$form['emergency']['booking_guardian_email'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Emergency Contact Email Address'),
|
|
'#size' => 30,
|
|
'#required' => TRUE,
|
|
'#default_value' => empty($data->booking_guardian_email) ? '' : $data->booking_guardian_email,
|
|
);
|
|
$form['emergency']['booking_guardian_email_confirm'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Confirm Emergency Contact Email Address'),
|
|
'#size' => 30,
|
|
'#required' => TRUE,
|
|
'#default_value' => empty($data->booking_guardian_email_confirm) ? '' : $data->booking_guardian_email_confirm,
|
|
);
|
|
}
|
|
//don't require an admin to enter this field
|
|
else {
|
|
$form['emergency']['booking_guardian_email'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Emergency Contact Email Address'),
|
|
'#size' => 30,
|
|
'#required' => FALSE,
|
|
'#default_value' => empty($data->booking_guardian_email) ? '' : $data->booking_guardian_email,
|
|
);
|
|
}
|
|
$form['emergency']['booking_guardian_phone'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Emergency Contact Mobile Phone Number'),
|
|
'#maxlength' => 30,
|
|
'#size' => 30,
|
|
'#required' => TRUE,
|
|
'#default_value' => empty($data->booking_guardian_phone) ? '' : $data->booking_guardian_phone
|
|
);
|
|
$form['emergency']['booking_guardian_phone_alt'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Emergency Contact Alternate Contact Number'),
|
|
'#maxlength' => 30,
|
|
'#size' => 30,
|
|
'#required' => FALSE,
|
|
'#default_value' => empty($data->booking_guardian_phone_alt) ? '' : $data->booking_guardian_phone_alt
|
|
);
|
|
|
|
if (variable_get('booking_enable_helpareas', 1) == 1) {
|
|
$form['help-areas'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Help Areas'
|
|
);
|
|
|
|
//retrieve help areas that have been enabled by admin
|
|
$enabled_help_areas = variable_get('booking_enabled_helparea_options', NULL);
|
|
//watchdog('booking', "<pre>Retreiving help area options:\n@info</pre>", array('@info' => print_r( $enabled_help_areas, true)));
|
|
|
|
//define help areas
|
|
$help_areas = array(
|
|
'booking_help_music' => array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('I can help with music by playing the following musical instrument(s)'),
|
|
'#maxlength' => 200,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_help_music) ? $data->booking_help_music : ''
|
|
),
|
|
'booking_help_reading' => array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I can help with reading'),
|
|
'#default_value' => (!empty($data->booking_help_reading) && $data->booking_help_reading == 'Y') ? 1 : 0
|
|
),
|
|
'booking_help_chairing' => array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I can help with chairing'),
|
|
'#default_value' => (!empty($data->booking_help_chairing) && $data->booking_help_chairing == 'Y') ? 1 : 0
|
|
),
|
|
'booking_help_praying' => array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I can help with praying'),
|
|
'#default_value' => (!empty($data->booking_help_praying) && $data->booking_help_praying == 'Y') ? 1 : 0
|
|
),
|
|
'booking_help_meditations' => array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I can help with evening meditations'),
|
|
'#default_value' => (!empty($data->booking_help_meditations) && $data->booking_help_meditations == 'Y') ? 1 : 0
|
|
),
|
|
'booking_firstaid' => array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I am a qualified First Aid Officer'),
|
|
'#default_value' => (!empty($data->booking_firstaid) && $data->booking_firstaid == 'Y') ? 1 : 0
|
|
),
|
|
'booking_nurse' => array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I am a qualified Nurse'),
|
|
'#default_value' => (!empty($data->booking_nurse) && $data->booking_nurse == 'Y') ? 1 : 0
|
|
)
|
|
);
|
|
|
|
//include enabled help areas in the form
|
|
foreach ($help_areas as $key => $value) {
|
|
if (in_array($key, $enabled_help_areas)) {
|
|
$form['help-areas'][$key] = $value;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (variable_get('booking_enable_skills', 1) == 1) {
|
|
$form['mission-experience'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Mission Work Experience'
|
|
);
|
|
$form['mission-experience']['booking_has_mission_experience'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I have previous mission work experience'),
|
|
'#default_value' => (!empty($data->booking_has_mission_experience) && $data->booking_has_mission_experience == 'Y') ? 1 : 0
|
|
);
|
|
|
|
$form['mission-experience']['booking_mission_experience_details'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t("Please list the places you've done mission work previously"),
|
|
'#maxlength' => 200,
|
|
//'#size' => 100,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
// Only show this field when the 'booking_has_mission_experience' checkbox is enabled.
|
|
'visible' => array(
|
|
':input[name="booking_has_mission_experience"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
),
|
|
'#default_value' => !empty($data->booking_mission_experience_details) ? $data->booking_mission_experience_details : ''
|
|
);
|
|
$form['skill-areas'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Skills Section'
|
|
);
|
|
$form['skill-areas']['booking_skills_builder'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I am an experienced builder'),
|
|
'#default_value' => (!empty($data->booking_skills_builder) && $data->booking_skills_builder == 'Y') ? 1 : 0
|
|
);
|
|
$form['skill-areas']['booking_skills_cooking'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I can assist with cooking'),
|
|
'#default_value' => (!empty($data->booking_skills_cooking) && $data->booking_skills_cooking == 'Y') ? 1 : 0
|
|
);
|
|
$form['skill-areas']['booking_skills_childminding'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I have child minding experience or am happy to work with children and sunday school students'),
|
|
'#default_value' => (!empty($data->booking_skills_childminding) && $data->booking_skills_childminding == 'Y') ? 1 : 0
|
|
);
|
|
$form['skill-areas']['booking_skills_language'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I can speak multiple languages'),
|
|
'#default_value' => (!empty($data->booking_skills_language) && $data->booking_skills_language == 'Y') ? 1 : 0
|
|
);
|
|
|
|
$form['skill-areas']['booking_skills_language_details'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please list any languages other than English that you speak'),
|
|
'#maxlength' => 250,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_skills_language"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
),
|
|
'#default_value' => !empty($data->booking_skills_language_details) ? $data->booking_skills_language_details : ''
|
|
);
|
|
|
|
$form['skill-areas']['booking_skills_other'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I have other skills that can assist in preaching activities'),
|
|
'#default_value' => (!empty($data->booking_skills_other) && $data->booking_skills_other == 'Y') ? 1 : 0
|
|
);
|
|
$form['skill-areas']['booking_skills_other_details'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please list any skills you believe will be helpful'),
|
|
'#maxlength' => 250,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_skills_other"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
),
|
|
'#default_value' => !empty($data->booking_skills_other_details) ? $data->booking_skills_other_details : ''
|
|
);
|
|
|
|
}
|
|
|
|
$form['misc-areas'] = array(
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Miscellaneous'
|
|
);
|
|
|
|
if ($inserting == TRUE) {
|
|
$form['misc-areas']['booking_dietary_check'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I have special dietary requirements'),
|
|
'#default_value' => (!empty($data->booking_dietary) && $data->booking_dietary == 'Y') ? 1 : 0
|
|
);
|
|
|
|
if (variable_get('booking_enable_dietary', 0) == 1) {
|
|
$form['misc-areas']['booking_dietary'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please describe your dietary requirements.'),
|
|
'#maxlength' => 120,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_dietary_check"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
),
|
|
'#default_value' => !empty($data->booking_dietary) ? $data->booking_dietary : ''
|
|
);
|
|
}
|
|
//the user is not allowed to enter data directly, so show them the instructions specified by the admin configuration options
|
|
else {
|
|
$form['misc-areas']['booking_dietary'] = array(
|
|
'#type' => 'container',
|
|
'#children' => variable_get('booking_dietary_text_definition', "Please contact us to specify your dietary requirements."),
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_dietary_check"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
$form['misc-areas']['booking_medical_conditions_check'] = array(
|
|
'#type' => 'checkbox',
|
|
'#title' => t('I have special medical condition(s), including allergies'),
|
|
'#default_value' => (!empty($data->booking_medical_conditions) && $data->booking_medical_conditions == 'Y') ? 1 : 0
|
|
);
|
|
|
|
if (variable_get('booking_enable_medcond', 0) == 1) {
|
|
$form['misc-areas']['booking_medical_conditions'] = array(
|
|
'#type' => 'textarea',
|
|
'#title' => 'Medical Conditions',
|
|
'#description' => t("Please list any allergies you have, including your reaction to the allergen/s.<br />" .
|
|
"Please list any medical conditions you have.<br />All responses will be kept confidential."),
|
|
'#cols' => 60,
|
|
'#rows' => 5,
|
|
'#resizable' => FALSE,
|
|
'#required' => FALSE,
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_medical_conditions_check"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
),
|
|
'#attributes' => array(
|
|
'maxlength' => 1000
|
|
),
|
|
'#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : ''
|
|
);
|
|
}
|
|
//the user is not allowed to enter data directly, so show them the instructions specified by the admin configuration options
|
|
else {
|
|
$form['misc-areas']['booking_medical_conditions'] = array(
|
|
'#type' => 'container',
|
|
'#children' => variable_get('booking_medcond_text_definition', "Please contact us to specify your medical conditions."),
|
|
'#states' => array(
|
|
'visible' => array(
|
|
':input[name="booking_medical_conditions_check"]' => array(
|
|
'checked' => TRUE
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|
|
|
|
//inserting is not true, so give the admin the textfield for entering/viewing data for dietary and medical conditions
|
|
} else {
|
|
$form['misc-areas']['booking_dietary'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('Please describe your dietary requirements.'),
|
|
'#maxlength' => 120,
|
|
'#default_value' => !empty($data->booking_dietary) ? $data->booking_dietary : ''
|
|
);
|
|
$form['misc-areas']['booking_medical_conditions'] = array(
|
|
'#type' => 'textarea',
|
|
'#title' => t('Please list any medical conditions we need to be aware of. For allegies, please list the reaction to the allergen(s).'),
|
|
'#cols' => 60,
|
|
'#rows' => 5,
|
|
'#resizable' => TRUE,
|
|
'#required' => FALSE,
|
|
'#attributes' => array(
|
|
'maxlength' => 1000
|
|
),
|
|
'#default_value' => !empty($data->booking_medical_conditions) ? $data->booking_medical_conditions : ''
|
|
);
|
|
}
|
|
|
|
if (variable_get('booking_enable_roommate', 0) == 1) {
|
|
$form['misc-areas']['booking_room_mate1'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('List up to two people you would like to share a room with (subject to availability)'),
|
|
'#maxlength' => 200,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_room_mate1) ? $data->booking_room_mate1 : ''
|
|
);
|
|
}
|
|
/*
|
|
$form['misc-areas']['booking_random_facts'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t('List three random facts about yourself (optional).'),
|
|
'#maxlength' => 200,
|
|
'#required' => FALSE,
|
|
'#default_value' => !empty($data->booking_random_facts) ? $data->booking_random_facts : ''
|
|
);
|
|
*/
|
|
if (variable_get('booking_enable_songchoice', 0) == 1) {
|
|
$songchoice_required_check = (variable_get('booking_require_songchoice', 1) == 1) && $inserting;
|
|
$form['misc-areas']['booking_song_choice'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t("Let us know if there's a song you'd love to sing during the week"),
|
|
'#maxlength' => 200,
|
|
'#required' => $songchoice_required_check,
|
|
'#default_value' => !empty($data->booking_song_choice) ? $data->booking_song_choice : ''
|
|
);
|
|
}
|
|
if (variable_get('booking_enable_freestyle', 0) == 1) {
|
|
$freestyle_required_check = (variable_get('booking_require_freestyle', 1) == 1) && $inserting;
|
|
$form['misc-areas']['booking_freestyle_text'] = array(
|
|
'#type' => 'textfield',
|
|
'#title' => t("Freestyle text (anything you'd like to share)"),
|
|
'#maxlength' => 500,
|
|
'#required' => $freestyle_required_check,
|
|
'#default_value' => !empty($data->booking_freestyle_text) ? $data->booking_freestyle_text : ''
|
|
);
|
|
}
|
|
if (variable_get('booking_enable_previous_studyweeks', 0) == 1) {
|
|
$form['misc-areas']['booking_prev_sw_count'] = array(
|
|
'#type' => 'select',
|
|
'#title' => t("How many Study Weeks have you been to previously?"),
|
|
'#required' => FALSE,
|
|
'#default_value' => variable_get('booking_prev_sw_count', empty($data->booking_prev_sw_count) ? '' : $data->booking_prev_sw_count),
|
|
'#options' => _get_previous_sw_options(),
|
|
);
|
|
}
|
|
|
|
// https://www.lullabot.com/articles/a-beginners-guide-to-caching-data-in-drupal-7
|
|
// This code will only cache this one element
|
|
// And forms get cached differently anyway
|
|
/*
|
|
$form['cache'] = array('#cache' => array(
|
|
'cid' => 'booking_data',
|
|
'bin' => 'cache_booking',
|
|
'expire' => time() + 360,
|
|
),
|
|
);
|
|
*/
|
|
|
|
if ($inserting == TRUE) {
|
|
$form['submit'] = array(
|
|
'#type' => 'submit',
|
|
'#value' => t('Register')
|
|
);
|
|
}
|
|
return $form;
|
|
}
|
|
|
|
/**
|
|
* Callback function to verify if an early access code was valid
|
|
*/
|
|
function booking_earlyaccess_feedback_callback($form, &$form_state) {
|
|
global $event;
|
|
//$node = $form_state['values']['form_id'];
|
|
$data = $form_state['input'];
|
|
//watchdog('booking', '<pre>booking_earlyaccess_feedback_callback validation:\n@info</pre>', array('@info' => print_r( $data, true)));
|
|
|
|
//if necessary, validate early access code
|
|
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1 && (isset($data['booking_earlyaccess']) && $data['booking_earlyaccess'] == 1)) {
|
|
//watchdog('booking', '<pre>booking_earlyaccess_feedback_callback first if statement passed</pre>');
|
|
if (isset($data['booking_earlyaccess_code']) && $data['booking_earlyaccess_code'] != '') {
|
|
//watchdog('booking', '<pre>booking_earlyaccess_feedback_callback second if statement passed</pre>');
|
|
//perform a database lookup against the booking_earlyaccess_codes table
|
|
$code_check = db_query("SELECT cid " .
|
|
"FROM {booking_earlyaccess_codes} " .
|
|
"WHERE booking_earlyaccess_code = :code AND booking_eventid = :eid AND booking_earlyaccess_code_avail = 'Y'",
|
|
array(
|
|
':code' => $data['booking_earlyaccess_code'],
|
|
':eid' => $event->eid,
|
|
)
|
|
)->fetchObject();
|
|
//watchdog('booking', "<pre>booking_earlyaccess_feedback_callback code check:\n@info</pre>", array('@info' => print_r( $code_check, true)));
|
|
//no matching code found so return an error
|
|
if (! $code_check) {
|
|
//watchdog('booking', "<pre>booking_earlyaccess_feedback_callback code check did not pass!</pre>");
|
|
return '<div id="booking_earlyaccess_feedback_wrapper"><span style="color:#8c2e0b;font-weight: bold;">' .
|
|
'You have entered an invalid early registration code. If you do not have a code, please wait until normal registrations open.</span><br /><br /></div>';
|
|
}
|
|
//matched a code so let the user know everything is fine
|
|
else {
|
|
//watchdog('booking', "<pre>booking_earlyaccess_feedback_callback code check matched</pre>");
|
|
return '<div id="booking_earlyaccess_feedback_wrapper"><span style="color:#234600;font-weight: bold;">' .
|
|
'Your early registration code has been validated.<br />Please do not share this code, since it will be validated again when you submit the form.</span><br /><br /></div>';
|
|
}
|
|
}
|
|
//no access code entered but we required one
|
|
else {
|
|
return '<div id="booking_earlyaccess_feedback_wrapper"><span style="color:#8c2e0b;font-weight: bold;">' .
|
|
'You must enter an early access code to register now. If you do not have a code, please wait until normal registrations open.</span><br /><br /></div>';
|
|
}
|
|
}
|
|
else {
|
|
return '<div id="booking_earlyaccess_feedback_wrapper"><span style="color:#8c2e0b;font-weight: bold;">Unexpected condition.</span><br /><br /></div>';
|
|
}
|
|
|
|
#fallback
|
|
return '<div id="booking_earlyaccess_feedback_wrapper">If you have been given an early-access code for registration, please enter it below. ' .
|
|
'Without this code, your registration will not be accepted.<br />' .
|
|
'<p><strong>NOTE: each early-access code can only be used once, so don\'t pass it along to your friends!</strong></p></div>';
|
|
}
|
|
|
|
/**
|
|
* Run a number of checks to validate user input
|
|
*/
|
|
function booking_form_validate($form, &$form_state) {
|
|
global $event;
|
|
$node = $form_state['values']['form_id'];
|
|
$data = $form_state['input'];
|
|
//watchdog('booking', '<pre>Booking registration form validation:\n@info</pre>', array('@info' => print_r( $data, true)));
|
|
|
|
//if necessary, validate early access code
|
|
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1 && (isset($data['booking_earlyaccess']) && $data['booking_earlyaccess'] == 1)) {
|
|
if (isset($data['booking_earlyaccess_code']) && $data['booking_earlyaccess_code'] != '') {
|
|
//perform a database lookup against the booking_earlyaccess_codes table
|
|
$code_check = db_query("SELECT cid " .
|
|
"FROM {booking_earlyaccess_codes} " .
|
|
"WHERE booking_earlyaccess_code = :code AND booking_eventid = :eid AND booking_earlyaccess_code_avail = 'Y'",
|
|
array(
|
|
':code' => $data['booking_earlyaccess_code'],
|
|
':eid' => $event->eid,
|
|
)
|
|
)->fetchObject();
|
|
//see if we got a result
|
|
if (! $code_check) {
|
|
form_set_error('booking_earlyaccess_code', t('You have entered an invalid early registration code. If you do not have a code, please wait until normal registrations open.'));
|
|
}
|
|
}
|
|
else {
|
|
form_set_error('booking_earlyaccess_code', t('You must enter an early access code to register now. If you do not have a code, please wait until normal registrations open.'));
|
|
}
|
|
}
|
|
|
|
//in case the date of birth field hasn't been filled out
|
|
watchdog('booking', 'Blank date of birth checking: @info', array(
|
|
'@info' => var_export($data['booking_dob'], TRUE)
|
|
));
|
|
$dob_check = $data['booking_dob']['day'] != '' && $data['booking_dob']['month'] != '' && $data['booking_dob']['year'] != '' ? _datearray_to_ts($data['booking_dob']) : 0;
|
|
|
|
//Verify this is not a duplicate registration
|
|
//try and find the person in the database for this event
|
|
$person = db_query("SELECT person.nid, person.booking_tempid " . "FROM {booking_person} person " . "WHERE booking_firstname = :first AND booking_lastname = :last AND booking_dob = :dob AND booking_eventid = :eid", array(
|
|
':first' => $data['booking_firstname'],
|
|
':last' => $data['booking_lastname'],
|
|
':dob' => $dob_check,
|
|
':eid' => $event->eid
|
|
))->fetchObject();
|
|
|
|
if ($person) {
|
|
if ((strlen($person->booking_tempid) > 0) && (variable_get('booking_use_paypal', 0) == 1)) {
|
|
//they have registered but not paid, so give them the payment link
|
|
form_set_error('booking_firstname', t('Our records indicate that you are part-way through the registration process. Please !click to complete the process.', array(
|
|
'!click' => l('click here', 'confirm/' . $person->booking_tempid)
|
|
)));
|
|
return;
|
|
} else {
|
|
form_set_error('booking_firstname', t('Our records indicate that you have already registered. If you believe this to be incorrect, please !contact using the details provided.', array(
|
|
'!contact' => l('contact us', 'contact-us')
|
|
)));
|
|
}
|
|
}
|
|
|
|
//verify partner id is in the correct format
|
|
if (isset($data['booking_partner_id']) && $data['booking_partner_id'] != '') {
|
|
if (!is_numeric($data['booking_partner_id'])) {
|
|
form_set_error('booking_partner_id', t('You have entered an invalid partner registration id. Please ensure you are using only the registration reference number your partner received via email. If you believe this to be incorrect, please !contact using the details provided.', array(
|
|
'!contact' => l('contact us', 'contact')
|
|
)));
|
|
}
|
|
|
|
//check that the partner exists
|
|
$partner = db_query("SELECT person.nid, person.booking_married " . "FROM {booking_person} person " . "WHERE nid = :nid AND person.booking_married = 'Y'", array(
|
|
':nid' => $data['booking_partner_id']
|
|
))->fetchObject();
|
|
|
|
//watchdog('booking', 'Checking for partner via query: @info', array('@info' => $partner->__toString()));
|
|
|
|
if (!$partner) {
|
|
form_set_error('booking_partner_id', t('Our records do not indicate that the supplied registration ID of your spouse is correct. Please ensure you are using only the number that relates to their registration. If you believe this to be incorrect, please !contact using the details provided.', array(
|
|
'!contact' => l('contact us', 'contact')
|
|
)));
|
|
}
|
|
}
|
|
|
|
//watchdog('booking', 'Form validate data: @info', array('@info' => var_export($data, TRUE)));
|
|
//validate attendee's email address
|
|
$email = (isset($data['booking_email']) ? $data['booking_email'] : $node->booking_email);
|
|
if (strlen(trim($email)) > 0 && !_valid_email_address($email)) {
|
|
form_set_error('booking_email', t('You must enter a valid e-mail address. Please ensure you typed your email address correctly.'));
|
|
}
|
|
|
|
//make sure that the email confirmation field matches the first email address entry
|
|
$email_confirm = (isset($data['booking_email_confirm']) ? $data['booking_email_confirm'] : $node->booking_email);
|
|
$email = preg_replace('/\s+/', '', $email);
|
|
$email_confirm = preg_replace('/\s+/', '', $email_confirm);
|
|
if (strcasecmp($email, $email_confirm) !== 0) {
|
|
form_set_error('booking_email', t('Your email addresses do not match. Please ensure you typed your email address correctly.'));
|
|
}
|
|
|
|
//validate emergency contact's email address
|
|
$guardian_email = (isset($data['booking_guardian_email']) ? $data['booking_guardian_email'] : $node->booking_guardian_email);
|
|
if (strlen(trim($guardian_email)) > 0 && !_valid_email_address($guardian_email)) {
|
|
form_set_error('booking_guardian_email', t('You must enter a valid e-mail address. Please ensure you typed your emergency contact\'s email address correctly.'));
|
|
}
|
|
$guardian_email_confirm = (isset($data['booking_guardian_email_confirm']) ? $data['booking_guardian_email_confirm'] : $node->booking_guardian_email);
|
|
$guardian_email = preg_replace('/\s+/', '', $guardian_email);
|
|
$guardian_email_confirm = preg_replace('/\s+/', '', $guardian_email_confirm);
|
|
if (strcasecmp($guardian_email_confirm, $guardian_email_confirm) !== 0) {
|
|
form_set_error('booking_guardian_email', t('Your emergency contact\'s email addresses do not match. Please ensure you typed your emergency contact\'s email address correctly.'));
|
|
}
|
|
|
|
//if DOB on form is more recent than DOB limit, display validation error
|
|
if ($dob_check > _booking_max_dob_ts()) {
|
|
watchdog('booking', "Attempt to register from !first !last, who is too young (!info) to attend event.", array(
|
|
'!first' => $data['booking_firstname'],
|
|
'!last' => $data['booking_lastname'],
|
|
'!info' => var_export($data['booking_dob'], TRUE)
|
|
));
|
|
form_set_error('booking_dob', t('Unfortunately you are too young to attend !event.', array(
|
|
'!event' => variable_get('booking_event_name', 'this event')
|
|
)));
|
|
}
|
|
|
|
//check the medicare number for people in Australia
|
|
if (variable_get('booking_enable_medicare', 1) == 1 && $data['booking_country'] == 'Australia') {
|
|
//proper validation routine at http://dyball.wordpress.com/2007/12/05/validation-of-medicare-numbers/
|
|
if ((variable_get('booking_enforce_medicare_verification', 1) == 1) && (!_valid_medicare_number($data['booking_medicare']))) {
|
|
form_set_error('booking_medicare', t('You have entered an invalid medicare number. Please check your medicare card and re-enter the number. If you believe this to be incorrect, please !contact.', array(
|
|
'!contact' => l('send us an email', 'mailto:' . variable_get('booking_contact_email') . '?subject=Invalid Medicare Number')
|
|
)));
|
|
} elseif ((variable_get('booking_enforce_medicare_verification', 1) == 0) && (!_valid_medicare_number($data['booking_medicare']))) {
|
|
drupal_set_message(t('You have entered an invalid medicare number. Please ensure you check your medicare card and send us the correct information via !contact.', array(
|
|
'!contact' => l('email', 'mailto:' . variable_get('booking_contact_email') . '?subject=Invalid Medicare Number')
|
|
)), 'error', FALSE);
|
|
}
|
|
}
|
|
|
|
//verify state information with the new few checks
|
|
|
|
//make sure state field is not blank
|
|
if ($data['booking_state'] == '_blank_') {
|
|
form_set_error('booking_state', t('You must enter your State in the address section of the Contact details. ' . 'Please choose a state of Other and specify N/A if your country does not have states, or choose NZ if you reside in New Zealand.'));
|
|
}
|
|
|
|
//verify international address has updated the state field
|
|
if ((strcasecmp($data['booking_country'], 'New Zealand') == 0) && (strcasecmp($data['booking_state'], 'NZ') !== 0)) {
|
|
form_set_error('booking_state', t('You have indicated you reside in New Zealand. Please select NZ as your state.'));
|
|
} elseif ((strcasecmp($data['booking_country'], 'Australia') !== 0) && (strcasecmp($data['booking_state'], 'Other') !== 0) && (strcasecmp($data['booking_state'], 'NZ') !== 0)) {
|
|
form_set_error('booking_state', t('You must enter your State in the address section of the Contact details. Please choose a state of Other and specify N/A if your country does not have states.'));
|
|
}
|
|
|
|
//verify that a state has been entered if "Other" was selected
|
|
if (($data['booking_state'] == 'Other') && ($data['booking_other_state'] == ''))
|
|
form_set_error('booking_other_state', t('You must enter your State in the address section of the Contact details. Please put N/A if your country does not have states.'));
|
|
|
|
//verify passport number
|
|
if (variable_get('booking_enable_passport', 0) == 1 && $data['booking_country'] == 'Australia') {
|
|
if (($data['booking_passport_num'] != '') && (!_valid_passport_number($data['booking_passport_num']))) {
|
|
form_set_error('booking_passport_num', t('You have entered an invalid passport number. Please check your passport and re-enter the number. ' . 'If you believe this to be incorrect, please !contact.', array(
|
|
'!contact' => l('send us an email', 'mailto:' . variable_get('booking_contact_email') . '?subject=Invalid Passport Number')
|
|
)));
|
|
}
|
|
}
|
|
|
|
//check at least one phone number has been entered
|
|
if (($data['booking_phone'] == '') && ($data['booking_mobile'] == ''))
|
|
form_set_error('booking_mobile', t('You must enter at least one phone number, either a mobile phone or a home phone number.'));
|
|
if (($data['booking_phone'] != '') && (!_valid_phone_number($data['booking_phone'])))
|
|
form_set_error('booking_phone', t('You have entered an invalid home phone number.'));
|
|
if (($data['booking_mobile'] != '') && (!_valid_phone_number($data['booking_mobile'])))
|
|
form_set_error('booking_mobile', t('You have entered an invalid mobile phone number.'));
|
|
|
|
//verify an australian mobile number is entered correctly if applicable
|
|
if (($data['booking_mobile'] != '') && ($data['booking_country'] == 'Australia') && (!_valid_australian_mobile_number($data['booking_mobile'])))
|
|
form_set_error('booking_mobile', t('You have entered an invalid mobile phone number.'));
|
|
|
|
//validate guardian phone number
|
|
if ($data['booking_country'] == 'Australia') {
|
|
if (!_valid_australian_mobile_number($data['booking_guardian_phone'])) {
|
|
form_set_error('booking_guardian_phone', t('You have entered an invalid contact phone number for your emergency contact.'));
|
|
}
|
|
} else {
|
|
if (!_valid_phone_number($data['booking_guardian_phone'])) {
|
|
form_set_error('booking_guardian_phone', t('You have entered an invalid contact phone number for your emergency contact.'));
|
|
}
|
|
}
|
|
|
|
//verify alternate guardian phone number
|
|
if (($data['booking_guardian_phone_alt'] != '') && (!_valid_phone_number($data['booking_guardian_phone_alt']))) {
|
|
form_set_error('booking_guardian_phone_alt', t('You have entered an invalid alternate contact phone number for your emergency contact.'));
|
|
}
|
|
|
|
//check the terms and conditions have been agreed to. Do this one last so it stands out more
|
|
if ($data['booking_agreement'] == 0) {
|
|
form_set_error('booking_agreement', t('You must read and agree with the aims and expectations prior to submitting this form.'));
|
|
}
|
|
|
|
if (variable_get('booking_enable_previous_studyweeks', 0) == 1 && $data['booking_prev_sw_count'] == '') {
|
|
form_set_error('booking_prev_sw_count', t('You must select the number of study weeks that you\'ve previously attended.'));
|
|
}
|
|
|
|
//if there are any errors then log the data the user entered so we can check it later
|
|
if (form_get_errors()) {
|
|
watchdog('booking', "<pre>Detected validation error(s):\n@errors\n\n User data:\n@info</pre>", array(
|
|
'@info' => print_r($data, true),
|
|
'@errors' => print_r(form_get_errors(), true)
|
|
));
|
|
}
|
|
|
|
}
|
|
/**
|
|
* Create the new node for this booking
|
|
*/
|
|
function booking_form_submit($form, &$form_state)
|
|
{
|
|
global $event;
|
|
|
|
$values = $form_state['input'];
|
|
|
|
//do some preprocessing on input
|
|
//convert names from whatever case they're in to Title Case
|
|
$values['booking_firstname'] = _booking_ucname($values['booking_firstname']);
|
|
$values['booking_lastname'] = _booking_ucname($values['booking_lastname']);
|
|
|
|
//strip any emojis from user input
|
|
if (variable_get('booking_enable_emoji_removal', 1) == 1) {
|
|
foreach ($values as $key => $value) {
|
|
$values[$key] = _booking_remove_emoji($value);
|
|
}
|
|
watchdog('booking_debug', "<pre>Form values after emoji removal:\n@info</pre>", array('@info' => print_r($values, TRUE)));
|
|
}
|
|
|
|
//get DOB from form
|
|
$dob = _datearray_to_ts($values['booking_dob']);
|
|
|
|
//retrieve an object with the booking price
|
|
$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();
|
|
$node = node_type_set_defaults();
|
|
$title = t('!event registration: !name', array(
|
|
'!event' => $event->booking_eventname,
|
|
'!name' => $values['booking_firstname'] . ' ' . $values['booking_lastname']
|
|
));
|
|
//$title = _booking_remove_emoji($title);
|
|
$node->title = $title;
|
|
$node->type = 'booking';
|
|
$node->status = 1; // set published to true
|
|
$node->promote = 0; // prevent display on front page
|
|
$node->language = LANGUAGE_NONE;
|
|
$node->created = REQUEST_TIME;
|
|
$node->changed = REQUEST_TIME;
|
|
|
|
$node->booking_firstname = ucwords(trim($values['booking_firstname']));
|
|
$node->booking_lastname = ucwords(trim($values['booking_lastname']));
|
|
$node->booking_gender = $values['booking_gender'];
|
|
$node->booking_dob = $dob;
|
|
$node->booking_status = 0; //zero means not yet coming. Only change to 1 when a payment is made
|
|
|
|
//payment details
|
|
$node->booking_payment_id = $values['booking_payment_id'];
|
|
|
|
//contact details
|
|
$node->booking_street = ucwords($values['booking_street']);
|
|
$node->booking_suburb = ucwords($values['booking_suburb']);
|
|
$node->booking_postcode = $values['booking_postcode'];
|
|
$node->booking_country = $values['booking_country'];
|
|
$node->booking_phone = $values['booking_phone'];
|
|
$node->booking_mobile = $values['booking_mobile'];
|
|
$node->booking_email = strtolower(trim($values['booking_email']));
|
|
$node->booking_ecclesia = ucwords($values['booking_ecclesia']);
|
|
$node->booking_baptised = ($values['booking_baptised'] == 1 ? 'Y' : 'N');
|
|
$node->booking_married = empty($values['booking_married']) ? 'N' : ($values['booking_married'] == 1 ? 'Y' : 'N');
|
|
$node->booking_partner_name = empty($values['booking_partner_name']) ? '' : ucwords($values['booking_partner_name']);
|
|
$node->booking_partner_id = empty($values['booking_partner_id']) ? 0 : $values['booking_partner_id'];
|
|
$node->booking_bf_gf_nid = empty($values['booking_bf_gf_nid']) ? 0 : $values['booking_bf_gf_nid'];
|
|
$node->booking_keepseparate_id = empty($values['booking_keepseparate_id']) ? 0 : $values['booking_keepseparate_id'];
|
|
|
|
//allow for user-entered value if the state is not already listed
|
|
if ($values['booking_state'] == 'Other') {
|
|
$node->booking_state = $values['booking_other_state'];
|
|
} else {
|
|
$node->booking_state = ucwords($values['booking_state']);
|
|
}
|
|
|
|
//emergency contact info
|
|
$node->booking_guardian_name = $values['booking_guardian_name'];
|
|
$node->booking_guardian_type = $values['booking_guardian_type'];
|
|
$node->booking_guardian_email = $values['booking_guardian_email'];
|
|
$node->booking_guardian_phone = $values['booking_guardian_phone'];
|
|
$node->booking_guardian_phone_alt = $values['booking_guardian_phone_alt'];
|
|
$node->booking_medicare = empty($values['booking_medicare']) ? 0 : $values['booking_medicare'];
|
|
|
|
//fields that may or may not have been present in the initial form
|
|
$node->booking_barcode = empty($values['booking_barcode']) ? '' : $values['booking_barcode'];
|
|
$node->booking_qrcode_url = empty($values['booking_qrcode_url']) ? '' : $values['booking_qrcode_url'];
|
|
$node->booking_luckynum = empty($values['booking_luckynum']) ? 0 : $values['booking_luckynum'];
|
|
$node->booking_random_facts = empty($values['booking_random_facts']) ? '' : $values['booking_random_facts'];
|
|
$node->booking_welfare_required = empty($values['booking_welfare_required']) ? 'N' : ($values['booking_welfare_required'] == 1 ? 'Y' : 'N');
|
|
$node->booking_committee_member = empty($values['booking_committee_member']) ? 'N' : ($values['booking_committee_member'] == 1 ? 'Y' : 'N');
|
|
$node->booking_payment_complete = empty($values['booking_payment_complete']) ? 'N' : ($values['booking_payment_complete'] == 1 ? 'Y' : 'N');
|
|
$node->booking_refund_processed = empty($values['booking_refund_processed']) ? 'N' : ($values['booking_refund_processed'] == 1 ? 'Y' : 'N');
|
|
$node->booking_dependant_children = empty($values['booking_dependant_children']) ? 'N' : ($values['booking_dependant_children'] == 1 ? 'Y' : 'N');
|
|
$node->booking_refund_due = empty($values['booking_refund_due']) ? 0 : $values['booking_refund_due'];
|
|
$node->booking_help_music = empty($values['booking_help_music']) ? '' : $values['booking_help_music'];
|
|
$node->booking_help_meditations = empty($values['booking_help_meditations']) ? '' : $values['booking_help_meditations'];
|
|
$node->booking_help_praying = empty($values['booking_help_praying']) ? '' : $values['booking_help_praying'];
|
|
$node->booking_help_reading = empty($values['booking_help_reading']) ? 'N' : ($values['booking_help_reading'] == 1 ? 'Y' : 'N');
|
|
$node->booking_help_chairing = empty($values['booking_help_chairing']) ? 'N' : ($values['booking_help_chairing'] == 1 ? 'Y' : 'N');
|
|
$node->booking_help_readgroup_lead = empty($values['booking_help_readgroup_lead']) ? 'N' : ($values['booking_help_readgroup_lead'] == 1 ? 'Y' : 'N');
|
|
$node->booking_help_discussgroup_lead = empty($values['booking_help_discussgroup_lead']) ? 'N' : ($values['booking_help_discussgroup_lead'] == 1 ? 'Y' : 'N');
|
|
$node->booking_firstaid = empty($values['booking_firstaid']) ? 'N' : ($values['booking_firstaid'] == 1 ? 'Y' : 'N');
|
|
$node->booking_nurse = empty($values['booking_nurse']) ? 'N' : ($values['booking_nurse'] == 1 ? 'Y' : 'N');
|
|
$node->booking_lifesaver = empty($values['booking_lifesaver']) ? 'N' : ($values['booking_lifesaver'] == 1 ? 'Y' : 'N');
|
|
$node->booking_doctor = empty($values['booking_doctor']) ? 'N' : ($values['booking_doctor'] == 1 ? 'Y' : 'N');
|
|
$node->booking_dietary = empty($values['booking_dietary']) ? 'N/A' : $values['booking_dietary'];
|
|
$node->booking_mission_experience_details = empty($values['booking_mission_experience_details']) ? 'N/A' : $values['booking_mission_experience_details'];
|
|
$node->booking_has_mission_experience = empty($values['booking_has_mission_experience']) ? 'N' : ($values['booking_has_mission_experience'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_builder = empty($values['booking_skills_builder']) ? 'N' : ($values['booking_skills_builder'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_cooking = empty($values['booking_skills_cooking']) ? 'N' : ($values['booking_skills_cooking'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_childminding = empty($values['booking_skills_childminding']) ? 'N' : ($values['booking_skills_childminding'] == 1 ? 'Y' : 'N');
|
|
$node->booking_skills_language = empty($values['booking_skills_language']) ? 'N' : ($values['booking_skills_language'] == 1 ? 'Y' : 'N');
|
|
$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_id = empty($values['booking_earlyaccess_code']) ? 0 : $earlyaccess_query->cid;
|
|
$node->booking_song_choice = empty($values['booking_song_choice']) ? '' : $values['booking_song_choice'];
|
|
$node->booking_freestyle_text = empty($values['booking_freestyle_text']) ? '' : $values['booking_freestyle_text'];
|
|
$node->booking_prev_sw_count = empty($values['booking_prev_sw_count']) ? '0' : $values['booking_prev_sw_count'];
|
|
|
|
//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'];
|
|
$comment = empty($values['booking_comment_field']) ? '' : $values['booking_comment_field'];
|
|
$node->booking_medical_conditions = str_replace(PHP_EOL, '', $medical);
|
|
$node->booking_comment_field = str_replace(PHP_EOL, '', $comment);
|
|
|
|
//potential fields for future
|
|
//$node->booking_payment_method = $payment_method;
|
|
$node->booking_room_mate1 = empty($values['booking_room_mate1']) ? '' : $values['booking_room_mate1'];
|
|
$node->booking_room_mate2 = empty($values['booking_room_mate2']) ? '' : $values['booking_room_mate2'];
|
|
$node->booking_shirt_size = empty($values['booking_shirt_size']) ? 'N/A' : $values['booking_shirt_size'];
|
|
|
|
//fields only configured by admin
|
|
$node->booking_readinggroup = !empty($values['booking_readinggroup']) ? $values['booking_readinggroup'] : '';
|
|
$node->booking_timestamp = REQUEST_TIME;
|
|
|
|
//internal fields
|
|
$tempid = _booking_uuidSecure();
|
|
$node->booking_tempid = $tempid;
|
|
$node->booking_eventid = $event->eid;
|
|
$node->booking_amount_paid = 0;
|
|
$node->booking_total_pay_reqd = $payment_total_price->booking_price;
|
|
|
|
//watchdog('booking', 'Node data: @info', array('@info' => var_export($node, TRUE)));
|
|
$foo = node_submit($node);
|
|
//watchdog('booking', 'Node data after submit: @info', array('@info' => var_export($foo, TRUE)));
|
|
$blah = node_save($foo);
|
|
//watchdog('booking', 'Node data after save: @info', array('@info' => var_export($blah, TRUE)));
|
|
|
|
//post submission triggers
|
|
_booking_form_submit_post_triggers($node);
|
|
|
|
//redirect the user to the confirmation page
|
|
$form_state['redirect'] = array(
|
|
'confirm/' . $tempid
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Perform any workflow actions after the registration form submission
|
|
*/
|
|
function _booking_form_submit_post_triggers($node)
|
|
{
|
|
global $event;
|
|
|
|
//mark early access code as being used
|
|
if (variable_get('booking_enable_earlyaccess_codes', 0) == 1 && $node->booking_earlyaccess_code_id != '') {
|
|
watchdog('booking_debug', "<pre>Early access code used, node info below\n@info</pre>", array('@info' => print_r($node, true)));
|
|
|
|
//update the database to mark the code as being unavailable
|
|
db_update('booking_earlyaccess_codes')->fields(array(
|
|
'booking_earlyaccess_code_avail' => 'N',
|
|
'booking_earlyaccess_code_nid' => $node->nid,
|
|
))->condition('cid', $node->booking_earlyaccess_code_id)->execute();
|
|
}
|
|
|
|
//do these triggers really do anything? The partner id and bf/gf id won't be set in initial submit
|
|
|
|
//if booking_partner_id is set, make sure the nid it refers to has this node as its booking_partner_id
|
|
if ($node->booking_partner_id != 0) {
|
|
$partner = db_query("Select booking_partner_id from {booking_person} where nid = :nid", array(
|
|
':nid' => $node->booking_partner_id
|
|
))->fetchObject();
|
|
if ($partner->booking_partner_id == 0) {
|
|
watchdog('booking', 'Updating partner node !partner to refer to this node !nid', array(
|
|
'!partner' => $node->booking_partner_id,
|
|
'!nid' => $node->nid
|
|
));
|
|
//update the partner id of the partner to refer to this node
|
|
db_update('booking_person')->fields(array(
|
|
'booking_partner_id' => $node->nid
|
|
))->condition('nid', $node->booking_partner_id)->execute();
|
|
}
|
|
}
|
|
|
|
//repeat the process above for bf/gf
|
|
if ($node->booking_bf_gf_nid != 0) {
|
|
$partner = db_query("Select booking_bf_gf_nid from {booking_person} where nid = :nid", array(
|
|
':nid' => $node->booking_bf_gf_nid
|
|
))->fetchObject();
|
|
if ($partner->booking_bf_gf_nid == 0) {
|
|
watchdog('booking', 'Updating bf/gf node !partner to refer to this node !nid', array(
|
|
'!partner' => $node->booking_bf_gf_nid,
|
|
'!nid' => $node->nid
|
|
));
|
|
//update the partner id of the partner to refer to this node
|
|
db_update('booking_person')->fields(array(
|
|
'booking_bf_gf_nid' => $node->nid
|
|
))->condition('nid', $node->booking_bf_gf_nid)->execute();
|
|
}
|
|
}
|
|
|
|
//check whether we should send an automatic email even though they haven't paid yet
|
|
if (variable_get('booking_auto_confirm_email', 0) == 1) {
|
|
//send the person an email
|
|
_booking_registration_email($node->nid, FALSE, FALSE);
|
|
} else {
|
|
//just send a notification email
|
|
_booking_regn_notifyonly_email($node, FALSE);
|
|
}
|
|
} |