/**
  * Configuration Action for Super Admins
  */
 public function actionIndex()
 {
     $query = ReportContent::find()->joinWith('content')->andWhere(['IS', 'content.space_id', new \yii\db\Expression('NULL')]);
     $countQuery = clone $query;
     $pagination = new \yii\data\Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
     $query->offset($pagination->offset)->limit($pagination->limit);
     return $this->render('index', array('reportedContent' => $query->all(), 'pagination' => $pagination));
 }
 public function up()
 {
     $this->renameClass('ReportContent', ReportContent::className());
     // Only allow posts during upgrade to namespaced version
     $this->delete('report_content', ['!=', 'object_model', 'Post']);
     // Namespace object_model
     $this->update('report_content', ['object_model' => Post::className()], ['object_model' => 'Post']);
     // Remove all open notifications
     $this->delete('notification', ['class' => 'NewReportAdminNotification']);
     $this->delete('notification', ['class' => 'NewReportNotification']);
 }
 public static function onIntegrityCheck($event)
 {
     $integrityController = $event->sender;
     $integrityController->showTestHeadline("ReportContent Module (" . ReportContent::find()->count() . " entries)");
     foreach (ReportContent::find()->joinWith('content')->all() as $rc) {
         if ($rc->content === null) {
             if ($integrityController->showFix("Deleting report id " . $rc->id . " without existing content!")) {
                 $rc->delete();
             }
         }
     }
 }
 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'));
     }
 }
 /**
  * Executes the widget.
  */
 public function run()
 {
     if (get_class($this->content) == Post::className() && ReportContent::canReportPost($this->content->id)) {
         return $this->render('reportSpamLink', array('object' => $this->content, 'model' => new ReportReasonForm()));
     }
 }
 /**
  * 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;
 }
</p>
                            <br/>    
                            <small class="media">
                                <span class="time"><?php 
        echo Yii::t('ReportcontentModule.base', 'created by :displayName', array(':displayName' => Html::a(Html::encode($report->getSource()->content->user->displayName), $report->getSource()->content->user->getUrl())));
        ?>
</span>
                                <?php 
        echo \humhub\widgets\TimeAgo::widget(['timestamp' => $report->getSource()->created_at]);
        ?>
                            </small>     
                        </div>
                    </td>
                    <td style="font-weight:bold; vertical-align:middle">
                        <?php 
        echo ReportContent::getReason($report->reason);
        ?>
                    </td>
                    <td width="52px">
                        <a href="<?php 
        echo $report->user->getUrl();
        ?>
">

                            <img class="media-object img-rounded"
                                 src="<?php 
        echo $report->user->profileImage->getUrl();
        ?>
" width="48"
                                 height="48" alt="48x48" data-src="holder.js/48x48"
                                 style="width: 48px; height: 48px;">