// Obtain the permission list
Public function 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
AND ru. role_id = r. id
AND r. id = p. role_id
AND m. id = p. menu_id
AND m. status = 1
AND m. level = 1
AND u. id = {$ id }";
$ Rs = $ this-> query ($ SQL );
// $ Row = $ this-> fetch_assoc ($ rs );
$ M1 = array ();
While ($ row = $ this-> fetch_assoc ($ rs )){
$ M1 [] = $ row;
}
$ Prive = array ();
Foreach ($ m1 as $ key => $ v ){
$ PriveId = $ v ['id'];
$ PriveName = $ v ['name'];
$ Prive [strtoupper ($ priveName)] = array ();
$ Sql2 = "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
AND ru. role_id = r. id
AND r. id = p. role_id
AND m. id = p. menu_id
AND m. status = 1
AND m. level = 2
AND m. pid = {$ priveId}
AND u. id = {$ id }";
$ Rs2 = $ this-> query ($ sql2 );
$ M2 = array ();
While ($ row2 = $ this-> fetch_assoc ($ rs2 )){
$ M2 [] = $ row2;
}
// Determine the public module www.2cto.com
$ Public = array ();
Foreach ($ m2 as $ key => $ m ){
$ PId = $ m ['id'];
$ PName = $ m ['name'];
If ('public' = strtoupper ($ m ['name']) {
$ Sql3 = "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
AND ru. role_id = r. id
AND r. id = p. role_id
AND m. id = p. menu_id
AND m. status = 1
AND m. level = 3
AND m. pid = {$ pId}
AND u. id = {$ id }";
$ Rs3 = $ this-> query ($ sql3 );
$ M3 = array ();
While ($ row3 = $ this-> fetch_assoc ($ rs3 )){
$ M3 [] = $ row3;
}
Foreach ($ m3 as $ val ){
$ Public [$ val ['name'] = $ val ['id'];
}
// Print_r ($ m2 [$ key]);
Unset ($ m2 [$ key]);
Break;
}
}
// Print_r ($ Public );
Foreach ($ m2 as $ key => $ m ){
$ PId = $ m ['id'];
$ PName = $ m ['name'];
$ Sql4 = "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
AND ru. role_id = r. id
AND r. id = p. role_id
AND m. id = p. menu_id
AND m. status = 1
AND m. level = 3
AND m. pid = {$ pId}
AND u. id = {$ id }";
$ Rs4 = $ this-> query ($ sql4 );
$ M4 = array ();
While ($ row4 = $ this-> fetch_assoc ($ rs4 )){
$ M4 [] = $ row4;
}
$ Action = array ();
Foreach ($ m4 as $ va ){
$ Action [$ va ['name'] = $ va ['id'];
}
$ Action + = $ Public;
$ Prive [strtoupper ($ priveName)] [strtoupper ($ pName)] = array_change_key_case ($ action, CASE_UPPER );
}
}
Print_r ($ prive );
}
From chaojie2009