/** * 获取所有菜单项 * @return [type] [description] */ protected function getAllMenus() { $menu_object = WMenu::find()->where('type = 0')->all(); $menus = array(); if (!empty($menu_object)) { foreach ($menu_object as $menu) { foreach ($menu as $key => $value) { $menus[$menu->id][$key] = $value; } } } return $menus; }
public function verifyAccess() { $adminGroupModel = new \app\models\WAdminGroup(); $menuModel = new \app\models\WMenu(); $urlRule = $this->setUrlFlag(); $groupIds = $adminGroupModel->getUserPower($this->_sessionGet('accountID')); if ($groupIds->group_options != 'administrator' && $groupIds->group_options != '') { $rulesArray = $menuModel->getMeunByIf('id in (' . $groupIds->group_options . ')', 'menu_acl'); $rules = array(); foreach ($rulesArray as $val) { $rules[] = $val->menu_acl; } $rules = implode(',', $rules) . ',iadmin_default,iadmin_default_index'; if (strpos($rules, $urlRule) == false) { \app\common\XUtils::message('error', '您没有操作权限', \Yii::$app->urlManager->createUrl(['iadmin/admin/index'])); } } }
public function actionEditPowerOptions() { $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; $menuModel = \app\models\WMenu::findOne($id); if ($menuModel) { if (\Yii::$app->request->isPost) { $getPost = $this->_getPost('WMenu'); if ($getPost['id']) { if ($this->parentTrue($getPost['id'], $getPost['pid'])) { if ($this->isTwoLayersOfSuper($getPost['pid']) > 1) { \app\common\XUtils::message('error', '暂不支持添加三级及以上菜单!', \Yii::$app->urlManager->createUrl(['iadmin/auth/edit-power-options', 'id' => $id])); } if ($this->buildUpdate($getPost['id'], $menuModel, $getPost)) { \app\common\XUtils::message('success', '菜单更新成功!', \Yii::$app->urlManager->createUrl(['iadmin/auth/edit-power-options', 'id' => $id])); } } else { \app\common\XUtils::message('error', '不能选择当前菜单或当前菜单下级菜单', \Yii::$app->urlManager->createUrl(['iadmin/auth/edit-power-options', 'id' => $id])); } } } $groupList = $this->menusDropDownList($menuModel); $keys = array_keys($groupList); $keys = array_merge(array(0), $keys); $values = array_values($groupList); $values = array_merge(array('顶级分类'), $values); $tmpList = array(); foreach ($keys as $k => $v) { $tmpList[$v] = $values[$k]; } return $this->render('editpoweroptions', ['model' => $menuModel, 'groupList' => $tmpList]); } \app\models\XUtils::message('error', '无此菜单信息', \Yii::$app->urlManager->createUrl('iadmin/auth/index-power-options')); }