/**
  * Handles AJAX Post Request to submit new Comment
  */
 public function actionPost()
 {
     $this->forcePostRequest();
     if (Yii::$app->user->isGuest) {
         throw new HttpException(403, 'Guests can not comment.');
     }
     if (!Yii::$app->getModule('comment')->canComment($this->parentContent->content)) {
         throw new HttpException(403, 'You are not allowed to comment.');
     }
     $message = Yii::$app->request->post('message');
     $files = Yii::$app->request->post('fileList');
     if (trim($message) === '' && trim($files) === '') {
         // do not create empty comments
         return '';
     }
     $comment = new Comment();
     $comment->message = $message;
     $comment->object_model = $this->parentContent->className();
     $comment->object_id = $this->parentContent->getPrimaryKey();
     $comment->save();
     \humhub\modules\file\models\File::attachPrecreated($comment, $files);
     // Reload comment to get populated created_at field
     $comment->refresh();
     return $this->renderAjaxContent(\humhub\modules\comment\widgets\Comment::widget(['comment' => $comment, 'justEdited' => true]));
 }
 /**
  * Handles AJAX Post Request to submit new Comment
  */
 public function actionPost()
 {
     $this->forcePostRequest();
     $message = Yii::$app->request->post('message');
     if ($message != "" && !Yii::$app->user->isGuest) {
         $comment = new Comment();
         $comment->message = $message;
         $comment->object_model = $this->parentContent->className();
         $comment->object_id = $this->parentContent->getPrimaryKey();
         $comment->save();
         \humhub\modules\file\models\File::attachPrecreated($comment, Yii::$app->request->post('fileList'));
         // Reload comment to get populated created_at field
         $comment = Comment::findOne(['id' => $comment->id]);
         return $this->renderAjaxContent(\humhub\modules\comment\widgets\Comment::widget(['comment' => $comment, 'justEdited' => true]));
     }
 }