/**
  * @param string          $story
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  * @param                 $origin
  * @param int             $privacyType
  * @param int             $privacyValue
  * @param array           $params
  *
  * @return Feed
  */
 public function add($story = '', PosterInterface $poster, PosterInterface $parent = null, $origin, $privacyType = 1, $privacyValue = 1, $params = [])
 {
     $about = null;
     $content = null;
     $parentShareId = 0;
     $feedId = 0;
     if (null == $parent) {
         $parent = $poster;
     }
     if ($origin instanceof Feed) {
         $content = $origin->getAbout();
         $feedId = $origin->getId();
     } else {
         $content = $origin;
     }
     if (empty($about)) {
         $about = $content;
     }
     if ($about instanceof Share) {
         $parentShareId = $content->getId();
         $about = $about->getAbout();
     }
     $share = new Share(['user_id' => $poster->getUserId(), 'feed_id' => 0, 'story' => $story, 'poster_id' => $poster->getId(), 'parent_share_id' => (int) $parentShareId, 'poster_type' => $poster->getType(), 'parent_user_id' => $parent->getUserId(), 'parent_id' => $parent->getId(), 'parent_type' => $parent->getType(), 'about_id' => $about->getId(), 'about_type' => $about->getType(), 'params_text' => json_encode($params), 'privacy_type' => $privacyType, 'privacy_value' => $privacyValue, 'privacy_text' => json_encode(['view' => ['type' => $privacyType, 'value' => $privacyValue]])]);
     $share->save();
     $feed = app()->feedService()->addItemFeed('share', $share);
     $share->setFeedId($feed->getId());
     $share->save();
     return $feed;
 }
 /**
  * @param PosterInterface           $poster
  * @param AtomInterface             $about
  * @param                           $content
  * @param array                     $params
  *
  * @return \Platform\Comment\Model\Comment
  */
 public function add(PosterInterface $poster, AtomInterface $about, $content, $params = [])
 {
     $parent = $about->getParent();
     $params = array_merge(['about_id' => $about->getId(), 'poster_id' => $poster->getId(), 'user_id' => $poster->getUserId(), 'about_type' => $about->getType(), 'poster_type' => $poster->getType(), 'parent_id' => $parent->getId(), 'parent_user_id' => $parent->getUserId(), 'parent_type' => $parent->getType(), 'content' => strip_tags(html_entity_decode($content)), 'created_at' => KENDO_DATE_TIME, 'modified_at' => KENDO_DATE_TIME], $params);
     $comment = new Comment($params);
     $comment->save();
     return $comment;
 }
 /**
  * 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 PosterInterface $poster
  * @param PosterInterface $parent
  *
  * @return int
  */
 public function getMembershipStatus(PosterInterface $poster, PosterInterface $parent)
 {
     if (null == $poster || null == $parent) {
         return [];
     }
     $posterId = $poster->getId();
     $parentId = $parent->getId();
     if ($parent->getUserId() == $posterId) {
         return RELATION_TYPE_OWNER;
     }
     $highestRelation = app()->relation()->getListRelationType($posterId, $parentId);
     if ($highestRelation) {
         return $highestRelation;
     }
     /**
      * Received request?
      */
     $status = app()->table('platform_relation_request')->select()->where('poster_id=?', $parentId)->where('parent_id = ?', $posterId)->where('status NOT IN ?', ['canceled', 'ignored', 'accepted'])->field('status');
     if ($status) {
         return self::REQUEST_RECEIVED;
     }
     /**
      * Sent request?
      */
     $status = app()->table('platform_relation_request')->select()->where('poster_id=?', $posterId)->where('parent_id = ?', $parentId)->where('status NOT IN ?', ['canceled', 'ignored', 'accepted'])->field('status');
     if ($status) {
         return self::REQUEST_SENT;
     }
     // check what is happended in this case
     return self::IS_EMPTY;
 }
 /**
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  * @param array           $params
  *
  * @return Group
  */
 public function addGroup(PosterInterface $poster, PosterInterface $parent, $params = [])
 {
     $group = new Group(['user_id' => $poster->getUserId(), 'poster_id' => $poster->getId(), 'poster_type' => $poster->getType(), 'parent_id' => $parent->getId(), 'parent_type' => $parent->getType(), 'parent_user_id' => $parent->getUserId(), 'created_at' => KENDO_DATE_TIME, 'modified_at' => KENDO_DATE_TIME]);
     $group->setFromArray($params);
     $group->save();
     return $group;
 }
 /**
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  * @param array           $params
  * @param int             $privacyType
  * @param int             $privacyValue
  *
  * @return Video
  */
 public function addVideo(PosterInterface $poster, PosterInterface $parent, $params = [], $privacyType = null, $privacyValue = null)
 {
     if (null === $privacyType || null === $privacyValue) {
         $privacyType = RELATION_TYPE_ANYONE;
         $privacyValue = RELATION_TYPE_ANYONE;
     }
     $data = array_merge(['user_id' => $poster->getUserId(), 'poster_id' => $poster->getId(), 'poster_type' => $poster->getType(), 'parent_id' => $parent->getId(), 'parent_type' => $parent->getType(), 'parent_user_id' => $parent->getUserId(), 'module_id' => 'video', 'privacy_type' => $privacyType, 'privacy_value' => $privacyValue, 'created_at' => KENDO_DATE_TIME, 'modified_at' => KENDO_DATE_TIME], $params);
     $video = new Video($data);
     $video->save();
     return $video;
 }
 /**
  * Send new notification to receiver(parent) from poster(sender)
  *
  * @param string                           $type
  * @param PosterInterface                  $poster
  * @param PosterInterface                  $parent
  * @param ContentInterface|PosterInterface $about
  * @param                                  $params
  *
  * @return Platform\Notification
  */
 public function addNotification($type, PosterInterface $poster, PosterInterface $parent, $about = null, $params = [])
 {
     if (!$about) {
         $about = $poster;
     }
     $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(), 'about_type' => $about->getType(), 'about_id' => $about->getId(), 'params' => json_encode($params), 'created_at' => KENDO_DATE_TIME];
     if (null != $about) {
         $data = array_merge($data, ['about_id' => $about->getId(), 'about_type' => $about->getType()]);
     }
     $item = new Notification($data);
     $item->save();
     return $item;
 }
示例#8
0
 /**
  * @param ContentInterface|PosterInterface $item
  *
  * @return bool
  */
 public function isPoster($item)
 {
     if (!$this->logged()) {
         return false;
     }
     return (bool) array_intersect([$this->getId(), $this->getUserId()], [$item->getId(), $item->getPosterId(), $item->getUserId()]);
 }
示例#9
0
 /**
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  * @param array           $data
  *
  * @return \Platform\Blog\Model\BlogPost
  */
 public function addPost(PosterInterface $poster, PosterInterface $parent, $data = [])
 {
     if (empty($data['title']) or empty($data['content'])) {
         throw new \InvalidArgumentException("Missing parameters  [title, content]");
     }
     // truncate description
     if (empty($data['description'])) {
         $data['description'] = mb_substr(strip_tags($data['content']), 0, 500);
     }
     $data = array_merge(['user_id' => $poster->getUserId(), 'poster_id' => $poster->getId(), 'poster_type' => $poster->getType(), 'parent_id' => $parent->getId(), 'parent_type' => $parent->getType(), 'parent_user_id' => $parent->getUserId(), 'created_at' => KENDO_DATE_TIME, 'modified_at' => KENDO_DATE_TIME, 'module_id' => 'blog'], $data);
     $post = new BlogPost($data);
     $post->save();
     return $post;
 }
示例#10
0
 /**
  * @param array                            $fileId
  * @param PosterInterface                  $poster
  * @param PosterInterface                  $parent
  * @param \Platform\Photo\Model\PhotoAlbum $album
  * @param array                            $params
  *
  * @return \Platform\Photo\Model\Photo
  */
 public function addPhoto($fileId, PosterInterface $poster, PosterInterface $parent = null, PhotoAlbum $album = null, $params = [])
 {
     if (null == $parent) {
         $parent = $poster;
     }
     if (null == $album) {
         $album = $this->getSingletonAlbum($parent);
     }
     $photo = new Photo(['album_id' => $album->getId(), 'collection_id' => 0, 'user_id' => $poster->getUserId(), 'poster_id' => $poster->getId(), 'poster_type' => $poster->getType(), 'parent_id' => $parent->getId(), 'parent_type' => $parent->getType(), 'parent_user_id' => $parent->getUserId(), 'photo_file_id' => (int) $fileId, 'title' => '', 'content' => '', 'created_at' => KENDO_DATE_TIME, 'modified_at' => KENDO_DATE_TIME]);
     $photo->setFromArray($params);
     $photo->save();
     $album->setPhotoCount($album->getPhotoCount() + 1);
     if ($album->getPhotoFileId() == 0) {
         $album->setPhotoFileId($photo->getPhotoFileId());
     }
     $album->save();
     return $photo;
 }
示例#11
0
 /**
  * @param string          $status
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  * @param int             $privacyType
  * @param int             $privacyValue
  *
  * @return FeedStatus
  */
 public function addStatus($status, PosterInterface $poster, PosterInterface $parent = null, $privacyType, $privacyValue)
 {
     if (!$parent->viewerIsParent()) {
         list($privacyType, $privacyValue) = $parent->getPrivacy('activity__share_status');
     }
     $privacyText = json_encode(['view' => ['type' => $privacyType, 'value' => $privacyValue]]);
     $status = new FeedStatus(['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(), 'story' => (string) $status, 'privacy_type' => $privacyType, 'privacy_value' => $privacyValue, 'privacy_text' => $privacyText, 'created_at' => KENDO_DATE_TIME, 'modified_at' => KENDO_DATE_TIME]);
     $status->save();
     return $status;
 }
示例#12
0
 /**
  * @param                 $params
  * @param PosterInterface $poster
  * @param PosterInterface $parent
  * @param int             $privacyType
  * @param int             $privacyValue
  *
  * @return \Platform\Link\Model\Link
  */
 public function addLink($params, PosterInterface $poster, PosterInterface $parent, $privacyType, $privacyValue)
 {
     if (null === $privacyType || null == $privacyValue) {
         $privacyType = RELATION_TYPE_ANYONE;
         $privacyValue = RELATION_TYPE_ANYONE;
     }
     $data = array_merge(['poster_id' => $poster->getId(), 'parent_id' => $parent->getId(), 'poster_type' => $poster->getType(), 'parent_type' => $parent->getType(), 'user_id' => $poster->getUserId(), 'privacy_type' => $privacyType, 'privacy_value' => $privacyValue, 'created_at' => KENDO_DATE_TIME, 'modified_at' => KENDO_DATE_TIME, 'privacy_text' => json_encode(['view' => ['type' => $privacyType, 'value' => $privacyType]])], $params);
     $link = new Link($data);
     $link->save();
     return $link;
 }