/** * @param ContentInterface $about * @param PosterInterface $viewer * * @return string */ public function getPrivacyLabel(ContentInterface $about, PosterInterface $viewer = null) { $isOwner = false; /** * Is poster of content */ if ($about->viewerIsParent()) { $isOwner = true; } $relationType = $about->getPrivacyType(); $parentType = $about->getParentType(); if ($relationType < RELATION_TYPE_CUSTOM) { switch ($relationType) { case RELATION_TYPE_ANYONE: $msgId = 'relation.privacy_label_public'; break; case RELATION_TYPE_OWNER: $msgId = 'relation.' . $parentType . '_privacy_label_owner'; break; case RELATION_TYPE_MEMBER_OF_MEMBER: $msgId = 'relation.' . $parentType . '_privacy_label_member_of_members'; break; case RELATION_TYPE_ADMIN: $msgId = 'relation.' . $parentType . '_privacy_label_admin'; break; case RELATION_TYPE_EDITOR: $msgId = 'relation.' . $parentType . '_privacy_label_editor'; break; case RELATION_TYPE_MEMBER: $msgId = 'relation.' . $parentType . '_privacy_label_member'; break; case RELATION_TYPE_REGISTERED: $msgId = 'relation.' . $parentType . '_privacy_label_registered'; break; default: $msgId = 'relation.' . $parentType . '_privacy_label_custom'; } } if (empty($msgId)) { $relationId = $about->getPrivacyValue(); $item = $this->findById($relationId); if ($item) { $msgId = $item->getRelationTitle(); } } if (empty($msgId)) { $msgId = 'relation.' . $about->getParentType() . '_privacy_label_custom'; } /** * */ $parent = $about->getParent(); if ($isOwner) { return app()->text($msgId, ['$parent\'s' => 'Your', '$parent' => 'You']); } $label = $parent->getTitle(); return app()->text($msgId, ['$parent' => $label]); }
/** * @param string $feedType * @param ContentInterface $about * @param array $params * * @return Feed * @throws \InvalidArgumentException */ public function addItemFeed($feedType, ContentInterface $about, $params = []) { list($privacyType, $privacyValue) = $about->getPrivacy('view'); $poster = app()->find($about->getPosterType(), $about->getPosterId()); $parent = app()->find($about->getParentType(), $about->getParentId()); $story = null; $hashtag = null; $peopletag = null; $story = $about->getStory(); $peopletag = $about->getPeople(); if (!empty($story)) { $hashtag = $this->getHashTagsInStory($story); } // parse story content to load hash tags. $feed = new Feed(['feed_type' => $feedType, 'poster_id' => $about->getPosterId(), 'poster_type' => $about->getPosterType(), 'parent_id' => $about->getParentId(), 'parent_type' => $about->getParentType(), 'about_id' => $about->getId(), 'about_type' => $about->getType(), 'privacy_type' => (int) $privacyType, 'privacy_value' => (int) $privacyValue, 'created_at' => KENDO_DATE_TIME, 'params_text' => json_encode($params)]); $feed->save(); $feed->validate(true, false); /** * add feed to hashtag list */ if (!empty($hashtag)) { foreach ($hashtag as $tag) { $this->addHashTag($feed, $tag); } } $this->putFeedToStream($feed, $poster, $parent, $peopletag); app()->notificationService()->subscribe($poster, $about); return $feed; }