示例#1
0
 /**
  * Creates a new AuthItem model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new AuthItem(null);
     $model->type = Item::TYPE_PERMISSION;
     if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
         MenuHelper::invalidate();
         return $this->redirect(['view', 'id' => $model->name]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
示例#2
0
 public function actionProfileEdit()
 {
     $model = $this->findModel(Yii::$app->getRequest()->getCookies()->getValue('userId'));
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['profile']);
     } else {
         return $this->render('@app/modules/user/views/user/update2', ['model' => $model, 'statuses' => $model->getStatuses(), 'roles' => AuthItem::getRoles()]);
     }
 }
 /**
  * Updates an existing AuthItemChild model.
  * @param string $parent
  * @param string $child
  * @return mixed
  */
 public function actionUpdate($parent, $child)
 {
     $model = $this->findModel($parent, $child);
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         Yii::$app->response->format = 'json';
         if ($model->save()) {
             return Yii::$app->params['response']['success'];
         } else {
             return ActiveForm::validate($model);
         }
     } else {
         return $this->renderAjax('update', ['model' => $model, 'authItems' => AuthItem::getAllForLists2()]);
     }
 }
示例#4
0
 public function search($params)
 {
     $query = AuthItem::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->current->getPageSize()]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['type' => $this->type, 'updated_at' => $this->updated_at]);
     if ($this->created_at) {
         $interval = Yii::$app->current->getDateInterval($this->created_at);
         $query->andFilterWhere(['between', 'created_at', $interval[0], $interval[1]]);
     }
     if ($this->updated_at) {
         $interval = Yii::$app->current->getDateInterval($this->updated_at);
         $query->andFilterWhere(['between', 'updated_at', $interval[0], $interval[1]]);
     }
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'rule_name', $this->rule_name])->andFilterWhere(['like', 'data', $this->data]);
     return $dataProvider;
 }
示例#5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChild0()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'child']);
 }
示例#6
0
 /**
  * @return AuthItem
  */
 public function getAuthItem()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'role']);
 }
 /**
  * Finds the AuthItem model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $name
  * @return AuthItem the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($name)
 {
     if (($model = AuthItem::findOne($name)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthItems()
 {
     return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']);
 }
示例#9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItemName()
 {
     return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
 }