/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MenuPointActiveRule::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'menu_point_id' => $this->menu_point_id]);
     $query->andFilterWhere(['like', 'module', $this->module])->andFilterWhere(['like', 'controller', $this->controller])->andFilterWhere(['like', 'action', $this->action]);
     return $dataProvider;
 }
示例#2
0
 private static function checkActiveRule($menuPointId)
 {
     $activeRules = MenuPointActiveRule::find()->where(['menu_point_id' => $menuPointId])->all();
     $module = Yii::$app->controller->module->id;
     $controller = Yii::$app->controller->id;
     $action = Yii::$app->controller->action->id;
     if ($activeRules != null) {
         foreach ($activeRules as $activeRule) {
             if ($activeRule->module != null && $activeRule->controller != null && $activeRule->action != null) {
                 return $activeRule->module == $module && $activeRule->controller == $controller && $activeRule->action == $action;
             } elseif ($activeRule->module != null && $activeRule->controller != null) {
                 return $activeRule->module == $module && $activeRule->controller == $controller;
             } elseif ($activeRule->controller != null && $activeRule->action != null) {
                 return $activeRule->controller == $controller && $activeRule->action == $action;
             } elseif ($activeRule->module != null) {
                 return $activeRule->module == $module;
             } elseif ($activeRule->controller != null && $activeRule->action == null) {
                 return $activeRule->controller == $controller;
             }
         }
     } else {
         return false;
     }
 }
 /**
  * Finds the MenuPointActiveRule model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MenuPointActiveRule the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MenuPointActiveRule::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }