Exemplo n.º 1
0
 public function actionAssignItems($id)
 {
     $model = self::findModel($id);
     $items = Yii::$app->request->post('authItems');
     if (!is_array($items)) {
         throw new Exception('Invalid request.Params has Error. Please do not repeat this request again.');
     }
     // 安全过滤待授权的项目
     $authItems = models\RbacAuthitems::getCanAssignItems();
     $items = array_intersect($items, $authItems);
     if ($items && models\RbacTaskItems::assignItemsToTask($id, $items)) {
         echo '授权成功';
     } else {
         throw new Exception('授权失败');
     }
 }