예제 #1
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;
     }
 }
예제 #2
0
 public function getUserAlbumList($userId)
 {
     $query = "SELECT at.*, pht.* from sat_album at, sat_photo pht WHERE " . " at.COVER = pht.PHOTOID AND " . " at.owner = {$userId} order by at.albumid desc";
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectListDTO = DataModelUtils::getObjectList(ALBUMDTO, $objectArray);
             return $objectListDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #3
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;
     }
 }
예제 #4
0
 public function getCommentListByPostId($postId)
 {
     $query = "select ct.*,ut.*,pht.* " . " from sat_comment ct, sat_user ut, sat_photo pht " . " where ct.postid = {$postId} and ct.authorid = ut.userid and ut.profilephoto = pht.photoid order by ct.date desc";
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectListDTO = DataModelUtils::getObjectList(COMMENTDTO, $objectArray);
             return $objectListDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #5
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;
     }
 }
예제 #6
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;
     }
 }
예제 #7
0
 public function getAllUserPhotos($userId)
 {
     $query = "SELECT pt.* from " . USER_PHOTO_ALBUMS_TABLE . " upat, sat_photo pt where upat.USERID = {$userId} and upat.PHOTOID = pt.PHOTOID";
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectListDTO = DataModelUtils::getObjectList(PHOTODTO, $objectArray);
             return $objectListDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }