码迷,mamicode.com
首页 > 其他好文 > 详细

权限管理

时间:2014-11-25 20:32:30      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   ar   os   sp   java   for   on   

<!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="__ROOT__/Public/css/style.css" rel="stylesheet" type="text/css" />
<script src="__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="#">首页</a></li>
    <li><a href="#">表单</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="$rdata">checked=checked</in> id="{$first.id}" pid="{$first.pid}" level="{$first.level}" value="{$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="$rdata">checked=checked</in> id="{$sec.id}" pid="{$sec.pid}" level="{$sec.level}" value="{$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="$rdata">checked=checked</in> id="{$third.id}" pid="{$third.pid}" level="{$third.level}" value="{$third.id}_{$third.level}"/>
                                        [操作]{$third.title}
                                </li>
                            
                        </foreach>
                        </ul>
                    </div>
                </foreach>
                </div>
                
        </foreach>
        <div style="clear:both">
        <label>&nbsp;</label>
        <input name="role_id" type="hidden" value="{$role_id}"/>
        <input name="submit" type="submit" class="btn" value="确认保存"/>
          </div>
    </form>
    
    </div>


 </body>
</html>

 

    function roleaccess()
    {
        $D=M("Access");
        $id=$_GET[‘id‘];
        $rdata=$D->where("role_id=".$id)->getField("node_id",true);
        $M=M("Node");
        $data=$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();
    }

权限管理

标签:style   http   io   ar   os   sp   java   for   on   

原文地址:http://www.cnblogs.com/wan1011/p/4121787.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!