Home > php教程 > php手册 > thinkphp通过rabc实现仅显示有权限的列表

thinkphp通过rabc实现仅显示有权限的列表

WBOY
Release: 2016-06-07 11:44:19
Original
1295 people have browsed it

thinkphp通过rabc实现仅显示有权限的列表
实现思想:将已有的模块和权限列表中对比实现,其实有更优的方案,根据具体的需求而定吧,成功案例请见http://liezy.com
1.控制器部分/*如果验证模式为2即时验证,通过rbac去即时获得用户的权限列表*/<br> //import('@.ORG.RBACFRONT');<br> //$accessList = RBAC::getAccessList($_SESSION[C('MEMBER_AUTH_KEY')]);<br>  <br> /*验证模式为1使用,登录验证模式,登录后保存的权限访问列表*/<br> $accessList = $_SESSION['_ACCESS_LIST'];<br>  <br> //已有的模块<br> $module=array('BeginNego','Room','AgreeTpl','Agreement','Contact','EnterInfo','RoleFront','WebHelp');<br>  <br> foreach($module as $v){<br>     if(isset($accessList[strtoupper($v)][INDEX])) {<br>         $this->assign($v,$v);<br>     }<br>     //免验证管理员直接输出所有的模块<br>     if(isset($_SESSION['administrator'])){<br>         $this->assign($v,$v);<br>     }<br> }2.模板展示部分<if><br>     <ul>帮助文档</ul> <br> </if><br>  <br> <div> <br>     <notempty><br>         <a>网站使用说明</a> <br>     </notempty> <br> </div> 

AD:真正免费,域名+虚机+企业邮箱=0元

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template