首页 > 代码库 > 权限管理
权限管理
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="http://www.mamicode.com/__ROOT__/Public/css/style.css" rel="stylesheet" type="text/css" />
<script src="http://www.mamicode.com/__ROOT__/Public/js/jquery.js"></script>
<script language="javascript">
$(function(){
$("input").click(function(){
var level=$(this).attr("level");
if(level==1){
var str="_";
var inputs=$("input[value*="+str+"]");
$(this).attr("checked")?inputs.attr("checked",true):inputs.removeAttr("checked");
}
else if(level==2){
var id=$(this).attr("id");
var pid=$(this).attr("pid");
var inputs=$("input[pid="+id+"]");
var puts=$("input[id="+pid+"]");
$(this).attr("checked")?inputs.attr("checked",true):inputs.removeAttr("checked");
$(this).attr("checked")?puts.attr("checked",true):puts.removeAttr("checked");
}
else if(level==3){
var pid=$(this).attr("pid");
var inputs=$("input[id="+pid+"]");
var ppid=$("input[id="+pid+"]").attr("pid");
var puts=$("input[id="+ppid+"]");
$(this).attr("checked")?inputs.attr("checked",true):inputs.removeAttr("checked");
$(this).attr("checked")?puts.attr("checked",true):puts.removeAttr("checked");
}
});
})
</script>
</head>
<body>
<div class="place">
<span>位置:</span>
<ul class="placeul">
<li><a href="http://www.mamicode.com/#">首页</a></li>
<li><a href="http://www.mamicode.com/#">表单</a></li>
</ul>
</div>
<div class="formbody">
<div class="formtitle"><span>基本信息</span></div>
<form method="post" action="{:U(‘Access/addaccess‘)}">
<foreach name="nodelist" item="first">
<div style="clear:both; line-height:40px;">
<input type="checkbox" name="access[]"<in name="$first.id" value="http://www.mamicode.com/$rdata">checked=checked</in> id="{$first.id}" pid="{$first.pid}" level="{$first.level}" value="http://www.mamicode.com/{$first.id}_{$first.level}"/>
[项目]{$first.title}
</div>
<div>
<foreach name="first.second" item="sec">
<div style="margin-left:50px;clear:both; line-height:40px;">
<input type="checkbox" name="access[]" <in name="$sec.id" value="http://www.mamicode.com/$rdata">checked=checked</in> id="{$sec.id}" pid="{$sec.pid}" level="{$sec.level}" value="http://www.mamicode.com/{$sec.id}_{$sec.level}"/>
[模块]{$sec.title}
</div>
<div style="margin-left:100px;">
<ul>
<foreach name="sec.third" item="third">
<li style="float:left; line-height:40px; padding-left:20px;">
<input type="checkbox" name="access[]" <in name="$third.id" value="http://www.mamicode.com/$rdata">checked=checked</in> id="{$third.id}" pid="{$third.pid}" level="{$third.level}" value="http://www.mamicode.com/{$third.id}_{$third.level}"/>
[操作]{$third.title}
</li>
</foreach>
</ul>
</div>
</foreach>
</div>
</foreach>
<div style="clear:both">
<label> </label>
<input name="role_id" type="hidden" value="http://www.mamicode.com/{$role_id}"/>
<input name="submit" type="submit" class="btn" value="http://www.mamicode.com/确认保存"/>
</div>
</form>
</div>
</body>
</html>
function roleaccess()
{
$D=M("Access");
$id=$_GET[‘id‘];
$rdata=http://www.mamicode.com/$D->where("role_id=".$id)->getField("node_id",true);
$M=M("Node");
$data=http://www.mamicode.com/$M->where("pid=0")->select();
foreach($data as &$v)
{
$v[‘second‘]=$M->where("pid=".$v[‘id‘])->select();
foreach($v[‘second‘] as &$t)
{
$t[‘third‘]=$M->where("pid=".$t[‘id‘])->select();
}
}
//dump($data);
$this->assign("rdata",$rdata);
$this->assign("role_id",$id);
$this->assign("nodelist",$data);
$this->display();
}
权限管理