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; } }
/** * 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; }
<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)]) . ' '; } $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')) . ' '; } ?> <?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');
<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)]) . ' '; } $spiders = YBoardSpider::find()->presentScope()->all(); foreach ($spiders as $spider) { echo Html::a($spider->name, $spider->url, array('class' => 'spider', 'target' => '_new')) . ' '; } ?> <?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'); ?>