/** * @param PosterInterface $parent * @param PosterInterface $poster * @param $forAction * @param int $relationType * @param int $relationId * * @return string */ public function getRelationOptionForSelect(PosterInterface $parent = null, PosterInterface $poster = null, $forAction, $relationType = null, $relationId = null) { if (empty($parent) or empty($poster)) { return false; } if ($poster->getUserId() != $parent->getUserId()) { return false; } if (null === $relationId || null === $relationType) { list($relationType, $relationId) = $parent->getPrivacy($forAction); } if (null == $relationId) { $relationType = RELATION_TYPE_ANYONE; $relationId = RELATION_TYPE_ANYONE; } $parentType = $parent->getType(); $msgId = null; if ($relationType < RELATION_TYPE_CUSTOM) { return ['type' => $relationType, 'value' => $relationId, 'label' => app()->text('relation.relation_type_' . $parentType . '_' . $relationType)]; } $item = app()->relation()->findById($relationId); if (!$item instanceof Relation) { return ['type' => RELATION_TYPE_ANYONE, 'value' => RELATION_TYPE_ANYONE, 'label' => 'relation.relation_type_public']; } return ['type' => $item->getRelationType(), 'value' => $item->getRelationId(), 'label' => strtr($item->getRelationName(), ['$parent' => $parent->getTitle()])]; }
/** * @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; }