public function getAllRoleMenuRoleKey()
 {
     $secuityUrlKey = $this->secuityUrlKey();
     $role_ids = $this->getAllRoleIds();
     //var_dump($role_ids);
     $role_menu_keys = [];
     if (!empty($role_ids)) {
         foreach ($role_ids as $role_id) {
             $d_menu_ids = AdminRoleMenu::find()->asArray()->select(['menu_id'])->where(['role_id' => $role_id])->all();
             $role_keys = [];
             $menu_ids = [];
             if (!empty($d_menu_ids)) {
                 foreach ($d_menu_ids as $d) {
                     $menu_ids[] = $d['menu_id'];
                 }
             }
             if ($menu_ids) {
                 $menus = AdminMenu::find()->asArray()->where(['in', 'id', $menu_ids])->all();
                 //	var_dump(['in','id',$menu_ids]);
                 if (!empty($menus)) {
                     foreach ($menus as $menu) {
                         $role_keys[] = $menu['role_key'];
                     }
                     $role_menu_key[$role_id] = array_merge($role_keys, $secuityUrlKey);
                 }
             } else {
                 $role_menu_key[$role_id] = $secuityUrlKey;
             }
         }
     }
     return $role_menu_key;
 }
 public static function getMenuArr()
 {
     if ($menuArr = CCache::get(self::MENU_CACHE_ARR)) {
         return $menuArr;
     } else {
         $menuArr = [];
         $data = AdminMenu::find()->select(['name', 'role_key'])->all();
         foreach ($data as $one) {
             $menuArr[$one['role_key']] = $one['name'];
         }
         $menuArr['/fecadmin/index'] = '主界面';
         $menuArr['/fecadmin/login'] = '******';
         $menuArr['/fecadmin/logout'] = '账号退出';
         CCache::set(self::MENU_CACHE_ARR, $menuArr);
         return $menuArr;
     }
 }
 public function getMenuTree($parent_id = 0)
 {
     $menuArr = [];
     $parentArr = AdminMenu::find()->asArray()->where(['parent_id' => $parent_id])->orderBy(['sort_order' => SORT_DESC])->all();
     if (is_array($parentArr) && !empty($parentArr)) {
         foreach ($parentArr as $node) {
             $name = $node["name"];
             $id = $node["id"];
             $url_key = $node["url_key"];
             $menuArr[$id] = ['id' => $id, 'name' => $name, 'url_key' => $url_key];
             $menuArr[$id]['child'] = $this->getMenuTree($id);
         }
     }
     return $menuArr;
 }
 public function getAllParentMenuIds($select_menus)
 {
     $thisIds = [];
     if (!is_array($select_menus)) {
         $ids = [];
         $select_menu_ids = explode(",", $select_menus);
         if (is_array($select_menu_ids) && !empty($select_menu_ids)) {
             foreach ($select_menu_ids as $menu_id) {
                 if ($i = trim($menu_id)) {
                     $ids[] = $i;
                 }
             }
         }
     } else {
         $ids = $select_menus;
     }
     $thisIds = $ids;
     if (!empty($ids)) {
         $parentMenus = AdminMenu::find()->asArray()->where(['in', 'id', $ids])->all();
         $parentIds = [];
         foreach ($parentMenus as $menu) {
             $parent_id = $menu['parent_id'];
             if ($parent_id) {
                 $parentIds[] = $parent_id;
             }
         }
         if (!empty($parentIds)) {
             $parent_ids = $this->getAllParentMenuIds($parentIds);
             $thisIds = array_merge($thisIds, $parent_ids);
         }
     }
     return $thisIds;
 }
Beispiel #5
0
 public static function getContent()
 {
     $AdminMenu = new AdminMenu();
     return $AdminMenu->getLeftMenuTreeHtml();
 }
 public function getMenuAllChildId($id, $ids = [])
 {
     $adminMenu = new AdminMenu();
     $data = AdminMenu::find()->asArray()->where(" parent_id = " . $id . " AND can_delete = 2 ")->all();
     if (!empty($data)) {
         foreach ($data as $node) {
             $ids[] = $node['id'];
             if ($adminMenu->hasChild($node)) {
                 $ids[] = $this->getMenuAllChildId($node['id']);
             }
         }
     }
     return $ids;
 }