public function get_userProfile($uuid)
 {
     session_start();
     try {
         if (isset($_SESSION["email"]) && !empty($_SESSION["email"])) {
             $user = $this->getUserByEmail($_SESSION["email"]);
             //$mascotaModel = new MascotaModel();
             //$mascotaData = $mascotaModel->mMascotaByUUID($mascotaid);
             $img = new ImageModel();
             $images = $img->mGetByUUId($user[0]["uuid"]);
             $eventObject = new CalendarioModel();
             $events = $eventObject->mGetByUserUUID($user[0]["uuid"]);
             $animalista = new AnimalistaModel();
             $is_animalista = $animalista->mVerifyProfile($uuid);
             $profile = array();
             $msg = new MensajesModel();
             $messages = $msg->mGetAllByUser($uuid);
             $inbox = array();
             if ($messages) {
                 $userObject = new UsuariosModel();
                 $mascotaObject = new MascotaModel();
                 foreach ($messages as $key => $message) {
                     $user_uuid = $userObject->getByuuid($message["from"]);
                     if ($user_uuid) {
                         $inbox[] = array("uuid" => $message["uuid"], "from" => $user_uuid["nombre"], "subject" => $message["subject"], "date" => $message["date"]);
                     } else {
                         $mascota = $mascotaObject->mMascotaByUUID($message["from"]);
                         if ($mascota) {
                             $inbox[] = array("uuid" => $message["uuid"], "from" => $mascota["nombre"], "subject" => $message["subject"], "date" => $message["date"]);
                         }
                     }
                 }
             }
             if ($is_animalista) {
                 $profile = $animalista->mUUID($uuid);
             }
             $estados = new EstadosModel();
             $municipios = $estados->get_temp();
             return View::make("user-profile", array("user" => $user, "images" => $images, "events" => $events, "is_animalista" => $is_animalista, "profile" => $profile, "messages" => $inbox, "municipios" => $municipios));
         } else {
             Auth::logout();
             unset($_SESSION["email"]);
             return Redirect::to("/");
         }
     } catch (exception $e) {
         echo $e;
     }
 }
 public function getMyFavs($current_uuid)
 {
     $favs = $this->connection->mMyFavs($current_uuid);
     if (is_array($favs)) {
         //print_r($favs);die;
         $favorito = array();
         $userObject = new UsuariosModel();
         $mascotaObject = new MascotaModel();
         foreach ($favs as $key => $fav) {
             $user_uuid = $userObject->getByuuid($fav["mi_favorito"]);
             if ($user_uuid) {
                 $favorito[] = array("uuid" => $fav["mi_favorito"], "nombre" => $user_uuid["nombre"]);
             } else {
                 $mascota = $mascotaObject->mMascotaByUUID($fav["mi_favorito"]);
                 if ($mascota) {
                     $favorito[] = array("name" => $message["nombre"], "uuid" => $fav["mi_favorito"]);
                 }
             }
         }
         return json_encode(array("status" => 200, "favoritos" => $favorito));
     } else {
         return json_encode(array("status" => 200, "message" => "No tienes favoritos aun"));
     }
 }
 public function get_sent($uuid)
 {
     session_start();
     if (isset($_SESSION["email"]) && !empty($_SESSION["email"])) {
         $messages = $this->dbObject->mGetAllByUserSent($uuid);
         $sent = array();
         $userObject = new UsuariosModel();
         $mascotaObject = new MascotaModel();
         foreach ($messages as $key => $message) {
             $user_uuid = $userObject->getByuuid($message["to"]);
             if ($user_uuid) {
                 $sent[] = array("uuid" => $message["uuid"], "to" => $user_uuid["nombre"], "subject" => $message["subject"], "date" => $message["created_at"]);
             } else {
                 $mascota = $mascotaObject->mMascotaByUUID($message["to"]);
                 if ($mascota) {
                     $sent[] = array("uuid" => $message["uuid"], "to" => $mascota["nombre"], "subject" => $message["subject"], "date" => $message["created_at"]);
                 }
             }
         }
         return View::make("sent", array("uuid" => $uuid, "messages" => $sent));
     } else {
         return Redirect::to("/");
     }
 }
 public function get_visita($mascotaid)
 {
     if ($mascotaid == null) {
         return Redirect::to("/");
     }
     session_start();
     $user = new UsuariosController();
     $userData = $user->getUserByEmail($_SESSION["email"]);
     $mascotaModel = new MascotaModel();
     $mascotaData = $mascotaModel->mMascotaByUUID($mascotaid);
     $img = new ImageModel();
     $images = $img->mGetByUUId($mascotaData["uuid"]);
     return View::make("mascota-visita", array("mascota" => $mascotaData, "images" => $images, "user" => $userData));
 }
Exemplo n.º 5
0
 public function cancelAccount($uuid)
 {
     try {
         $cancel = $this->find($uuid);
         $mascota = new MascotaModel();
         $mascotas = $mascota->mMascotaLista($uuid);
         if (!empty($mascotas)) {
             foreach ($mascotas as $key => $masc) {
                 $mascota->mDelete($masc["uuid"]);
             }
         }
         $cancel->delete();
     } catch (exception $e) {
         echo $e;
     }
 }