public function run() { $var = []; $items = AuthItem::getAuthItems(); $service = []; foreach ($items as $item) { if ($item->type == 2) { continue; } $child = []; foreach ($items as $c) { if ($c->type == 1) { continue; } if (preg_match('/^' . $item->name . '/', $c->name)) { $child[] = $c; } } $item->setAttribute("child", $child); $service[] = $item; } $userId = Yii::$app->user->getId(); $assign = AuthAssignment::getAssignById($userId); foreach ($assign as $assignment) { $var["assignments"][] = $assignment->getAttributes(); } $var['services'] = $service; $var['group'] = AuthGroup::getGroups(); return $this->render('navigation', ['var' => $var]); }
/** * Lấy thông tin quyền và thông tin nhóm quyền * @return type */ public function actionGetigroup() { $params = Yii::$app->request->post(); if (!empty($params)) { $item = AuthItem::findAll(['type' => 2]); $assign = AuthAssignment::findAll(['user_id' => $params['id']]); $group = AuthGroup::getGroups(); if (!empty($item) && !empty($group)) { $data = ['items' => $item, 'group' => $group]; $data['assign'] = !empty($assign) ? $assign : []; return $this->response(new Response(true, 'Lấy dữ liệu thành công', $data)); } else { return $this->response(new Response(false, 'Lấy dữ liệu không thành công', [])); } } }