Exemplo n.º 1
0
 public function getAttributesByRole()
 {
     $model = AuthItem::find()->select('name')->where(['name' => $this->getRolesByUser()])->with('visibleAttributes', 'editableAttributes')->one();
     if ($model->visibleAttributes !== null || $model->editableAttributes !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The project not have any roles configured.');
     }
 }
 public function actionEditable()
 {
     if (Yii::$app->request->post('hasEditable') && Yii::$app->request->post('AuthItem')) {
         $posted = Yii::$app->request->post('AuthItem');
         if ($id = Yii::$app->request->post('editableKey')) {
         } else {
             if ($posted['attribute_name']) {
                 $id = $posted['attribute_name'];
             }
         }
         $model = AuthItem::findOne($id);
         if (!ArrayHelper::isAssociative($posted, true)) {
             $post['AuthItem'] = current($posted);
         } else {
             $post['AuthItem'] = $posted;
         }
         if ($model->load($post) && $model->save()) {
             echo \yii\helpers\Json::encode(['output' => Yii::t('order', "Click for edit"), 'message' => '']);
         } else {
             echo \yii\helpers\Json::encode(['output' => Yii::t('order', "Error"), 'message' => '']);
         }
         return;
     }
 }