diff --git a/booking.admin.inc b/booking.admin.inc index 9e469f5..1c128cd 100644 --- a/booking.admin.inc +++ b/booking.admin.inc @@ -607,6 +607,17 @@ function booking_admin() { ) ) ); + + $form['regn_options']['booking_enable_earlyaccess_codes'] = array( + '#type' => 'radios', + '#title' => t('Allow early access to registration form with unique code?'), + '#description' => t('Select whether to enable the feature that will allow early registrations with a unique code. Note this feature is still under development.'), + '#options' => array( + 0 => t('No'), + t('Yes') + ), + '#default_value' => variable_get('booking_enable_earlyaccess_codes', 0) + ); $form['management'] = array( '#type' => 'fieldset', diff --git a/booking.import_data.inc b/booking.import_data.inc index 45e45ef..d846411 100644 --- a/booking.import_data.inc +++ b/booking.import_data.inc @@ -1,6 +1,4 @@ array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), 'booking_eventid' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE), - 'booking_tempid' => array('type' => 'varchar', 'length' => '40', 'not null' => FALSE), + 'booking_tempid' => array('type' => 'varchar', 'length' => '40', 'not null' => FALSE), + 'booking_earlyaccess_code_id' => array('type' => 'int', 'length' => '11', 'default' => 0, 'not null' => FALSE), 'booking_timestamp' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '11'), 'booking_firstname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), 'booking_lastname' => array('type' => 'varchar', 'length' => '50', 'not null' => TRUE), @@ -988,5 +989,16 @@ function booking_schema() { 'primary key' => array('mid'), ); + //This lists all the early registration access codes + $schema['booking_regn_earlyaccess_codes'] = array( + 'fields' => array( + 'cid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_eventid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'disp-width' => '10'), + 'booking_regn_earlyaccess_code' => array('type' => 'varchar', 'length' => '500', 'not null' => FALSE), + 'booking_regn_earlyaccess_code_avail' => array('type' => 'varchar', 'length' => '1', 'not null' => FALSE), + ), + 'primary key' => array('cid'), + ); + return $schema; } diff --git a/booking.misc.inc b/booking.misc.inc new file mode 100644 index 0000000..527935c --- /dev/null +++ b/booking.misc.inc @@ -0,0 +1,50 @@ + $event->eid)); + $attendees = $attendee_query->fetchAll(); + + //assuming there's less than 900 people, generate numbers within that range and shuffle the order + $numbers = range(100,750); + shuffle($numbers); + + foreach ($attendees as $attendee) + { + $luckynum = $numbers[$i++]; + + drupal_set_message(t('Updating user !id to have lucky number !num.', + array('!id' => $attendee->nid, '!num' => $luckynum))); + + //run an update query + db_update('booking_person') + ->fields(array ( + 'booking_luckynum' => $luckynum, + )) + ->condition('nid', $attendee->nid) + ->execute(); + + } + drupal_set_message(t('Finished.')); + + return t("

Generate Lucky Numbers

"); +} + +/** + * Function to populate the booking_regn_earlyaccess_codes table used for storing and checking early registration access codes + */ +function booking_generate_earlyregn_codes() { + global $event; +} \ No newline at end of file diff --git a/booking.module b/booking.module index c1e3636..07d93a0 100644 --- a/booking.module +++ b/booking.module @@ -71,6 +71,8 @@ module_load_include('inc', 'booking', 'booking.rooms_allocate'); module_load_include('inc', 'booking', 'booking.rooms_admin'); // Load the include for stripe payments module_load_include('inc', 'booking', 'booking.stripe'); +// Load the include for miscellaneous functions +module_load_include('inc', 'booking', 'booking.misc'); function booking_init() { date_default_timezone_set(date_default_timezone(FALSE)); @@ -946,46 +948,6 @@ function booking_requirements($phase) { return $requirements; } - -/** - * Function for generating the "lucky number" to be used on the lanyard - * @todo move this into a better place. It doesn't belong here - */ -function booking_generate_luckynumbers() { - global $event; - - $i = 0; - - //query for the mappings relating to $readinggroup_studygroup_id - $attendee_query = db_query("SELECT * FROM {booking_person} WHERE booking_eventid = :eid", - array(':eid' => $event->eid)); - $attendees = $attendee_query->fetchAll(); - - //assuming there's less than 900 people, generate numbers within that range and shuffle the order - $numbers = range(100,750); - shuffle($numbers); - - foreach ($attendees as $attendee) - { - $luckynum = $numbers[$i++]; - - drupal_set_message(t('Updating user !id to have lucky number !num.', - array('!id' => $attendee->nid, '!num' => $luckynum))); - - //run an update query - - db_update('booking_person') - ->fields(array ( - 'booking_luckynum' => $luckynum, - )) - ->condition('nid', $attendee->nid) - ->execute(); - - } - drupal_set_message(t('Finished.')); - - return t("

Generate Lucky Numbers

"); -} /* function booking_form_user_profile_form_alter(&$form, &$form_state) { // Add your own function to the array of validation callbacks diff --git a/booking.regn_form.inc b/booking.regn_form.inc index f1d3ae5..af70e76 100644 --- a/booking.regn_form.inc +++ b/booking.regn_form.inc @@ -116,7 +116,16 @@ function booking_form($node, &$form_state, $inserting = FALSE) $payment_type_options[$row->pid] = $row->booking_price_descrip . ' ($' . $price . ')'; } - //form starts here + // ------- form starts here --------- + + //add new feature for early registration access + if ($inserting == TRUE && variable_get('booking_enable_earlyaccess_codes', 1) == 1) { + $form['early-access'] = array( + '#type' => 'fieldset', + '#title' => 'Early Registration Code' + ); + } + $form['your-details'] = array( '#type' => 'fieldset', '#title' => 'Personal details' diff --git a/booking.variety.inc b/booking.variety.inc index 6b8a953..aa61804 100644 --- a/booking.variety.inc +++ b/booking.variety.inc @@ -3,6 +3,7 @@ /** * @file * Admin pages for configuring a variety session + * NOTE: This feature is not complete and probably never will be */ function booking_variety_admin()