/**
  * Creates a new AccionGrupo model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new AccionGrupo();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id_accion' => $model->id_accion, 'id_controlador' => $model->id_controlador, 'id_grupo' => $model->id_grupo]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #2
0
 /**
  * Assign or revoke assignment to user
  * @param  integer $id
  * @param  string  $action
  * @return mixed
  */
 public function actionAsignarPermisos()
 {
     try {
         Yii::$app->response->format = 'json';
         if (Yii::$app->request->isAjax) {
             $grupo = Grupo::findOne(Yii::$app->request->post('id'));
             if ($grupo) {
                 $action = Acciones::findOne(Yii::$app->request->post('accion'));
                 if ($action) {
                     $tipo = intval(Yii::$app->request->post('tipo'));
                     if ($tipo == 1) {
                         $model = new AccionGrupo();
                         $model->id_grupo = $grupo->id_grupo;
                         $model->id_accion = $action->id_accion;
                         $model->id_controlador = $action->id_controlador;
                         $model->save();
                     } else {
                         if ($tipo == -1) {
                             $model = AccionGrupo::findOne(['id_accion' => $action->id_accion, 'id_grupo' => $grupo->id_grupo]);
                             if ($model) {
                                 $model->delete();
                             }
                         }
                     }
                     return ['success' => true];
                 }
             }
         }
     } catch (Exception $ex) {
     }
     return ['success' => false];
 }