コード例 #1
0
ファイル: YBoard.php プロジェクト: dextercool/yii2-yiiboard
 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
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = YBoardSpider::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'hits' => $this->hits, 'last_visit' => $this->last_visit]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'user_agent', $this->user_agent]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: _footer.php プロジェクト: dextercool/yii2-yiiboard
				<span class="header2"><?php 
echo YBoard::t('yboard', '{{guests}} guest(s) and {{members}} active member(s)', ['{guests}' => $guests, '{members}' => $members]);
?>
</span>
				<?php 
echo YBoard::t('yboard', '(in the past 15 minutes)');
?>
			</div>
			
            <div>
				<?php 
$members = YBoardMember::find()->presentScope()->all();
foreach ($members as $member) {
    echo Html::a($member->profile->username, ['member/view', 'id' => $member->id], ['style' => 'color:#' . ($member->group == null ? '' : $member->group->color)]) . '&nbsp;';
}
$spiders = \app\modules\yboard\models\YBoardSpider::find()->all();
//present()->findAll();
foreach ($spiders as $spider) {
    echo Html::a($spider->name, $spider->url, array('class' => 'spider', 'target' => '_new')) . '&nbsp;';
}
?>
				<?php 
echo YBoard::t('yboard', '({hidden} anonymous member(s))', array('hidden' => YBoardMember::find()->hiddenScope()->presentScope()->count()));
?>
			</div>
		</div>
		
        <div class="statistics col-md-3"> 
			<span class="header2">
				<?php 
echo YBoard::t('yboard', 'Board Statistics');
コード例 #4
0
ファイル: _footer.php プロジェクト: dextercool/yii2-yiiboard
				<span class="header2" id="online-record"><?php 
echo YBoard::t('yboard', '{{guests}} guest(s) and {{members}} active member(s)', ['{guests}' => $guests, '{members}' => $members]);
?>
</span>
				<?php 
echo YBoard::t('yboard', '(in the past 15 minutes)');
?>
			</div>
			
            <div>
				<?php 
$members = YBoardMember::find()->presentScope()->all();
foreach ($members as $member) {
    echo Html::a($member->profile->username, ['member/view', 'id' => $member->id], ['style' => 'color:#' . ($member->group == null ? '' : $member->group->color)]) . '&nbsp;';
}
$spiders = YBoardSpider::find()->presentScope()->all();
foreach ($spiders as $spider) {
    echo Html::a($spider->name, $spider->url, array('class' => 'spider', 'target' => '_new')) . '&nbsp;';
}
?>
				<?php 
echo YBoard::t('yboard', '({hidden} anonymous member(s))', array('hidden' => YBoardMember::find()->hiddenScope()->presentScope()->count()));
?>
			</div>
		</div>
		
        <div class="statistics col-md-3"> 
			<span class="header2">
				<?php 
echo YBoard::t('yboard', 'Board Statistics');
?>
コード例 #5
0
 /**
  * handle Ajax call for getting spider
  */
 public function actionGetSpider()
 {
     if (!Yii::$app->user->can('app.forum.setting.get-spider')) {
         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($_GET['id'])) {
         $model = YBoardSpider::findOne($_GET['id']);
         if ($model !== null) {
             $json['id'] = $model->id;
             $json['name'] = $model->name;
             $json['user_agent'] = $model->user_agent;
         }
     }
     echo json_encode($json);
     Yii::$app->end();
 }