Esempio n. 1
0
 /**
  * Get all media associated with an entity
  * @param $objMediaParam: entityType, entityId, experienceId, designerId         
  */
 public static function getMediaForEntity($designerId, $experienceId, $entityId, $entityType)
 {
     $response = array();
     try {
         //Get all mediaexperience
         if ($designerId == ADMIN_ID) {
             //admin
             $ex = SharcExperience::find($experienceId);
             $designerId = $ex->designerId;
         }
         $mediaExperience = SharcMediaExperience::where('entityId', $entityId)->where('entityType', $entityType)->where('experienceId', $experienceId)->orderBy('order')->get();
         //$mediaExperience = $mediaExperience->sortBy('order');
         $response["status"] = SUCCESS;
         //Get mediadesigner for each mediaexperience
         $i = 0;
         for ($i = 0; $i < $mediaExperience->count(); $i++) {
             $mediaDesigner = SharcMediaDesigner::where('id', $mediaExperience[$i]->mediaDesignerId)->where('designerId', $designerId)->get();
             $mediaExperience[$i]["mediaDesigner"] = $mediaDesigner[0]->toArray();
         }
         $response["data"] = $mediaExperience->toArray();
     } catch (Exception $e) {
         $response["status"] = ERROR;
         $response["data"] = Utils::getExceptionMessage($e);
     }
     return $response;
 }
Esempio n. 2
0
 /**
  * Get content of an experience for SPVT
  * @param String $experienceId: id of the SharcExperience         
  * @param String $userId: id of the SharcUser
  */
 public static function getExperienceSnapshotForSpvt($experienceId, $userId)
 {
     $response = array();
     try {
         //Check if the designerId owns the experience
         $rs = SharcExperience::find($experienceId);
         if ($rs == null || $rs->isPublished == 0) {
             //Not exists
             $response["status"] = FAILED;
             $response["data"] = EXPERIENCE_NOT_EXIST;
             return $response;
         } else {
             $response = ExperienceService::getSnapshotForSpvt($rs->designerId, $experienceId, $userId);
         }
     } catch (Exception $e) {
         $response["status"] = ERROR;
         $response["data"] = Utils::getExceptionMessage($e);
     }
     return $response;
 }
Esempio n. 3
0
 /**
  * Get number of new reponses for notification purpose only
  * @param String $experienceId: id of the SharcExperience
  * @param String $designerId: id of the designer           
  */
 public static function getResponsesCount($designerId, $experienceId)
 {
     $response = array();
     try {
         //Check if the designerId owns the experience
         if ($designerId == ADMIN_ID) {
             //admin
             $ex = SharcExperience::find($experienceId);
             $designerId = $ex->designerId;
         }
         $rs = SharcExperience::where('id', $experienceId)->where('designerId', $designerId)->get();
         if ($rs->count() == 0) {
             //Not exists
             $response["status"] = FAILED;
             $response["data"] = EXPERIENCE_NOT_EXIST;
             return $response;
         } else {
             $response["status"] = SUCCESS;
             //Get all responses
             $objResponses = SharcResponse::where('experienceId', $experienceId)->where('status', 'waiting')->get();
             $response["data"] = $objResponses->count();
             return $response;
         }
     } catch (Exception $e) {
         $response["status"] = ERROR;
         $response["data"] = Utils::getExceptionMessage($e);
     }
     return $response;
 }