//获取权制限列表
パブリック関数 getPriveList($id){
$sql="SELECT m.id, m.name
FROM jh_user AS u、jh_role AS r、jh_role_user AS ru、jh_prive AS p、jh_menu AS m
WHERE u.id = ru.user_id
かつ ru.role_id = r.id
かつ r.id = p.role_id
かつ m.id = p.menu_id
かつ m.status =1
かつ m.level =1
かつ u.id ={$id}";
$rs=$this->クエリ($sql);
//$row=$this->fetch_assoc($rs);
$m1=配列();
while ($row=$this->fetch_assoc($rs)){
$m1[]=$row;
}
$prive=array();
foreach ($m1 as $key=>$v){
$priveId=$v['id'];
$priveName=$v['名前'];
$prive[strtoupper($priveName)]=array();
$sql2="m.id、m.name を選択
FROM jh_user AS u、jh_role AS r、jh_role_user AS ru、jh_prive AS p、jh_menu AS m
WHERE u.id = ru.user_id
かつ ru.role_id = r.id
かつ r.id = p.role_id
かつ m.id = p.menu_id
かつ m.status =1
かつ m.level =2
かつ m.pid ={$priveId}
かつ u.id ={$id}";
$rs2=$this->クエリ($sql2);
$m2=配列();
while ($row2=$this->fetch_assoc($rs2)){
$m2[]=$row2;
}
// 判断パブリックモ块 www.2cto.com
$Public=array();
foreach ($m2 as $key =>$m){
$pId=$m['id'];
$pName=$m['名前'];
if('PUBLIC'==strtoupper($m['name'])){
$sql3="m.id、m.name を選択
FROM jh_user AS u、jh_role AS r、jh_role_user AS ru、jh_prive AS p、jh_menu AS m
WHERE u.id = ru.user_id
かつ ru.role_id = r.id
かつ r.id = p.role_id
かつ m.id = p.menu_id
かつ m.status =1
かつ m.level =3
かつ m.pid ={$pId}
かつ u.id ={$id}";
$rs3=$this->クエリ($sql3);
$m3=配列();
while ($row3=$this->fetch_assoc($rs3)){
$m3[]=$row3;
}
foreach ($m3 を $val として){
$Public[$val['name']]=$val['id'];
}
//print_r( $m2[$key]);
unset($m2[$key]);
壊す;
}
}
// print_r($Public);
foreach ($m2 as $key =>$m){
$pId=$m['id'];
$pName=$m['名前'];
$sql4="m.id、m.name を選択
FROM jh_user AS u、jh_role AS r、jh_role_user AS ru、jh_prive AS p、jh_menu AS m
WHERE u.id = ru.user_id
かつ ru.role_id = r.id
かつ r.id = p.role_id
かつ m.id = p.menu_id
かつ m.status =1
かつ m.level =3
かつ m.pid ={$pId}
かつ u.id ={$id}";
$rs4=$this->クエリ($sql4);
$m4=配列();
while ($row4=$this->fetch_assoc($rs4)){
$m4[]=$row4;
}
$アクション=配列();
foreach ($m4 を $va){
$action[$va['name']]=$va['id'];
}
$アクション+=$パブリック;
$prive[strtoupper($priveName)][strtoupper($pName)] =array_change_key_case($action,CASE_UPPER);
}
}
print_r($prive);
}
摘自chaojie2009的专栏