public function registerPopular() { $jpop = new JuradoPopular(); if (isset($_POST["usuario"])) { $jpop->setId($_POST["usuario"]); $jpop->setNombre($_POST["nombre"]); $jpop->setEmail($_POST["correo"]); $jpop->setResidencia($_POST["residencia"]); $jpop->setTipo("juradoPopular"); if ($_POST["pass"] == $_POST["repass"]) { $jpop->setPassword($_POST["pass"]); } else { $errors["pass"] = "******"; $this->view->setVariable("errors", $errors); $this->view->render("users", "registerPopular"); return false; } try { $jpop->checkIsValidForCreate(); if (!$this->userMapper->usernameExists($_POST["usuario"])) { $this->userMapper->save($jpop); $this->view->setFlash("Usuario " . $jpop->getId() . " registrado."); $this->view->redirect("users", "login"); } else { $errors = array(); $errors["usuario"] = "El usuario ya existe"; $this->view->setVariable("errors", $errors); } } catch (ValidationException $ex) { $errors = $ex->getErrors(); $this->view->setVariable("errors", $errors); } } // Put the User object visible to the view $this->view->setVariable("juradoPopular", $jpop); $this->view->render("users", "registerPopular"); }