PHP7中文手册2018 带注释 最新chm版
- $aclList = array(
- 'Index' => array('name'=>'系统管理','mod'=>'Index','icon'=>'fa-home','url'=>'Index/index','list'=>array(
- array('name' => '系统主页', 'url' => 'Index/index','act'=>'index'),
- array('name' => '基本设置', 'url' => 'Index/editWebinfo','act'=>'editWebinfo'),
- array('name' => '刷新缓存', 'url' => 'Index/flushCache','act'=>'flushCache'),
- array('name' => '添加充值方式', 'url' => 'Index/sendMethod','act'=>'sendMethod'),
- array('name' => '管理充值方式', 'url' => 'Index/manageMethod','act'=>'manageMethod'),
- )),
- 'User' => array('name'=>'用户管理','mod'=>'User','icon'=>'fa-columns','url'=>'User/index','list'=>array(
- array('name' => '会员列表', 'url' => 'User/showAllusers','act'=>'showAllusers'),
- array('name' => '修改密码', 'url' => 'User/editPassword','act'=>'editPassword'),
- )),
- );
- if (C('USER_AUTH_ON') && emptyempty($_SESSION[C('ADMIN_AUTH_KEY')])) {
- if (C('USER_AUTH_TYPE') == 2) {
- //加强验证和即时验证模式
- import('ORG.Util.RBAC');
- $accessList = RBAC::getAccessList($_SESSION[C('USER_AUTH_KEY')]);
- } else {
- $accessList = $_SESSION['_ACCESS_LIST'];
- }
- }
- //打印出$accessList 找到第一个ADmin
- $_menu = array();
- foreach ($aclList as $key=>$val) {
- $_key = strtoupper($key);
- if(array_key_exists($_key,$accessList['ADMIN'])) {
- foreach ($val['list'] as $k=>$v) {
- if(!array_key_exists(strtoupper($v['act']),$accessList['ADMIN_BITCOIN'][$_key])) {
- unset($val['list'][$k]);
- }
- }
- $_menu[$key] = $val;
- }
- }
- $this->assign('meun',$_menu);
meun.html
- <volist name="meun" id="data">
- <!--active -->
- <li <if condition="$Think.const.MODULE_NAME eq $data['mod']">class="active"</if>>
- <a href="<{:U($data['url'])}>">
- <i class="fa <{$data.icon}>"></i>
- <span class="nav-label"><{$data.name}></span>
- <span class="fa arrow"></span>
- </a>
- <ul class="nav nav-second-level">
- <volist name="data.list" id="vo_1" key="key_1">
- <!--activemenu-->
- <li <if condition="$Think.const.MODULE_NAME eq $data['mod'] && $Think.const.ACTION_NAME eq $vo_1['act']">class="activemenu"</if>><a href="<{:U($vo_1['url'])}>"><{$vo_1['name']}></a></li>
- </volist>
- </ul>
- </li>
- </volist>
转载请注明:谷谷点程序 » thinkphp rbac显示菜单的方法