Exemplo n.º 1
0
 private function afterCommentCreate()
 {
     $post = Content::model()->findByPk($this->owner->new_entity_id);
     if (!$post) {
         return;
     }
     $apps = Application::model()->byChannel('user_channel')->findAll();
     /**
      * @var Application $app;
      */
     foreach ($apps as $app) {
         $gcm = new GcmSender($post->authorId, $app->gcm_conf);
         $gcm->setType(Types::NEW_COMMENT)->setId((int) $this->owner->new_entity_id)->setAppId($app->_id);
         if (!($post->authorId == $this->owner->author_id)) {
             $topic = new GcmTopic();
             $topic->setChannel(Channels::USER)->setId($post->authorId);
             $gcm->sendToTopic($topic);
         }
     }
     $this->commentInPost($post);
     if ($this->owner->response_id) {
         $root = Comment::model()->findByPk($this->owner->response_id);
         if (!$root || $root->author_id == $this->owner->author_id) {
             return;
         }
         foreach ($apps as $app) {
             $gcm = new GcmSender($root->author_id, $app->gcm_conf);
             $gcm->setType(Types::NEW_COMMENT_ANSWER)->setId((int) $this->owner->new_entity_id)->setAppId($app->_id);
             $topic = new GcmTopic();
             $topic->setChannel(Channels::USER)->setId($root->author_id);
             $gcm->sendToTopic($topic);
         }
     }
 }
Exemplo n.º 2
0
 public function getPostComments()
 {
     $require = array('entity_id' => true, 'service' => true, 'count' => false);
     $params = $this->controller->getParams($require);
     $aliases = array('oldBlog' => 'BlogContent', 'oldCommunity' => 'CommunityContent', 'photopost' => 'NewPhotoPost');
     $where = "entity_id = {$params['entity_id']} and entity = '{$aliases[$params['service']]}'";
     if (isset($params['count'])) {
         $this->controller->data = array('comments_count' => Comment::model()->count($where));
     } else {
         $this->controller->get(Comment::model(), $this, $where);
     }
 }
Exemplo n.º 3
0
 public function deleteComment()
 {
     $this->controller->getActionProperties()->setModel(Comment::model())->setRequire(array('id' => true, 'action' => true))->setAccess(array('manageOwnContent', array('entity' => 'Record')));
     $this->controller->delete();
 }