예제 #1
0
 /**
  *
  * @param WOOOF $wo
  * @param id $movieRamaUserId
  * @return false | array[ ]
  */
 public static function getMainInfo(WOOOF $wo, $movieRamaUserId)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  [{$movieRamaUserId}]");
     $main = [];
     if ($movieRamaUserId == $wo->app->userId) {
         $ramaUser = $wo->app->movieRamaPersonRow;
         $main['isSelf'] = true;
     } else {
         $ramaUser = $wo->db->getRowByColumn('v_movierama_persons', 'VUS_id', $movieRamaUserId);
         if ($ramaUser === FALSE || $ramaUser === NULL) {
             return false;
         }
         $main['isSelf'] = false;
     }
     $main['personProfileId'] = $ramaUser['VUS_personProfileId'];
     $main['movieRamaUserId'] = $ramaUser['VUS_id'];
     $main['isActive'] = $ramaUser['VUS_isActive'];
     $main['isLoggedIn'] = true;
     $main['isType'] = 'PRS';
     $main['avatarImg'] = $ramaUser['VUS_avatarImg'];
     $mainElems = ['PROF_firstName', 'PROF_lastName'];
     WOOOF_Util::filterOnKeys($main, $mainElems, $ramaUser, 'PROF_');
     return $main;
 }
예제 #2
0
 /**
  *
  * @param WOOOF $wo
  * @param string $requestorUserId = ''
  * @param bool $isUserLoggedIn
  * @param string $sortCriteria = ''
  * @param string $targetUserId = ''
  * @return array of movies
  */
 public static function getMovies(WOOOF $wo, $requestorUserId = '', $isUserLoggedIn, $sortCriteria = '', $targetUserId = '')
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     $wo->debug("{$place}:  Get Movies");
     $movies = [];
     $movieElems = ['MUM_id', 'MUM_movieramaUserId', 'MUM_title', 'MUM_description', 'MUM_publishDateTime', 'MUM_noOfLikes', 'MUM_noOfHates', 'VUS_username', 'VUS_avatarImg', 'PPR_firstName', 'PPR_lastName'];
     $tblViewMovieRamaUserMovies = new WOOOF_dataBaseTable($wo->db, 'v_movierama_user_movies');
     if (!$tblViewMovieRamaUserMovies->constructedOk) {
         return false;
     }
     //movies from all users
     if (!$wo->hasContent($targetUserId)) {
         //all movies without sorting filter
         if (!$wo->hasContent($sortCriteria)) {
             $result = $wo->db->query("SELECT * FROM v_movierama_user_movies");
         } else {
             $result = $wo->db->query("SELECT * FROM v_movierama_user_movies ORDER BY {$sortCriteria} DESC");
         }
     } else {
         //all movies from a user without sorting filter
         if (!$wo->hasContent($sortCriteria)) {
             $result = $wo->db->query("SELECT * FROM v_movierama_user_movies WHERE MUM_movieramaUserId='{$targetUserId}'");
         } else {
             $result = $wo->db->query("SELECT * FROM v_movierama_user_movies WHERE MUM_movieramaUserId='{$targetUserId}' ORDER BY {$sortCriteria} DESC");
         }
     }
     if ($result === FALSE) {
         return false;
     }
     if (!$wo->db->getNumRows($result)) {
         //no error no results
         return [];
     } else {
         //no error results
         while ($row = $wo->db->fetchAssoc($result)) {
             $tblViewMovieRamaUserMovies->resultRows[] = $row;
         }
     }
     $ids = [];
     //not logged in
     if ($isUserLoggedIn === 'false') {
         foreach ($tblViewMovieRamaUserMovies->resultRows as $v_movie) {
             $movie = [];
             $movieId = $v_movie['MUM_id'];
             WOOOF_Util::filterOnKeys($movie, $movieElems, $v_movie);
             $movie['isType'] = 'MOV';
             $movies[$movieId] = $movie;
         }
         //convert the associative array to a simple array to come back to the frontend
         $movies = array_values($movies);
         return $movies;
     } else {
         foreach ($tblViewMovieRamaUserMovies->resultRows as $v_movie) {
             $movie = [];
             $movieId = $v_movie['MUM_id'];
             WOOOF_Util::filterOnKeys($movie, $movieElems, $v_movie);
             $movie['isType'] = 'MOV';
             $isUserMovieCreator = self::isUserMovieCreator($wo, $wo->app->userId, $v_movie['MUM_id']);
             if ($isUserMovieCreator === FALSE) {
                 return false;
             }
             if ($isUserMovieCreator === '1') {
                 $movie['isSelfMovieCreator'] = true;
             } else {
                 $movie['isSelfMovieCreator'] = false;
             }
             $hasRunningEvals = VO_Evaluation::hasRunningEvaluations($wo, $movieId, 'MOV', $wo->app->userId);
             if ($hasRunningEvals === FALSE) {
                 return false;
             }
             $runningEvalId = '';
             if ($hasRunningEvals === 1) {
                 //go get last running evaluation id
                 $runningEvalId = VO_Evaluation::getLastRunningEvaluation($wo, $movieId, 'MOV', $wo->app->userId);
                 if ($runningEvalId === FALSE) {
                     return false;
                 }
             }
             $movie['hasRunningEvals'] = $hasRunningEvals;
             $movie['runningEvalId'] = $runningEvalId;
             $movies[$movieId] = $movie;
         }
         //pass the keys from $movies to $ids
         $ids = array_keys($movies);
         //make the opinions array
         $opinionInfoArray = self::getOpinionsInfo($wo, $wo->app->userId, $ids);
         if ($opinionInfoArray === false) {
             return false;
         }
         //merge the movies array (with main info) with the opinions array
         foreach ($movies as $aKey => &$aMovie) {
             $aMovie['opinions'] = $opinionInfoArray[$aKey];
         }
         //convert the associative array to a simple array to come back to the frontend
         $movieOpinions = array_values($movies);
         //return $movieOpinions;
         return $movieOpinions;
     }
 }
예제 #3
0
 /**
  *
  * @param WOOOF $wo
  * @param string $evaluationId
  * @param string $requestorUserId
  * return [] if none | [ criteria1, criteria2, ... ]
  */
 public static function getCriteria(WOOOF $wo, $evaluationId, $requestorUserId)
 {
     $place = __CLASS__ . '::' . __FUNCTION__;
     if (!$wo->hasContent($evaluationId)) {
         $wo->logError(self::_ECP . "5099 No value for evaluation id to find criteria");
         return false;
     }
     $criterias = [];
     $criteriaElems = ['id', 'evaluationId', 'evalTemplateId', 'label', 'description', 'evaluationTypeDVCode', 'isOptional', 'weight'];
     $tblEvaluationCriteria = new WOOOF_dataBaseTable($wo->db, 'evaluation_criteria');
     if (!$tblEvaluationCriteria->constructedOk) {
         return false;
     }
     $safeEvaluationId = $wo->db->escape($evaluationId);
     $result = $wo->db->query("SELECT * FROM evaluation_criteria WHERE evaluationId='{$safeEvaluationId}' AND isDeleted='0'");
     if ($result === FALSE) {
         return false;
     }
     if (!$wo->db->getNumRows($result)) {
         //no error no results
         return [];
     } else {
         //no error results
         while ($row = $wo->db->fetchAssoc($result)) {
             $tblEvaluationCriteria->resultRows[] = $row;
         }
     }
     foreach ($tblEvaluationCriteria->resultRows as $aCriteria) {
         $criteria = [];
         WOOOF_Util::filterOnKeys($criteria, $criteriaElems, $aCriteria);
         $criterias[] = $criteria;
     }
     return $criterias;
 }