コード例 #1
0
ファイル: PoiTypeService.php プロジェクト: TrienDo/SHARC20
 /**
  * Delete a PoiType 
  * @param String $objPoiType: a json object containing info of both PoiTypes                  
  */
 public static function deletePoiType($objPoiType)
 {
     $response = array();
     try {
         //Delete media
         $poiType = SharcPoiType::find($objPoiType['id']);
         if ($poiType != null) {
             $result = $poiType->delete();
             if ($result) {
                 //= 1 success
                 $response["status"] = SUCCESS;
                 $response["data"] = "";
             } else {
                 //error
                 $response["status"] = ERROR;
                 $response["data"] = INTERNAL_SERVER_ERROR;
             }
         }
     } catch (Exception $e) {
         $response["status"] = ERROR;
         $response["data"] = Utils::getExceptionMessage($e);
     }
     return $response;
 }
コード例 #2
0
ファイル: ExperienceService.php プロジェクト: TrienDo/SHARC20
 /**
  * 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           
  */
 public static function getExperienceSnapshotDetails($designerId, $experienceId)
 {
     $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();
         //$tmpPois[$i]["media"] = $media->toArray();
         if ($media != null) {
             $tmpPois[$i]["mediaCount"] = $media->count();
         } else {
             $tmpPois[$i]["mediaCount"] = 0;
         }
         $tmpPois[$i]["responseCount"] = 0;
     }
     $response["data"]["allPois"] = $tmpPois;
     //Get all EOIs of the experience
     $objEois = SharcEoiExperience::where('experienceId', $experienceId)->get();
     $tmpEois = $objEois->toArray();
     $i = 0;
     for ($i; $i < $objEois->count(); $i++) {
         $rs = SharcEoiDesigner::where('id', $objEois[$i]->eoiDesignerId)->where('designerId', $designerId)->get();
         $tmpEois[$i]["eoiDesigner"] = $rs[0]->toArray();
         //Media for EOI
         $media = MediaService::getMediaForEntityServer($designerId, $experienceId, $objEois[$i]->id, "EOI");
         //$tmpEois[$i]["media"] = $media->toArray();
         if ($media != null) {
             $tmpEois[$i]["mediaCount"] = $media->count();
         } else {
             $tmpEois[$i]["mediaCount"] = 0;
         }
         $tmpEois[$i]["responseCount"] = 0;
     }
     $response["data"]["allEois"] = $tmpEois;
     //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();
         //Media for EOI
         $media = MediaService::getMediaForEntityServer($designerId, $experienceId, $objRoutes[$i]->id, "ROUTE");
         //$tmpRoutes[$i]["media"] = $media->toArray();
         if ($media != null) {
             $tmpRoutes[$i]["mediaCount"] = $media->count();
         } else {
             $tmpRoutes[$i]["mediaCount"] = 0;
         }
         $tmpRoutes[$i]["responseCount"] = 0;
     }
     $response["data"]["allRoutes"] = $tmpRoutes;
     //Get all Media of the experience
     $objMedia = SharcMediaExperience::where('experienceId', $experienceId)->get();
     $tmpMedia = $objMedia->toArray();
     $i = 0;
     for ($i; $i < $objMedia->count(); $i++) {
         $rs = SharcMediaDesigner::where('id', $objMedia[$i]->mediaDesignerId)->where('designerId', $designerId)->get();
         $tmpMedia[$i]["mediaDesigner"] = $rs[0]->toArray();
         //Response for media
         $media = SharcResponse::where('experienceId', $experienceId)->where('entityType', 'media')->where('entityId', $objMedia[$i]->id)->where('status', 'accepted')->get();
         if ($media != null) {
             $tmpMedia[$i]["commentCount"] = $media->count();
         } else {
             $tmpRoutes[$i]["commentCount"] = 0;
         }
     }
     $response["data"]["allMedia"] = $tmpMedia;
     //Get all responses
     $objResponses = SharcResponse::where('experienceId', $experienceId)->where('status', 'accepted')->get();
     $tmpResponse = $objResponses->toArray();
     $i = 0;
     for ($i; $i < $objResponses->count(); $i++) {
         $rs = SharcUser::find($objResponses[$i]->userId);
         if ($rs != null) {
             $tmpResponse[$i]["userId"] = $rs->username;
         }
         //get entity name as well
     }
     $response["data"]["allResponses"] = $tmpResponse;
     //Get all PoiType of the experience
     $objPoiTypes = SharcPoiType::where('designerId', $designerId)->get();
     $response["data"]["allPoiTypes"] = $objPoiTypes->toArray();
     return $response;
 }