/**
  * Login form handler method
  *
  * This method is called when the user clicks on "Log in"
  *
  * @param array $data Submitted data
  */
 public function dologin($data)
 {
     if ($this->performLogin($data)) {
         $this->logInUserAndRedirect($data);
     } else {
         if (array_key_exists('Email', $data)) {
             Session::set('SessionForms.MemberLoginForm.Email', $data['Email']);
             Session::set('SessionForms.MemberLoginForm.Remember', isset($data['Remember']));
         }
         if (isset($_REQUEST['BackURL'])) {
             $backURL = $_REQUEST['BackURL'];
         } else {
             $backURL = null;
         }
         if ($backURL) {
             Session::set('BackURL', $backURL);
         }
         // Show the right tab on failed login
         $loginLink = Store_OrderController::get_link() . "/place";
         if ($backURL) {
             $loginLink .= '?BackURL=' . urlencode($backURL);
         }
         $this->controller->redirect($loginLink . '#' . $this->FormName() . '_tab');
     }
 }
 /** 
  * FORM ACTION /createaccount
  * Create a new record for the customer in to the Customer DataObject, 
  * send them a confirmation email, sign their new account in to the
  * site and redirect them to stage two of the order process.
  *
  * @return null.
  */
 public function createaccount($data, $form)
 {
     /* Save Data */
     $customer = new Customer();
     $form->saveInto($customer);
     $customer->write();
     /* TODO - Send Confirmation Email */
     /* If the new customer can be signed in, redirect to order stage two. */
     if (Customer::get_one("Customer", "(`Email`='" . $customer->Email . "')")->logIn()) {
         return $this->redirect(Store_OrderController::get_link() . "/place/two");
     } else {
         $form->sessionMessage("An unexpected error occurred, please try again.", "bad");
         return $this->redirectBack();
     }
 }
 /**
  * ACTION /placeorder
  * Redirect the user to /order/place action on Store_Controller to pickup order process.
  */
 public function placeorder($data)
 {
     return $this->redirect(Store_OrderController::get_link() . "/place");
 }