예제 #1
0
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         //update users online information
         $this->updateOnlineStatus($action);
         // register visit by webspider
         if (isset($_SERVER['HTTP_USER_AGENT'])) {
             $spider = YBoardSpider::find()->where(['user_agent' => $_SERVER['HTTP_USER_AGENT']])->one();
         } else {
             $spider = null;
         }
         if ($spider != null) {
             $spider->setScenario('visit');
             $spider->hits++;
             $spider->last_visit = null;
             $spider->save();
         }
         //menu fixed for Views
         $approvals1 = YBoardPost::find()->unapprovedScope()->count();
         $approvals2 = YBoardTopic::find()->andWhere(['approved' => 0])->count();
         $reports = YBoardMessage::find()->reportScope()->unreadScope()->count();
         $this->params['foroMenu'] = [['label' => Yii::t('app', 'Members'), 'url' => ['member/index']], ['label' => Yii::t('app', 'Pending') . ' (' . ($approvals1 + $approvals2) . ')', 'url' => ['moderator/approve'], 'visible' => Yii::$app->user->can('moderator')], ['label' => Yii::t('app', 'Reported') . ' (' . $reports . ')', 'url' => ['moderator/reported'], 'visible' => Yii::$app->user->can('moderator')]];
         return true;
     } else {
         return false;
     }
 }
예제 #2
0
		<div class="col-md-7"> 
            <div class="row statistics">
                <div class="col-md-12 header2">
                    <?php 
echo YBoard::t('yboard', 'Board Statistics');
?>
                </div>
            </div>
            
            <div class="row">
                <div class="col-md-2"><?php 
echo YBoard::t('yboard', 'Total topics');
?>
</div> 
                <div class="col-md-1"><?php 
echo YBoardTopic::find()->count();
?>
</div> 
                <div class="col-md-9"></div> 
            </div>
            
            <div class="row">
                <div class="col-md-2"><?php 
echo YBoard::t('yboard', 'Total posts');
?>
</div> 
                <div class="col-md-1"><?php 
echo YBoardPost::find()->count();
?>
</div> 
                <div class="col-md-9"></div> 
예제 #3
0
 /**
  * Reset the first post id of a topic when a first post is deleted
  */
 private function resetFirstTopicPost()
 {
     $model = YBoardTopic::find()->where(['first_post_id' => $this->id])->one();
     if ($model !== null) {
         $post = YBoardPost::find()->where(['topic_id' => $model->id])->orderBy('id DESC')->one();
         if ($post !== null) {
             $model->user_id = $post->user_id;
             $model->first_post_id = $post->id;
             $model->save();
         }
     }
 }
 public function actionTopic()
 {
     if (!Yii::$app->user->can('app.forum.moderator.topic')) {
         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'])) {
         $model = YBoardTopic::findOne($_POST['id']);
         if ($model === null) {
             $json['success'] = 'no';
             $json['message'] = YBoard::t('yboard', 'Topic not found.');
         } else {
             $json['success'] = 'yes';
             $json['forum_id'] = $model->forum_id;
             $json['title'] = $model->title;
             $json['locked'] = $model->locked;
             $json['sticky'] = $model->sticky;
             $json['global'] = $model->global;
             $json['approved'] = $model->approved;
             $json['option'] = '<option value=""></option>';
             foreach (YBoardTopic::find()->where(['forum_id' => $model->forum_id])->all() as $topic) {
                 $json['option'] .= '<option value="' . $topic->id . '">' . $topic->title . '</option>';
             }
         }
     } else {
         $json['success'] = 'no';
         $json['message'] = YBoard::t('yboard', 'Topic not found.');
     }
     echo json_encode($json);
     Yii::$app->end();
 }
예제 #5
0
 public function actionMarkAllRead()
 {
     if (!Yii::$app->user->can('app.forum.forum.mark-all-read')) {
         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.'));
     }
     $topics = YBoardTopic::find()->all();
     foreach ($topics as $topic) {
         $topicLog = YBoardLogTopic::findOne(['member_id' => Yii::$app->user->id, 'topic_id' => $topic->id]);
         if ($topicLog === null) {
             $topicLog = new YBoardLogTopic();
             $topicLog->member_id = Yii::$app->user->id;
             $topicLog->topic_id = $topic->id;
             $topicLog->forum_id = $topic->forum_id;
         }
         $topicLog->last_post_id = $topic->last_post_id;
         $topicLog->save();
     }
     $this->redirect(['index']);
 }