Ejemplo n.º 1
0
 public function registerEstablecimiento()
 {
     $esta = new Establecimiento();
     if (isset($_POST["usuario"])) {
         $esta->setId($_POST["usuario"]);
         $esta->setNombre($_POST["nombre"]);
         $esta->setEmail($_POST["correo"]);
         $esta->setDescripcion($_POST["descripcion"]);
         $esta->setLocalizacion($_POST["localizacion"]);
         $esta->setTipo("Establecimiento");
         if ($_POST["pass"] == $_POST["repass"]) {
             $esta->setPassword($_POST["pass"]);
         } else {
             $errors["pass"] = "******";
             $this->view->setVariable("errors", $errors);
             $this->view->render("users", "registerEstablecimiento");
             return false;
         }
         try {
             $esta->checkIsValidForCreate();
             if (!$this->userMapper->usernameExists($_POST["usuario"])) {
                 $this->userMapper->save($esta);
                 $this->view->setFlash("Usuario " . $esta->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);
         }
     }
     $this->view->setVariable("Establecimiento", $esta);
     $this->view->render("users", "registerEstablecimiento");
 }