/**
  * Handle Ajax call for upvote/downvote of post
  */
 public function actionUpvote()
 {
     if (!Yii::$app->user->can('app.forum.forum.upvote')) {
         throw new ForbiddenHttpException(YBoard::t('yboard', 'You have no enough permission to access this page! If you think its a mistake, please consider reporting to us.'));
     }
     $json = [];
     if (isset($_POST['id'])) {
         $criteria = ['member_id' => Yii::$app->user->identity->id, 'post_id' => $_POST['id']];
         if (YBoardUpvoted::find()->where($criteria)->count() > 0) {
             // remove upvote
             YBoardUpvoted::deleteAll($criteria);
             $post = YBoardPost::findOne($_POST['id']);
             $topic = YBoardTopic::findOne($post->topic_id);
             $member = YBoardMember::findOne($post->user_id);
             $post->updateCounters(array('upvoted' => -1));
             $topic->updateCounters(array('upvoted' => -1));
         } else {
             // add upvote
             $upvote = new YBoardUpvoted();
             $upvote->member_id = Yii::$app->user->id;
             $upvote->post_id = $_POST['id'];
             $upvote->author = $_POST['author'];
             $upvote->save();
             $post = YBoardPost::findOne($_POST['id']);
             $topic = YBoardTopic::findOne($post->topic_id);
             $member = YBoardMember::findOne($post->user_id);
             $post->updateCounters(array('upvoted' => 1));
             $topic->updateCounters(array('upvoted' => 1));
         }
         $json['success'] = 'yes';
         $json['html'] = $this->showUpvote($_POST['id']);
     } else {
         $json['success'] = 'no';
     }
     echo json_encode($json);
     Yii::$app->end();
 }