Ejemplo n.º 1
0
 public function search($params)
 {
     $query = UserVisitLog::find();
     $query->joinWith(['user']);
     // Don't let non-superadmin view superadmin activity
     if (!Yii::$app->user->isSuperadmin) {
         $query->andWhere([User::tableName() . '.superadmin' => 0]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->request->cookies->getValue('_grid_page_size', 20)], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->visit_time) {
         $tmp = explode(' - ', $this->visit_time);
         if (isset($tmp[0], $tmp[1])) {
             $query->andFilterWhere(['between', static::tableName() . '.visit_time', strtotime($tmp[0]), strtotime($tmp[1])]);
         }
     }
     $query->andFilterWhere([$this->tableName() . '.id' => $this->id]);
     $query->andFilterWhere(['like', User::tableName() . '.username', $this->user_id])->andFilterWhere(['like', static::tableName() . '.ip', $this->ip])->andFilterWhere(['like', static::tableName() . '.os', $this->os])->andFilterWhere(['like', static::tableName() . '.browser', $this->browser])->andFilterWhere(['like', static::tableName() . '.language', $this->language]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
<?php

return ['vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'components' => ['cache' => ['class' => 'yii\\caching\\FileCache'], 'user' => ['class' => 'webvimark\\modules\\UserManagement\\components\\UserConfig', 'on afterLogin' => function ($event) {
    \webvimark\modules\UserManagement\models\UserVisitLog::newVisitor($event->identity->id);
}]], 'modules' => ['user-management' => ['class' => 'webvimark\\modules\\UserManagement\\UserManagementModule', 'on beforeAction' => function (yii\base\ActionEvent $event) {
    if ($event->action->uniqueId == 'user-management/auth/login') {
        $event->action->controller->layout = 'loginLayout.php';
    }
}]]];