{
$view = 'register';
$emailError = '';
- // Create dummy reg array
+
+ // Create dummy reg array $reg for the template data.
$reg = array(
'fname' => '',
'lname' => '',
'country' => '',
);
- // Check for $option
+ // Check for $option (Filtered)
$option = ( isset( $_REQUEST['option'] ) ) ? filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING) : null;
switch ( $option ) {
case 'submit':
+ // Filter the form variables for use in db insert.
$email = filter_var( $_REQUEST['email'], FILTER_VALIDATE_EMAIL );
$password = filter_var( $_REQUEST['password'], FILTER_SANITIZE_STRING );
$fname = filter_var( $_REQUEST['fname'], FILTER_SANITIZE_STRING );
$zip = filter_var( $_REQUEST['zip'], FILTER_SANITIZE_STRING );
$country = filter_var( $_REQUEST['country'], FILTER_SANITIZE_STRING );
if ( $email ) {
+ // Check to see if we have an account with that email already.
$accountId = $this->wpdb->get_var(
$this->wpdb->prepare(
"SELECT id
if ( $accountId ) {
// Already an account with that email address
$emailError = 'Already an account with that email address!';
+ // Setup $reg variable for the template form data.
$reg = array(
'fname' => $fname,
'lname' => $lname,
'fname' => $fname,
'lname' => $lname,
);
+ // Redirect to the start of registrations.
wp_redirect( GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/' );
}
break;
public function modelAction($actionData = false)
{
-
+ // Clear the headers for wordpress.
nocache_headers();
+
+ // Setup default variables
$loginAccount = '';
$cartId = false;
$haveCart = false;
$isNewCart = false;
$regEventFirstTime = false;
- // Have Backbone.js loaded
+ // Setup scripts array for needed js files.
$scripts = array(
'regApp' => 'js/frontRegApp.js',
);
+
+ // Loop through our scripts array and register them.
foreach ( $scripts as $scriptName => $scriptPath ) {
wp_register_script(
$scriptName,
true
);
}
+ // Load Backbone.sj and jQuery.
wp_enqueue_script( array( 'backbone', 'jquery' ) );
+
+ // Load our scripts.
wp_enqueue_script( array_keys( $scripts ) );
$regEvent = array();
$eventRegID = false;
}
}
+
+ // Set the $view to registration
$view = 'registration';
// Load cart support class
// Get the RegEvent entry
$this->postProcAddedEventData = true;
$regEvent = $this->getEventConfig( $eventRegID, true, false, true );
- // echo '<pre>$regEvent: ' . print_r( $regEvent, true ) . '</pre>';
+
if ( $regEvent ) {
if ( is_array( $regEvent['recurrences'] ) && count( $regEvent['recurrences'] ) ) {
+ // Loop through all of the event recurrences to pull out times.
foreach ($regEvent['recurrences'] as $k=>$v) {
+ // Set the $first time.
$first = current($v['times']);
- // $first = current($v['times']);
- // echo '<pre>$first: ' . print_r( $first, true ) . '</pre>';
+ // Set the $last time
$last = end($v['times']);
+
+ // Pass first and last times into regEvent
$regEvent['recurrences'][$k]['first_time'] = $first;
$regEvent['recurrences'][$k]['lastTime'] = $last;
if ($v['times'] && count($v['times']) > 0) {
}
}
+ // Create an $event array with the event data.
$event = array(
'id' => $regEvent['id'],
'event' => $regEvent['event'],
'terms' => $regEvent['terms'],
);
- // echo '<pre>$event: ' . print_r( $event, true ) . '</pre>';
break;
}
$jsonClasses = array();
if ( isset( $regEvent['reg_class'] ) && is_array( $regEvent['reg_class'] ) ) {
+
+ // Loop through the $regEvent['reg_class'] array to build $rClass array
foreach ( $regEvent['reg_class'] as $rClass ) {
// Pull the rate data
if ( isset( $rClass['reg_rate'] ) && is_array( $rClass['reg_rate'] ) ) {
$jsonClasses[] = json_encode( $rClass, JSON_NUMERIC_CHECK );
}
}
+
+ // Build the regClass JSON for the template.
$regClassJSON = '[' . implode( ',', $jsonClasses ) . ']';
$regCartJSON = json_encode( $cart );
// check to see if there's a user logged in
if ( isset( $_SESSION['LoginAccount'] ) && filter_var( $_SESSION['LoginAccount']['id'], FILTER_VALIDATE_INT ) ) {
+ // Setup JSON for the loginAccount.
$loginAccount = json_encode( $_SESSION['LoginAccount'], JSON_NUMERIC_CHECK );
}
// Looping through to grab out registrants from the cart.
if ( isset( $cart['events'] ) && is_array( $cart['events'] ) ) {
+
+ // Loop through events array.
foreach ( $cart['events'] as $rEvent ) {
if ( isset( $rEvent['classes'] ) && is_array( $rEvent['classes'] ) ) {
+
+ // Loop through classes array
foreach ( $rEvent['classes'] as $class ) {
if ( isset( $class['rates'] ) && is_array( $class['rates'] ) ) {
+
+ // Loop through rates array
foreach ( $class['rates'] as $rate ) {
if ( isset( $rate['registrants'] ) && is_array( $rate['registrants'] ) ) {
+
+ // Loop through registrants array.
foreach ( $rate['registrants'] as $registrant ) {
$accountData = array();
// If there's an account id get data for the account.
),
ARRAY_A
);
- // echo '<pre>$accountData: ' . print_r( $accountData , true ) . '</pre>';
}
// Need to know the class id for the registrant
);
$registrant['reg_time_text'] = $regTimeText;
}
+
+ // Setup the registrant for this level.
$registrant['class_id'] = $classId;
$registrant['email'] = $email;
$registrant['validated'] = $accountData['validated'];
$registrant['state'] = $accountData['state'];
$registrant['zip'] = $accountData['zip'];
$registrant['country'] = $accountData['country'];
- // echo '<pre>$registrant: ' . print_r( $registrant, true ) . '</pre>';
$registrants[] = $registrant;
- }
+ } // - End loop through for registrants array.
}
- }
+
+ } // - End loop through rates.
}
- }
+
+ } // - End loop through classes.
}
- }
+
+ } // - End loop through events.
}
- // echo '<pre>$registrants: ' . print_r( $registrants, true ) . '</pre>';
-// echo '<pre>$regEvent: ' . print_r( $regEvent, true ) . '</pre>';
// Compile template data
$templateData = array(
'haveCart' => $haveCart,
'regUrl' => GLM_MEMBERS_REGISTRATIONS_SITE_BASE_URL.$this->config['settings']['canonical_reg_page'].'/',
'loggedIn' => ( isset( $_SESSION['LoginAccount'] ) ) ? $_SESSION['LoginAccount']: false,
);
- // Return status, any suggested view, and any data to controller
+
+ // Return status, any suggested view, and any data to controller
return array(
'status' => true,
'modelRedirect' => false,