/** * Adds a new post * * @param KCommandContext $context Context parameter * * @return void */ protected function _actionAdd($context) { $data = $context->data; $entity = parent::_actionAdd($context); //if a person posting a message on his profile //or if a target is not actor then it can't be a private message if (get_viewer()->eql($this->actor) || !is_person($this->actor)) { unset($data->private); } //if a private message then //set the privacy to subject/target if ($data->private) { $entity->setAccess(array($this->actor->id, get_viewer()->id)); } //create a notification for the subscribers and //the post owner as well if ($entity->owner->isSubscribable()) { //create a notification and pass the owner $notification = $this->createNotification(array('name' => 'note_add', 'object' => $entity, 'subscribers' => array($entity->owner->subscriberIds->toArray(), $entity->owner)))->setType('post', array('new_post' => true)); } if (!empty($data['channels'])) { $this->shareObject(array('object' => $entity, 'sharers' => $data['channels'])); } return $entity; }
/** * When a topic is added, then create a notification. * * @param KCommandContext $context Context parameter */ protected function _actionAdd($context) { $entity = parent::_actionAdd($context); if ($entity->owner->isSubscribable()) { $notification = $this->createNotification(array('name' => 'topic_add', 'object' => $entity, 'subscribers' => $entity->owner->subscriberIds->toArray()))->setType('post', array('new_post' => true)); } return $entity; }