Exemplo n.º 1
0
 /**
  * Performs functionality to process a new user account during checkout
  *
  * @return bool
  */
 protected function process_new_account(Model_Vendo_User &$user, $user_post = array(), Model_Vendo_Address $address)
 {
     $validate = Validate::factory(array('password' => arr::get($user_post['password'], 'password'), 'repeat_password' => arr::get($user_post['repeat_password'], 'repeat_password')))->rule('repeat_password', 'not_empty')->rule('password', 'matches', array('repeat_password'));
     $valid_user = $user->is_valid($validate);
     $valid_address = $address->is_valid();
     if (TRUE === $valid_user and TRUE === $valid_address) {
         $address->save();
         $user->address_id = $address->id;
         $user->save();
         $user->roles = Model_Vendo_Role::LOGIN;
     } else {
         $errors = $user->errors('form_errors');
         $errors += $address->errors('form_errors');
         $this->request->response = new View_Checkout_Index();
         $this->request->response->set(array('user' => $user->as_array(), 'address' => $address->as_array(), 'cart' => Auth::instance()->get_user()->cart()));
         $errors = (string) View::factory('form_errors')->set(array('errors' => $errors));
         $this->request->response->errors = $errors;
         return FALSE;
     }
     return TRUE;
 }