/** * 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; }
/** * @param HttpRequest $request * @param PosterInterface $poster * @param PosterInterface $parent * * @return \Platform\Feed\Model\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'); $data = $request->getArray('video'); $data['story'] = $statusTxt; $video = $this->addVideo($poster, $parent, $data, $privacyType, $privacyValue); $needUpdate = false; $place = $request->getArray('place'); if (!empty($place)) { $video->setPlace($place); $needUpdate = true; } $people = $request->getArray('people'); if (!empty($people)) { $video->setPeople($people); $needUpdate = true; } if ($needUpdate) { $video->save(); } $feed = app()->feedService()->addItemFeed('video_shared', $video); return $feed; }
/** * @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; }