/**
  * 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();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->name]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 2
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 = $this->type;
     if ($model->load(Yii::$app->getRequest()->post()) && $model->save()) {
         Helper::invalidate();
         return $this->redirect(['view', 'id' => $model->name]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 3
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();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if ($model->type == 1) {
             Yii::$app->getSession()->setFlash('role-create-success');
         } elseif ($model->type == 2) {
             Yii::$app->getSession()->setFlash('rights-create-success');
         }
         return $this->redirect(['index']);
     }
     return $this->render('create', ['model' => $model]);
 }
Exemplo n.º 4
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();
     $model->group = YiiForum::getGetValue('group', '');
     if ($model->load(Yii::$app->request->post())) {
         $item = $this->model2Item($model, new Role());
         $this->auth->add($item);
         $groupName = YiiForum::getPostValue('AuthItem')['group'];
         $group = new Role();
         $group->name = $groupName;
         $this->auth->addChild($group, $item);
         AuthItem::createCachedRoles();
         return $this->redirect(['index', 'group' => $groupName]);
     } else {
         $locals = [];
         $locals['groups'] = $this->getCachedRoleGroups();
         $locals['model'] = $model;
         return $this->render('create', $locals);
     }
 }
 /**
  * Creates a new AuthItem model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @return mixed
  */
 public function actionCreate()
 {
     $categoryName = YiiForum::getGetValue('category');
     $model = new AuthItem();
     $model->category = $categoryName;
     if ($model->load(Yii::$app->request->post())) {
         $item = $this->model2Item($model, new Permission());
         $this->auth->add($item);
         $categoryName = YiiForum::getPostValue('AuthItem')['category'];
         $category = new Permission();
         $category->name = $categoryName;
         $this->auth->addChild($category, $item);
         AuthItem::createCachedPermissions();
         return $this->redirect(['index', 'category' => $categoryName]);
     } else {
         $locals = [];
         $locals['currentCategory'] = $categoryName;
         $locals['categories'] = $this->getCachedPermissionCategories();
         $locals['model'] = $model;
         return $this->render('create', $locals);
     }
 }