Ejemplo n.º 1
0
 public function actionAuditLog()
 {
     $query = \sammaye\audittrail\AuditTrail::find();
     $rules = \yii\helpers\Json::decode(Yii::$app->request->get('rules'));
     if ($rules) {
         $translator = new Translator($rules);
         $query->andWhere($translator->where())->addParams($translator->params());
     }
     $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     return $this->render('audit-log', ['dataProvider' => $dataProvider, 'rules' => $rules]);
 }
Ejemplo n.º 2
0
 /**
  * Lists all SysUser models.
  * @return mixed
  */
 public function actionIndex()
 {
     $query = SysUser::find();
     $rules = \yii\helpers\Json::decode(Yii::$app->request->get('rules'));
     if ($rules) {
         $translator = new Translator($rules);
         $query->andWhere($translator->where())->addParams($translator->params());
     }
     $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query]);
     return $this->render('index', ['dataProvider' => $dataProvider, 'rules' => $rules]);
 }
 public function testRules()
 {
     foreach ($this->rulesProvider() as $rule) {
         $translator = new Translator($rule[0]);
         $expected = $rule[1];
         $this->assertEquals($expected[0], $translator->where());
         $params = $translator->params();
         foreach ($expected[1] as $key => $value) {
             $this->assertArrayHasKey($key, $params);
             $this->assertEquals($value, $params[$key]);
         }
     }
 }