Пример #1
0
 /**
  * Get content of an experience details - this function is called by two above funtions
  * @param String $experienceId: id of the SharcExperience
  * @param String $designerId: id of the designer 
  * @param String $userId: id of the SharcUser          
  */
 public static function getSnapshotForSpvt($designerId, $experienceId, $userId)
 {
     $response = array();
     $response["status"] = SUCCESS;
     //Get all POIs of the experience
     $objPois = SharcPoiExperience::where('experienceId', $experienceId)->get();
     $tmpPois = $objPois->toArray();
     $i = 0;
     for ($i; $i < $objPois->count(); $i++) {
         $rs = SharcPoiDesigner::where('id', $objPois[$i]->poiDesignerId)->where('designerId', $designerId)->get();
         $tmpPois[$i]["poiDesigner"] = $rs[0]->toArray();
         //Thumbnail
         $media = SharcMediaExperience::where('entityId', $objPois[$i]->id)->where('entityType', 'POI')->where('mainMedia', 1)->get();
         if ($media->count() > 0) {
             $mediaDesigner = SharcMediaDesigner::where('id', $media[0]->mediaDesignerId)->where('designerId', $designerId)->get();
             if ($mediaDesigner->count() > 0) {
                 $tmpPois[$i]["thumbnail"] = $mediaDesigner[0]->content;
             } else {
                 $tmpPois[$i]["thumbnail"] = "";
             }
         } else {
             $tmpPois[$i]["thumbnail"] = "";
         }
         //Media for POI
         $media = MediaService::getMediaForEntityServer($designerId, $experienceId, $objPois[$i]->id, "POI");
         $tmpPois[$i]["media"] = $media->toArray();
         //Responses for POI by this user
         $tmpPois[$i]["responses"] = SharcResponse::where('experienceId', $experienceId)->where('userId', $userId)->where('entityId', $objPois[$i]->id)->get()->toArray();
     }
     $response["data"]["allPois"] = $tmpPois;
     //Get all Routes of the experience
     $objRoutes = SharcRouteExperience::where('experienceId', $experienceId)->get();
     $tmpRoutes = $objRoutes->toArray();
     $i = 0;
     for ($i; $i < $objRoutes->count(); $i++) {
         $rs = SharcRouteDesigner::where('id', $objRoutes[$i]->routeDesignerId)->where('designerId', $designerId)->get();
         $tmpRoutes[$i]["routeDesigner"] = $rs[0]->toArray();
     }
     $response["data"]["allRoutes"] = $tmpRoutes;
     //Get all responses
     $response["data"]["allResponses"] = SharcResponse::where('experienceId', $experienceId)->where('userId', $userId)->where('entityType', 'NEW')->get()->toArray();
     return $response;
 }
Пример #2
0
 /**
  * Delete a Route -> delete only SharcRouteExperience & SharcMediaExperience
  * @param String $objRoute: a json object containing info of both Routes                  
  */
 public static function deleteRoute($objRoute)
 {
     $response = array();
     try {
         //Delete media
         SharcMediaExperience::where('experienceId', $objRoute['experienceId'])->where('entityId', $objRoute['id'])->where('entityType', 'POI')->delete();
         $routeExperience = SharcRouteExperience::find($objRoute['id']);
         if ($routeExperience != null) {
             $result = $routeExperience->delete();
             if ($result) {
                 //= 1 success
                 $response["status"] = SUCCESS;
                 $response["data"] = $routeExperience->toArray();
             } else {
                 //error
                 $response["status"] = ERROR;
                 $response["data"] = INTERNAL_SERVER_ERROR;
             }
         }
         //update other table e.g. route/event
     } catch (Exception $e) {
         $response["status"] = ERROR;
         $response["data"] = Utils::getExceptionMessage($e);
     }
     return $response;
 }
Пример #3
0
 /**
  * Update a Media = 1 SharcMediaDesigner + 1 SharcMediaExperience
  * @param String $objMedia: a json object containing info of both Medias                  
  */
 public static function updateMedia($objMedia)
 {
     $response = array();
     try {
         $mediaDesigner = SharcMediaDesigner::find($objMedia['mediaDesigner']['id']);
         if ($mediaDesigner != null) {
             /*$mediaDesigner->name = $objMedia['mediaDesigner']['name'];                   
               $mediaDesigner->directed = $objMedia['mediaDesigner']['directed'];
               $mediaDesigner->colour = $objMedia['mediaDesigner']['colour'];
               $mediaDesigner->path = $objMedia['mediaDesigner']['path'];
               
               $result = $mediaDesigner->save();
                
               if (!$result){                     
                   $response["status"] = ERROR;
                   $response["data"] = INTERNAL_SERVER_ERROR; 
                   return $response;                
               }
               */
         }
         $mediaExperience = SharcMediaExperience::find($objMedia['id']);
         if ($mediaExperience != null) {
             //if mainMedia == 1 -> reset all other media to 0
             if ($objMedia['mainMedia'] == 1) {
                 SharcMediaExperience::where('experienceId', $objMedia['experienceId'])->where('entityType', $objMedia['entityType'])->where('entityId', $objMedia['entityId'])->update(array('mainMedia' => 0));
             }
             $mediaExperience->caption = $objMedia['caption'];
             $mediaExperience->mainMedia = $objMedia['mainMedia'];
             $mediaExperience->visible = $objMedia['visible'];
             $mediaExperience->order = $objMedia['order'];
             $result = $mediaExperience->save();
             if ($result) {
                 //= 1 success
                 $response["status"] = SUCCESS;
                 $mediaExperience["mediaDesigner"] = $mediaDesigner->toArray();
                 //need to return this info too for presentation
                 $response["data"] = $mediaExperience->toArray();
             } else {
                 //error
                 $response["status"] = ERROR;
                 $response["data"] = INTERNAL_SERVER_ERROR;
             }
         }
         //update other table e.g. poi/event
     } catch (Exception $e) {
         $response["status"] = ERROR;
         $response["data"] = Utils::getExceptionMessage($e);
     }
     return $response;
 }