public function signupAction() { $account = new Account(); $accountForm = new AccountForm($account); $this->view->accountForm = $accountForm; $user = new User(); $userForm = new UserForm($user); $this->view->userForm = $userForm; $this->view->setVar("tab", 0); if ($this->request->isPost()) { try { $this->db->begin(); $accountForm->bind($this->request->getPost(), $account); $userForm->bind($this->request->getPost(), $user); $idAccountplan = $accountForm->getValue('idAccountplan'); $idAccounttype = $accountForm->getValue('idAccounttype'); $city = $accountForm->getValue('city'); $pass1 = $userForm->getValue('pass1'); $pass2 = $userForm->getValue('pass2'); $email = $this->request->getPost('email'); $this->validateEqualsPassword($pass1, $pass2); $this->validateFields(array($idAccounttype, $idAccountplan, $city), array("Debes seleccionar un tipo de cuenta", "Debes seleccionar un plan de pago, recuerda que tenemos algunos gratuitos", "Debes seleccionar una ciudad")); if ($this->saveAccount($account, $accountForm, $userForm)) { if ($this->saveUser($user, $account)) { $file = $_FILES['avatar']; $ext = explode("/", $file['type']); $file['newName'] = "{$user->idUser}.{$ext[1]}"; $dir = $this->uploader->user_avatar_dir . "/" . $user->idUser . "/images/avatar/"; $uploader = new \Sayvot\Misc\Uploader(); $uploader->setExtensionsAllowed(array("png", "jpg", "jpeg")); $uploader->setFile($file); $uploader->setMaxSizeSupported($this->uploader->images_max_size); $uploader->setDir($dir); $uploader->validate(); $uploader->upload(); if ($this->saveCredential($user, $email, $pass1)) { $this->db->commit(); $pe = new \Sayvot\Misc\ParametersEncoder(); $link = $pe->encodeLink("account/verify", array($account->idAccount, $user->idUser)); $this->flashSession->warning($link); return $this->response->redirect("session/login"); } } } } catch (InvalidArgumentException $ex) { $this->flashSession->error($ex->getMessage()); $this->db->rollback(); } catch (Exception $ex) { $this->db->rollback(); $this->flashSession->error("Ha ocurrido un error, por favor contacta al administrador"); $this->logger->log("Exception while creating account: " . $ex->getMessage()); $this->logger->log($ex->getTraceAsString()); } } }