Ejemplo n.º 1
0
 /**
  * @param HttpRequest     $request
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  *
  * @return \Platform\Feed\Model\Feed
  */
 public function addFromCommentComposer(HttpRequest $request, PosterInterface $poster, PosterInterface $parent)
 {
     $privacy = $request->getArray('privacy');
     $privacyType = 1;
     $privacyValue = 1;
     if (!empty($privacy)) {
         $privacyType = $privacy['type'];
         $privacyValue = $privacy['value'];
     }
     $data = $request->getArray('video');
     $video = $this->addVideo($poster, $parent, $data, $privacyType, $privacyValue);
     return $video;
 }
Ejemplo n.º 2
0
 /**
  * @param HttpRequest     $request
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  *
  * @return Feed
  */
 public function addFromActivityComposer(HttpRequest $request, PosterInterface $poster, PosterInterface $parent)
 {
     $privacy = $request->getArray('privacy');
     $privacyType = 1;
     $privacyValue = 1;
     if (!empty($privacy)) {
         $privacyType = $privacy['type'];
         $privacyValue = $privacy['value'];
     }
     $statusTxt = $request->getString('statusTxt');
     $status = $this->addStatus($statusTxt, $poster, $parent, $privacyType, $privacyValue);
     $needUpdate = false;
     $place = $request->getArray('place');
     if (!empty($place)) {
         $status->setPlace($place);
         $needUpdate = true;
     }
     $people = $request->getArray('people');
     if (!empty($people)) {
         $status->setPeople($people);
         $needUpdate = true;
     }
     if ($needUpdate) {
         $status->save();
     }
     $feed = $this->addItemFeed('update_status', $status);
     return $feed;
 }
Ejemplo n.º 3
0
 /**
  * Add photo from activity composer
  *
  * @see FeedController::actionPost()
  *
  * @param HttpRequest     $request
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  *
  * @return \Platform\Feed\Model\Feed
  */
 public function addFromActivityComposer(HttpRequest $request, PosterInterface $poster, PosterInterface $parent)
 {
     // process upload photo to handler set.
     $photoTemp = $request->getArray('photoTemp');
     $fileIdList = $this->processPhotoUploadFromTemporary($photoTemp, null);
     $object = null;
     $feed = null;
     $album = $this->getSingletonAlbum($parent);
     if (!$album instanceof PhotoAlbum) {
         throw new \InvalidArgumentException();
     }
     list($totalPhoto, $photoList, $album, $collection) = $this->addPhotos($fileIdList, $poster, $parent, $album, [], false);
     if ($totalPhoto == 1) {
         $object = $photoList[0];
     }
     if ($totalPhoto > 1) {
         $object = $collection;
     }
     // process to add feed
     $activityService = app()->feedService();
     if ($object instanceof PhotoCollection) {
         $feed = $activityService->addItemFeed('update_status', $object);
     } else {
         if ($object instanceof Photo) {
             $feed = $activityService->addItemFeed('update_status', $object);
         }
     }
     $statusTxt = $request->getString('statusTxt');
     $place = $request->getArray('place');
     if (!empty($place)) {
         foreach ($photoList as $photo) {
             if (!$photo instanceof Photo) {
             }
             $photo->setPlace($place);
             $photo->save();
         }
     }
     $shouldUpdate = false;
     if ($statusTxt) {
         $object->setStory($statusTxt);
         $shouldUpdate = true;
     }
     if (!empty($place)) {
         $object->setPlace($place);
         $shouldUpdate = true;
     }
     $people = $request->getArray('people');
     if (!empty($people)) {
         $peopleCount = app()->tagService()->tagPeople($object, $people);
         $object->setPeopleCount($peopleCount);
         $shouldUpdate = true;
     }
     if ($shouldUpdate) {
         $object->save();
     }
     return $feed;
 }
Ejemplo n.º 4
0
 /**
  * @param HttpRequest     $request
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  *
  * @return Feed
  */
 public function addFromActivityComposer(HttpRequest $request, PosterInterface $poster, PosterInterface $parent)
 {
     $privacy = $request->getArray('privacy');
     $privacyType = 1;
     $privacyValue = 1;
     if (!empty($privacy)) {
         $privacyType = $privacy['type'];
         $privacyValue = $privacy['value'];
     }
     $story = $request->getString('statusTxt');
     $data = $request->getArray('link');
     $data['story'] = $story;
     $link = $this->addLink($data, $poster, $parent, $privacyType, $privacyValue);
     $needUpdate = false;
     $place = $request->getArray('place');
     if (!empty($place)) {
         $link->setPlace($place);
         $needUpdate = true;
     }
     $people = $request->getArray('people');
     if (!empty($people)) {
         $link->setPeople($people);
         $needUpdate = true;
     }
     if ($needUpdate) {
         $link->save();
     }
     $feed = app()->feedService()->addItemFeed('update_status', $link);
     return $feed;
 }