public function actionAppropriate()
 {
     $this->forcePostRequest();
     $reportId = Yii::$app->request->get('id');
     $report = ReportContent::findOne(['id' => $reportId]);
     if ($report->canDelete()) {
         $report->delete();
     }
     if (!$report->content->space_id) {
         return $this->htmlRedirect(Url::to(['/reportcontent/admin']));
     } else {
         $space = Space::findOne(['id' => $report->content->space_id]);
         return $this->htmlRedirect($space->createUrl('/reportcontent/space-admin'));
     }
 }
 /**
  * Checks if the given or current user can report post with given id.
  *
  * @param
  *            int postId
  */
 public static function canReportPost($postId, $userId = "")
 {
     if (Yii::$app->user->isGuest) {
         return false;
     }
     $post = Post::findOne(['id' => $postId]);
     if (!$post) {
         return false;
     }
     if ($userId != "") {
         $user = User::findOne(['id' => $userId]);
     } else {
         $user = Yii::$app->user->getIdentity();
     }
     if (!$user) {
         return false;
     }
     if ($user->super_admin) {
         return false;
     }
     if ($post->created_by == $user->id) {
         return false;
     }
     if ($post->content->container instanceof Space && ($post->content->getContainer()->isAdmin($user->id) || $post->content->getContainer()->isAdmin($post->created_by))) {
         return false;
     }
     if (ReportContent::findOne(['object_model' => Post::className(), 'object_id' => $post->id, 'created_by' => $user->id]) !== null) {
         return false;
     }
     if (User::findOne(['id' => $post->created_by, 'super_admin' => 1]) !== null) {
         return false;
     }
     return true;
 }