/**
  * @param ContentInterface $content
  * @param int              $limit
  *
  * @return array
  */
 public function loadPeople(ContentInterface $content, $limit = null)
 {
     $select = app()->table('platform_tag_people')->select()->where('content_id=?', $content->getId());
     if ($limit) {
         $select->limit($limit, 0);
     }
     $pairs = $select->toPairs('poster_id', 'poster_type');
     $idList = [];
     foreach ($pairs as $id => $type) {
         $idList[$type][] = $id;
     }
     foreach ($idList as $type => $list) {
         foreach (app()->table($type)->findByIdList($list) as $item) {
             if ($item instanceof PosterInterface) {
                 $id = $item->getId();
                 $pairs[$id] = $item;
             }
         }
     }
     foreach ($pairs as $id => $item) {
         if (is_string($item)) {
             unset($pairs[$id]);
         }
     }
     return $pairs;
 }
 /**
  * @param PosterInterface  $poster
  * @param ContentInterface $object
  *
  * @return bool
  */
 public function remove(PosterInterface $poster, ContentInterface $object)
 {
     $review = $this->findReview($poster->getId(), $object->getId());
     if (null != $review) {
         $review->delete();
     }
     return false;
 }
 /**
  * Add request from poster to parent
  *
  * @param string           $type
  * @param PosterInterface  $poster
  * @param PosterInterface  $parent
  * @param ContentInterface $object
  *
  * @return \Platform\Invitation\Model\Invitation
  */
 public function addRequest($type, PosterInterface $poster, PosterInterface $parent, ContentInterface $object = null)
 {
     $data = ['type_id' => $type, 'poster_id' => $poster->getId(), 'user_id' => $poster->getUserId(), 'parent_id' => $parent->getId(), 'parent_user_id' => $parent->getUserId(), 'poster_type' => $poster->getType(), 'parent_type' => $parent->getType(), 'created_at' => KENDO_DATE_TIME];
     if (null != $object) {
         $data = array_merge($data, ['object_id' => $object->getId(), 'object_type' => $object->getType()]);
     }
     $request = new Invitation($data);
     $request->save();
     return $request;
 }
 /**
  * @param  ContentInterface $about
  * @param  int              $limit
  * @param  int              $offset
  *
  * @return array
  */
 public function getListSubscriber($about, $limit = 100, $offset = 0)
 {
     return app()->table('platform_notification_subscribe')->select()->where('about_id=?', $about->getId())->limit($limit, $offset)->order('created_at', 1)->all();
 }
 /**
  * @param \Kendo\Content\PosterInterface                                 $poster
  * @param \Kendo\Content\ContentInterface|\Kendo\Content\PosterInterface $about
  * @param array                                                          $data
  *
  * @return Report
  */
 public function addReport($poster, $about, $data = [])
 {
     $data = array_merge(['poster_id' => $poster->getId(), 'poster_type' => $poster->getType(), 'about_type' => $about->getType(), 'about_id' => $about->getId(), 'created_at' => KENDO_DATE_TIME], $data);
     /**
      *
      */
     $item = new Report($data);
     $item->save();
     return $item;
 }
 /**
  * @param ContentInterface|PosterInterface $item
  *
  * @return bool
  */
 public function isParent($item)
 {
     if (!$this->logged()) {
         return false;
     }
     return (bool) array_intersect([$this->getId(), $this->getUserId()], [$item->getId(), $item->getParentId(), $item->getParentUserId()]);
 }
 /**
  * @param ContentInterface $about
  *
  * @return array
  */
 public function loadAboutBundles(ContentInterface $about)
 {
     $limitCommentCount = 3;
     $remainCommentCount = 0;
     $poster = app()->auth()->getViewer();
     $commentService = app()->commentService();
     $likeService = app()->likeService();
     if ($about instanceof ContentInterface) {
         if ($about->getCommentCount() > $limitCommentCount) {
             $remainCommentCount = $about->getCommentCount() - $limitCommentCount;
         }
     }
     $place = null;
     $story = null;
     $people = null;
     $shareCount = null;
     $story = $about->getStory();
     $people = $this->decorateTagPeople($about->getPeople());
     $place = $about->getPlace();
     $shareCount = $about->getShareCount();
     return ['place' => $place, 'hasStory' => !empty($story), 'story' => $story, 'people' => $people, 'hasAttachment' => !$about instanceof FeedStatus, 'attachmentId' => $about->getId(), 'about' => $about, 'shareCount' => $shareCount, 'poster' => $about->getPoster(), 'commentList' => $commentService->getCommentList($about, 0, 0, $limitCommentCount), 'limitCommentCount' => $limitCommentCount, 'remainCommentCount' => $remainCommentCount, 'like' => $likeService->getLikeResult($poster, $about, 2)];
 }