Example #1
0
 function addPhotoModel($photoForm, $albumId)
 {
     $formObjRaw = new FormDTO(ADD_PHOTO_FORM, $photoForm);
     $responseDTO = new ResponseDTO(ADD_PHOTO_FORM);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $validator = new FormValidator(ADD_PHOTO_FORM, $formDataObj);
         $validationError = $validator->checkAll();
         if (sizeof($validationError) == 0) {
             $uploadedPhoto = FileUtils::uploadPhotoModel($formDataObj[ADD_PHOTO_FORM . PHOTO], $albumId, ADD_PHOTO_FORM, $formDataObj[ADD_PHOTO_FORM . LATITUDE], $formDataObj[ADD_PHOTO_FORM . LONGITUDE]);
             if (get_class($uploadedPhoto) === PHOTODTO) {
                 DataModelUtils::notifyAction($uploadedPhoto->getPhotoId() . SEPARATOR . $uploadedPhoto->getPhotoUrl() . SEPARATOR . $albumId, ADD_PHOTO_FORM);
                 return $uploadedPhoto;
             } else {
                 $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento della foto");
             }
         } else {
             if (array_key_exists(PHOTO, $validationError)) {
                 $responseDTO->setErrField(PHOTO, $validationError[PHOTO]);
             }
         }
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #2
0
 public function getAllUsers()
 {
     $query = "SELECT ut.*, pht.*, pt.* FROM " . USER_TABLE . " ut, " . PHOTO_TABLE . " pht, sat_person pt WHERE ut.userid = pt.personid AND ut.PROFILEPHOTO = pht.PHOTOID and ut.role <> 'ADMIN' ";
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectListDTO = DataModelUtils::getObjectList(PERSONDTO, $objectArray);
             return $objectListDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #3
0
 public function checkIfAddressExist(\AddressDTO $addressDTO)
 {
     $objectArray = array();
     $query = "SELECT * FROM " . ADDRESS_TABLE . " WHERE longitude = " . $addressDTO->getLongitude() . " AND latitude = " . $addressDTO->getLatitude();
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             return DataModelUtils::getObjectDTO(ADDRESSDTO, $objectArray[0]);
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #4
0
 public function confirmFriendshipModel($notificationId, $userForm)
 {
     $formObjRaw = new FormDTO(CONFIRM_FRIENDSHIP_FORM, $userForm);
     $formObjRaw->setSubElementId($notificationId);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $friendDAO = new FriendsDAO();
         $result = $friendDAO->confirmFriendship($formDataObj[CONFIRM_FRIENDSHIP_FORM . FRIENDID]);
         $userDAO = new UserDAO();
         $friendDTO = $userDAO->getUserByUserId($formDataObj[CONFIRM_FRIENDSHIP_FORM . FRIENDID]);
         $friendDTO->setPassword(NULL);
         $notificationDAO = new NotificationDAO();
         $result = $notificationDAO->setNotificationAsRead($formDataObj[CONFIRM_FRIENDSHIP_FORM . NOTIFICATIONID]);
         SessionUtils::addFriendInUserLoggedFriendList($friendDTO, date(DATE_FORMAT));
         DataModelUtils::notifyAction($friendDTO->getUserId() . SEPARATOR . $friendDTO->getUserName(), CONFIRM_FRIENDSHIP_FORM);
         return $friendDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #5
0
 public function forgotPasswordModel($forgotPasswordForm)
 {
     $formObjRaw = new FormDTO(FORGOT_PWD_FORM, $forgotPasswordForm);
     $responseDTO = new ResponseDTO(FORGOT_PWD_FORM);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $validator = new FormValidator(FORGOT_PWD_FORM, $formDataObj);
         $validationError = $validator->checkAll();
         if (sizeof($validationError) == 0) {
             $userDAO = new UserDAO();
             $userDTO = $userDAO->getUserByEmail($formDataObj[FORGOT_PWD_FORM . EMAIL]);
             if (is_null($userDTO)) {
                 $responseDTO->setErrField(ERROR_RESPONSE, "Nessun user presente con questa mail");
             } else {
                 $newPassword = PasswordUtils::createRandomicPassword();
                 $userDTO->setPassword($newPassword);
                 $resultMail = DataModelUtils::sendMail($userDTO, FORGOT_PWD_FORM);
                 $hashedPwd = PasswordUtils::getPassword($newPassword);
                 $userDTO->setPassword($hashedPwd);
                 $result = $userDAO->updateUserPassword($userDTO);
                 if ($result != 1) {
                     $responseDTO->setErrField(ERROR_RESPONSE, "Problema nel cambio della password");
                 } else {
                     $responseDTO->setResponseSucc("Verra mandata una mail con una nuova password all'indirizzo " . $userDTO->getEmail());
                 }
             }
         } else {
             if (array_key_exists(EMAIL, $validationError)) {
                 $responseDTO->setErrField(EMAIL, $validationError[EMAIL]);
             }
             SessionUtils::setFormValue($formDataObj);
         }
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #6
0
 public function getUnreadNotificationList($limit = NULL)
 {
     $userLogged = SessionUtils::getUserLogged();
     if (is_null($limit)) {
         $query = "select * from sat_notify where SUBJECT_ID = " . $userLogged->getUserId() . " and IS_READ = 0 order by sent_at desc ";
     } else {
         $query = "select * from sat_notify where SUBJECT_ID = " . $userLogged->getUserId() . " and IS_READ = 0 order by sent_at desc ";
     }
     try {
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectListDTO = DataModelUtils::getObjectList(NOTIFICATIONDTO, $objectArray);
             return $objectListDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #7
0
 function addFriendModel($friendId)
 {
     try {
         $responseDTO = new ResponseDTO(ADD_FRIEND_FORM);
         $friendsDAO = new FriendsDAO();
         $userDAO = new UserDAO();
         $newFriendDTO = $userDAO->getUserByUserId($friendId);
         $userLogged = SessionUtils::getUserLogged();
         $userDTO = $userDAO->getUserByUserId($userLogged->getUserId());
         $newFriend = $friendsDAO->addNewFriend($friendId);
         SessionUtils::addFriendInUserLoggedFriendList($newFriendDTO);
         DataModelUtils::notifyAction($newFriendDTO->getUserId() . SEPARATOR . $newFriendDTO->getUserName(), ADD_FRIEND_FORM);
         $result = DataModelUtils::sendMail($userDTO, ADD_FRIEND_FORM, $newFriendDTO);
         $responseDTO->setResponseSucc("friend" . $friendId);
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #8
0
 public function getFriendsList($userProfile)
 {
     if (!SessionUtils::isAdmin()) {
         $query = "select ut.*, pt.*, tmp.FRIENDSSINCE \n                    from sat_user ut, sat_photo pt, ( \n                    select FRIENDID as USERID,FRIENDSSINCE \n                    from sat_user_friends \n                    where USERID = {$userProfile} \n                    UNION \n                    select USERID, FRIENDSSINCE \n                    from sat_user_friends \n                    where FRIENDID = {$userProfile} \n                    ) tmp \n                    where ut.profilephoto = pt.photoid and tmp.USERID = ut.USERID";
     } else {
         $query = "select distinct ut.*, pt.*, NULL AS FRIENDSSINCE from sat_user ut, sat_photo pt where ut.role <> 'ADMIN' and ut.profilephoto = pt.photoid ";
     }
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectListDTO = DataModelUtils::getObjectList(FRIENDSDTO, $objectArray);
             return $objectListDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #9
0
 public static function notifyAction($object, $context)
 {
     $notificationDAO = new NotificationDAO();
     $timestamp = date(DATE_FORMAT);
     $userLoggedFriendList = SessionUtils::getUserLoggedFriendsList();
     if ($context === REGISTRATION_FORM) {
         $user = explode(SEPARATOR, $object);
         $message = DataModelUtils::getNotificationMessage($object, $context);
         $notificationDTO = new NotifyDTO(NULL, $user[0], 1, $message, 0, $timestamp, $context, $user[0] . SEPARATOR . $user[1]);
         $notificationDAO->saveNewNotification($notificationDTO);
     } else {
         if ($context === ADD_FRIEND_FORM) {
             $userLogged = SessionUtils::getUserLogged();
             $friend = explode(SEPARATOR, $object);
             $message = DataModelUtils::getNotificationMessage($object, $context);
             $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friend[0], $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]);
             $notificationDAO->saveNewNotification($notificationDTO);
         } else {
             if ($context === CONFIRM_FRIENDSHIP_FORM) {
                 $userLogged = SessionUtils::getUserLogged();
                 $friend = explode(SEPARATOR, $object);
                 $message = DataModelUtils::getNotificationMessage($object, $context, TOMYSELF);
                 $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $userLogged->getUserId(), $message, 1, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]);
                 $result = $notificationDAO->saveNewNotification($notificationDTO);
                 $message = DataModelUtils::getNotificationMessage($object, $context, TOMINENEWFRIEND);
                 $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friend[0], $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]);
                 $result = $notificationDAO->saveNewNotification($notificationDTO);
                 $userLoggedFriendList = SessionUtils::getUserLoggedFriendsList();
                 SessionUtils::prepareNotificationToFriends($object, $context, $userLoggedFriendList, $timestamp, TOMYFRIENDSLIST);
                 $friendsDAO = new FriendsDAO();
                 $myfriendFriendList = $friendsDAO->getNewFriendsFriendList($userLogged->getUserId(), $friend[0]);
                 SessionUtils::prepareNotificationToFriends($object, $context, $myfriendFriendList, $timestamp, TOMINENEWFRIENDFRIENDLIST);
                 $message = '<a href="' . URL . PROFILE_CONTROLLER . INDEX . $userLogged->getUserId() . '"><label>' . $userLogged->getUsername() . '</label></a> ha stretto amicizia con <a href="' . URL . PROFILE_CONTROLLER . INDEX . $friend[0] . '"><label>' . $friend[1] . '</label></a>';
                 $adminNotificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), 1, $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $friend[0] . SEPARATOR . $friend[1]);
                 $notificationDAO->saveNewNotification($adminNotificationDTO);
             } else {
                 $userLoggedFriendList = SessionUtils::getUserLoggedFriendsList();
                 SessionUtils::prepareNotificationToFriends($object, $context, $userLoggedFriendList, $timestamp);
             }
         }
     }
 }
Example #10
0
 function addAlbumModel($albumForm)
 {
     $formObjRaw = new FormDTO(ADD_ALBUM_FORM, $albumForm);
     $responseDTO = new ResponseDTO(ADD_ALBUM_FORM);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $validator = new FormValidator(ADD_ALBUM_FORM, $formDataObj);
         $validationError = $validator->checkAll();
         //            $validationError = array();
         if (sizeof($validationError) == 0) {
             $userLogged = SessionUtils::getUserLogged();
             $uploadedPhoto = FileUtils::uploadPhotoModel($formDataObj[ADD_ALBUM_FORM . COVER], NULL, ADD_ALBUM_FORM);
             if (get_class($uploadedPhoto) === PHOTODTO) {
                 $userDAO = new UserDAO();
                 $userDTO = $userDAO->getUserByUserId($userLogged->getUserId());
                 $albumDAO = new AlbumDAO();
                 $albumDTO = new AlbumDTO(null, date(DATE_FORMAT), $formDataObj[ADD_ALBUM_FORM . TITLE], $uploadedPhoto, $userDTO);
                 $albumDTO = $albumDAO->insertNewAlbum($albumDTO);
                 if ($albumDTO->getAlbumId() != 0) {
                     $photoAlbumPath = FileUtils::createAlbumDirOnServer($userDTO->getUserId(), $albumDTO->getAlbumId());
                     DataModelUtils::notifyAction($albumDTO->getCover()->getPhotoId() . SEPARATOR . $albumDTO->getCover()->getPhotoUrl() . SEPARATOR . $albumDTO->getAlbumId() . SEPARATOR . $albumDTO->getTitle(), ADD_ALBUM_FORM);
                     return $albumDTO;
                 } else {
                     $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento dell'album");
                 }
             } else {
                 $responseDTO->setErrField(ERROR_RESPONSE, "Errore durante l'inserimento della foto profilo");
             }
         } else {
             if (array_key_exists(TITLE, $validationError)) {
                 $responseDTO->setErrField(TITLE, $validationError[TITLE]);
             }
             if (array_key_exists(PHOTO, $validationError)) {
                 $responseDTO->setErrField(COVER, $validationError[PHOTO]);
             }
             SessionUtils::setFormValue($formDataObj);
         }
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #11
0
 public function getAlbumByAlbumId($albumId)
 {
     $query = "SELECT at.*, pht.* from sat_album at, sat_photo pht WHERE " . " at.COVER = pht.PHOTOID AND " . " at.albumid = {$albumId}";
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectDTO = DataModelUtils::getObjectDTO(ALBUMDTO, $objectArray[0]);
             return $objectDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #12
0
 public function getUserInfoByCriteria($formDataObj)
 {
     $query = "";
     $userLogged = SessionUtils::getUserLogged();
     if ($formDataObj[SEARCH_USER_FORM . CRITERIA] === USERNAME) {
         $query = "select ut.*, pht.*\n                    from sat_user ut, sat_photo pht\n                    where ut.username like '%" . $formDataObj[SEARCH_USER_FORM . TARGET] . "%'\n                    and ut.userid <> " . $userLogged->getUserId() . " \n                    and ut.userid <> 1 \n                    and ut.profilephoto = pht.photoid";
     } else {
         if ($formDataObj[SEARCH_USER_FORM . CRITERIA] === EMAIL) {
             $query = "select ut.*, pht.*\n                    from sat_user ut, sat_photo pht\n                    where ut.email like '%" . $formDataObj[SEARCH_USER_FORM . TARGET] . "%'\n                    and ut.userid <> " . $userLogged->getUserId() . " \n                    and ut.userid <> 1 \n                    and ut.profilephoto = pht.photoid";
         }
     }
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             for ($i = 0; $i < sizeof($objectArray); $i++) {
                 $friendid = $objectArray[$i][strtoupper(USERID)];
                 $internalQuery = "select friendssince \n                    from sat_user_friends\n                        where userid = " . $friendid . " and friendid = " . $userLogged->getUserId() . "\n                        or friendid =  " . $friendid . " and userid = " . $userLogged->getUserId();
                 $friendsSince = $this->getDB()->execQuery($internalQuery);
                 if (!is_null($friendsSince)) {
                     $friendsSince = $friendsSince[0][FRIENDSSINCE];
                 }
                 $objectArray[$i][strtoupper(FRIENDSSINCE)] = $friendsSince;
             }
             return DataModelUtils::getObjectList(FRIENDSDTO, $objectArray);
         }
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #13
0
 public static function prepareNotificationToFriends($object, $context, $friendList, $timestamp, $direction = NULL, $userId = NULL)
 {
     $userLogged = SessionUtils::getUserLogged();
     $notificationDao = new NotificationDAO();
     if ($context !== CONFIRM_FRIENDSHIP_FORM) {
         $message = DataModelUtils::getNotificationMessage($object, $context, $direction);
         $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), 1, $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $object);
         $result = $notificationDao->saveNewNotification($notificationDTO);
     }
     if ($friendList != null) {
         foreach ($friendList as $key => $friendDTO) {
             $message = DataModelUtils::getNotificationMessage($object, $context, $direction);
             if ($context === CONFIRM_FRIENDSHIP_FORM) {
                 $friend = explode(SEPARATOR, $object);
                 if ($direction === TOMYFRIENDSLIST) {
                     if ($friend[0] !== $friendDTO->getFriendId()->getUserId()) {
                         $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friendDTO->getFriendId()->getUserId(), $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $object);
                         $result = $notificationDao->saveNewNotification($notificationDTO);
                     }
                 } else {
                     if ($direction === TOMINENEWFRIENDFRIENDLIST) {
                         if ($friendDTO->getFriendId()->getUserId() !== $userLogged->getUserId()) {
                             $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friendDTO->getFriendId()->getUserId(), $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $object);
                             $result = $notificationDao->saveNewNotification($notificationDTO);
                         }
                     }
                 }
             } else {
                 $notificationDTO = new NotifyDTO(NULL, $userLogged->getUserId(), $friendDTO->getFriendId()->getUserId(), $message, 0, $timestamp, $context, $userLogged->getUserId() . SEPARATOR . $userLogged->getUserName() . SEPARATOR . $object);
                 $result = $notificationDao->saveNewNotification($notificationDTO);
             }
         }
     }
 }
Example #14
0
 public function getPhotoByPhotoId($photoId)
 {
     $query = "select * from  " . PHOTO_TABLE . " where PHOTOID = {$photoId} ";
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectDTO = DataModelUtils::getObjectDTO(PHOTODTO, $objectArray[0]);
             return $objectDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #15
0
 public function commentAPostModel($commentForm, $postId)
 {
     $responseDTO = new ResponseDTO(WRITE_COMMENT_FORM);
     $formObjRaw = new FormDTO(WRITE_COMMENT_FORM, $commentForm);
     $formObjRaw->setSubElementId($postId);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $responseDTO->setSubElementId($formDataObj[WRITE_COMMENT_FORM . POSTID]);
         $validator = new FormValidator(WRITE_COMMENT_FORM, $formDataObj);
         $validationError = $validator->checkAll();
         if (sizeof($validationError) == 0) {
             $timestamp = date(DATE_FORMAT);
             $userLogged = SessionUtils::getUserLogged();
             $newCommentDTO = new CommentDTO(NULL, $formDataObj[WRITE_COMMENT_FORM . TEXT], $timestamp, $formDataObj[WRITE_COMMENT_FORM . POSTID], $userLogged);
             $postDAO = new PostDAO();
             $commentDTO = $postDAO->insertNewComment($newCommentDTO);
             if ($commentDTO->getCommentid() == 0) {
                 $errorDTO = new ErrDTO(WRITE_COMMENT_FORM);
                 $responseDTO->setResponseErr("Non รจ stato possibile inserire il commento del post");
                 $responseDTO->setSubElementId($formDataObj[WRITE_COMMENT_FORM . POSTID]);
                 return $errorDTO;
             } else {
                 DataModelUtils::notifyAction($commentDTO->getCommentid() . SEPARATOR . $formDataObj[WRITE_COMMENT_FORM . POSTID] . SEPARATOR . $userLogged->getUserId() . SEPARATOR . SessionUtils::getDashboardId(), WRITE_COMMENT_FORM);
                 return $commentDTO;
             }
         } else {
             if (array_key_exists(TEXT, $validationError)) {
                 $responseDTO->setErrField(TEXT, $validationError[TEXT]);
             }
             return $responseDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #16
0
 public function getPostByPostId($postId)
 {
     $query = "select \n                pt.postid as POSTID,\n                pt.TEXT\tas TEXT,\n                pt.DATE as DATE,\n                postph.LONGITUDE as LONGITUDE,\n                postph.LATITUDE as LATITUDE,\n                postph.PHOTOID as POSTPHOTOID,\n                postph.PHOTOURL as POSTPHOTOURL,\n                authut.USERID as AUTHORID,\n                authut.USERNAME as AUTHORUSERNAME,\n                authph.PHOTOURL as AUTHORPHOTOURL,\n                authph.PHOTOID as AUTHORPHOTOID,\n                dashut.USERID as DASHBOARDUSERID,\n                dashph.PHOTOURL as DASHBOARDPHOTOURL,\n                dashph.PHOTOID as DASHBOARDPHOTOID,\n                dashut.USERNAME as DASHBOARDUSERNAME" . " from sat_post pt, sat_photo postph, sat_user authut, sat_photo authph,sat_user dashut, sat_photo dashph" . " where pt.postid = " . $postId . " and pt.dashboardid = dashut.userid " . " and postph.photoid = pt.photoid " . " and pt.authorid = authut.userid " . " and authut.profilephoto = authph.photoid " . " and dashut.profilephoto = dashph.photoid " . " order by pt.date desc";
     //        var_dump($query);
     try {
         $this->userAutentication();
         $objectDto = $this->getDB()->execQuery($query);
         if (is_null($objectDto)) {
             return NULL;
         } else {
             $objectListDTO = DataModelUtils::getObjectDTO(POSTDTO, $objectDto[0]);
             return $objectListDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
 function changeUserProfileInfoModel($infoForm, $userId = NULL)
 {
     $formObjRaw = new FormDTO(CHANGE_SETTINGS_FORM, $infoForm);
     $responseDTO = new ResponseDTO(CHANGE_SETTINGS_FORM);
     try {
         $formDataObj = $formObjRaw->getFormData();
         $validator = new FormValidator(CHANGE_SETTINGS_FORM, $formDataObj);
         $validationError = $validator->checkAll();
         if (sizeof($validationError) == 0) {
             $birthday = $formDataObj[CHANGE_SETTINGS_FORM . YEAR];
             $userLogged = SessionUtils::getUserLogged();
             if (!is_null($birthday)) {
                 $birthday = $formDataObj[CHANGE_SETTINGS_FORM . YEAR] . "-" . $formDataObj[CHANGE_SETTINGS_FORM . MONTH] . "-" . $formDataObj[CHANGE_SETTINGS_FORM . DAY];
             }
             $personDAO = new PersonDAO();
             $userDAO = new UserDAO();
             if (is_null($userId)) {
                 $userId = $userLogged->getUserId();
             }
             $userDTO = $userDAO->getUserInfo($userId);
             $updateUserInfo = new PersonDTO($userDTO->getPersonId(), $formDataObj[CHANGE_SETTINGS_FORM . NAME], $formDataObj[CHANGE_SETTINGS_FORM . SURNAME], $formDataObj[CHANGE_SETTINGS_FORM . GENDER], $birthday, $formDataObj[CHANGE_SETTINGS_FORM . EDUCATION], $formDataObj[CHANGE_SETTINGS_FORM . JOB], $formDataObj[CHANGE_SETTINGS_FORM . DESCRIPTION], $formDataObj[CHANGE_SETTINGS_FORM . RELATIONSHIP], $formDataObj[CHANGE_SETTINGS_FORM . ORIENTATION]);
             $personDTO = $personDAO->updateProfileInfo($updateUserInfo);
             DataModelUtils::notifyAction(NULL, CHANGE_SETTINGS_FORM);
             return $personDTO;
         } else {
             if (array_key_exists(EDUCATION, $validationError)) {
                 $responseDTO->setErrField(EDUCATION, $validationError[EDUCATION]);
             }
             if (array_key_exists(DESCRIPTION, $validationError)) {
                 $responseDTO->setErrField(DESCRIPTION, $validationError[DESCRIPTION]);
             }
             if (array_key_exists(JOB, $validationError)) {
                 $responseDTO->setErrField(JOB, $validationError[JOB]);
             }
             if (array_key_exists(NAME, $validationError)) {
                 $responseDTO->setErrField(NAME, $validationError[NAME]);
             }
             if (array_key_exists(SURNAME, $validationError)) {
                 $responseDTO->setErrField(SURNAME, $validationError[SURNAME]);
             }
         }
         return $responseDTO;
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }