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' => '
NOTE: each early-access code can only be used once, so don\'t pass it along to your friends!
Retreiving help area options:\n@info", 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.
booking_earlyaccess_feedback_callback validation:\n@info', 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', '
booking_earlyaccess_feedback_callback first if statement passed'); if (isset($data['booking_earlyaccess_code']) && $data['booking_earlyaccess_code'] != '') { //watchdog('booking', '
booking_earlyaccess_feedback_callback second if statement passed'); //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', "
booking_earlyaccess_feedback_callback code check:\n@info", array('@info' => print_r( $code_check, true))); //no matching code found so return an error if (! $code_check) { //watchdog('booking', "
booking_earlyaccess_feedback_callback code check did not pass!"); return '
booking_earlyaccess_feedback_callback code check matched"); return '
NOTE: each early-access code can only be used once, so don\'t pass it along to your friends!
Booking registration form validation:\n@info', 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 there are any errors then log the data the user entered so we can check it later if (form_get_errors()) { watchdog('booking', "
Detected validation error(s):\n@errors\n\n User data:\n@info", array( '@info' => print_r($data, true), '@errors' => print_r(form_get_errors(), true) )); } } 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', "
Form values after emoji removal:\n@info", 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 //passport details /* $node->booking_passport_num = empty($values['booking_passport_num']) ? '' : $values['booking_passport_num']; $node->booking_passport_issue_location = empty($values['booking_passport_issue_location']) ? '' : $values['booking_passport_issue_location']; $node->booking_passport_issue_name = empty($values['booking_passport_issue_name']) ? '' : $values['booking_passport_issue_name']; $node->booking_passport_expiry_date = empty($values['booking_passport_expiry_date']) ? '0' : _datearray_to_ts($values['booking_passport_expiry_date']); $node->booking_destination_country = empty($values['booking_destination_country']) ? '' : $values['booking_destination_country']; $node->booking_travel_insurance = empty($values['booking_travel_insurance']) ? '' : $values['booking_travel_insurance']; //flight info, which may not be present $node->booking_outflight_bookingnum = empty($values['booking_outflight_bookingnum']) ? '' : $values['booking_outflight_bookingnum']; $node->booking_outflight_flightnum = empty($values['booking_outflight_flightnum']) ? '' : $values['booking_outflight_flightnum']; $node->booking_outflight_origin = empty($values['booking_outflight_origin']) ? '' : $values['booking_outflight_origin']; $node->booking_outflight_origin_ts = empty($values['booking_outflight_origin_ts']) ? '0' : _datetime_array_to_ts($values['booking_outflight_origin_ts']); $node->booking_outflight_connecting_flightnum = empty($values['booking_outflight_connecting_flightnum']) ? '' : $values['booking_outflight_connecting_flightnum']; $node->booking_outflight_destination = empty($values['booking_outflight_destination']) ? '' : $values['booking_outflight_destination']; $node->booking_outflight_destination_ts = empty($values['booking_outflight_destination_ts']) ? '0' : _datetime_array_to_ts($values['booking_outflight_destination_ts']); $node->booking_rtrnflight_bookingnum = empty($values['booking_rtrnflight_bookingnum']) ? '' : $values['booking_rtrnflight_bookingnum']; $node->booking_rtrnflight_flightnum = empty($values['booking_rtrnflight_flightnum']) ? '' : $values['booking_rtrnflight_flightnum']; $node->booking_rtrnflight_origin = empty($values['booking_rtrnflight_origin']) ? '' : $values['booking_rtrnflight_origin']; $node->booking_rtrnflight_origin_ts = empty($values['booking_rtrnflight_origin_ts']) ? '0' : _datetime_array_to_ts($values['booking_rtrnflight_origin_ts']); $node->booking_rtrnflight_connecting_flightnum = empty($values['booking_rtrnflight_connecting_flightnum']) ? '' : $values['booking_rtrnflight_connecting_flightnum']; $node->booking_rtrnflight_destination = empty($values['booking_rtrnflight_destination']) ? '' : $values['booking_rtrnflight_destination']; $node->booking_rtrnflight_destination_ts = empty($values['booking_rtrnflight_destination_ts']) ? '0' : _datetime_array_to_ts($values['booking_rtrnflight_destination_ts']); */ //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_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']; //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', "
Early access code used, node info below\n@info", 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); } }