Add new functions from acl enterprise menu

This commit is contained in:
m-lopez-f 2015-10-19 15:08:44 +02:00
parent 009ae5c92a
commit 256da3bc3d
3 changed files with 83 additions and 4 deletions

View File

@ -12,7 +12,9 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
$get_sec_pages = get_parameter('get_sec_pages');
$get_sec_pages2 = get_parameter('get_sec_pages2');
include_once("include/functions_menu.php");
include_once("include/functions_html.php");
if ($get_sec_pages) {
$sec = get_parameter('sec');
@ -46,4 +48,15 @@ if ($get_sec_pages) {
return;
}
if ($get_sec_pages2) {
$sec2 = get_parameter('sec2');
$sec = get_parameter('sec');
$menu_hash = get_parameter('menu_hash');
$pages = menu_get_sec2_pages($sec, $sec2, $menu_hash);
echo json_encode($pages);
return;
}
?>

View File

@ -305,6 +305,11 @@ function menu_print_menu (&$menu) {
$count_sub2 = 0;
foreach ($sub['sub2'] as $key => $sub2) {
if (enterprise_hook ('enterprise_acl', array ($config['id_user'], $mainsec, $subsec2, true,$key)) == false) {
continue;
}
$count_sub2++;
$link = "index.php?sec=".$subsec2."&sec2=".$key;
@ -536,10 +541,29 @@ function menu_get_sec($with_categories = false) {
$sec_array[$k] = $v['text'];
}
}
return $sec_array;
}
/**
* Get the sec list built in menu
*
* @param bool If true, the array returned will have the structure
* to combo categories (optgroup)
*
* @return array Sections list
*/
function get_sec($sec = false) {
$menu = menu_get_full_sec();
unset($menu['class']);
$in_godmode = false;
foreach ($menu as $k => $v) {
if (isset($v["sub"][$sec]))
return $k;
}
return false;
}
/**
* Get the pages in a section
*
@ -552,7 +576,7 @@ function menu_get_sec($with_categories = false) {
* @return array Sections list
*/
function menu_get_sec_pages($sec, $menu_hash = false) {
if ($menu_hash === false) {
if (!$menu_hash) {
$menu = menu_get_full_sec();
}
else {
@ -564,7 +588,7 @@ function menu_get_sec_pages($sec, $menu_hash = false) {
if (isset($sec)) {
// Get the sec2 of the main section
$sec2_array[$menu[$sec]['sec2']] = $menu[$sec]['text'];
//$sec2_array[$menu[$sec]['sec2']] = $menu[$sec]['text'];
// Get the sec2 of the subsections
@ -588,6 +612,37 @@ function menu_get_sec_pages($sec, $menu_hash = false) {
return $sec2_array;
}
/**
* Get the pages in a section2
*
* @param string sec code
* @param string menu hash. All the menu structure (For example
* returned by menu_get_full_sec(), json encoded and after that
* base64 encoded. If this value is false this data is obtained from
* menu_get_full_sec();
*
* @return array Sections list
*/
function menu_get_sec2_pages($sec, $sec2, $menu_hash = false) {
if ($menu_hash === false) {
$menu = menu_get_full_sec();
}
else {
$menu = json_decode(base64_decode($menu_hash),true);
}
$sec3_array = array();
if (isset($sec2)) {
// Get the sec2 of the subsections
foreach ($menu[$sec]['sub'][$sec2]['sub2'] as $k => $v) {
$sec3_array[$k] = $v['text'];
}
}
return $sec3_array;
}
/**
* Check if a page (sec2) is in a section (sec)
*

View File

@ -628,10 +628,21 @@ if ($searchPage) {
}
else {
if ($page != "") {
$main_sec = get_sec($sec);
if ($main_sec == false) {
if ($sec == 'extensions')
$main_sec = get_parameter('extension_in_menu');
else
$main_sec = $sec;
$sec = $sec2;
$sec2 = '';
}
$page .= '.php';
// Enterprise ACL check
if (enterprise_hook ('enterprise_acl',
array ($config['id_user'], $sec, $sec2, true)) == false) {
array ($config['id_user'], $main_sec, $sec, true,$sec2)) == false) {
require ("general/noaccess.php");