Update menu.php

This commit is contained in:
FusionPBX 2017-11-17 14:44:31 -07:00 committed by GitHub
parent 364d5225be
commit a20cb0b75f
1 changed files with 224 additions and 208 deletions

View File

@ -78,6 +78,7 @@ if (!class_exists('menu')) {
//get the $apps array from the installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/*/*/app_menu.php");
$x = 0;
if (is_array($config_list)) {
foreach ($config_list as &$config_path) {
$app_path = dirname($config_path);
$app_path = preg_replace('/\A.*(\/.*\/.*)\z/', '$1', $app_path);
@ -92,6 +93,7 @@ if (!class_exists('menu')) {
exit;
}
}
}
//begin the transaction
if ($db_type == "sqlite") {
@ -102,7 +104,9 @@ if (!class_exists('menu')) {
$language = new text;
//use the app array to restore the default menu
if (is_array($apps)) {
foreach ($apps as $row) {
if (is_array($row['menu'])) {
foreach ($row['menu'] as $menu) {
//set the variables
if (strlen($menu['title'][$this->menu_language]) > 0) {
@ -179,7 +183,7 @@ if (!class_exists('menu')) {
}
//set the menu languages
if (!$menu_item_exists) {
if (!$menu_item_exists and is_array($language->languages)) {
foreach ($language->languages as $menu_language) {
$menu_item_title = $menu["title"][$menu_language];
if(strlen($menu_item_title) == 0) {
@ -209,6 +213,8 @@ if (!class_exists('menu')) {
}
}
}
}
//make sure the default user groups exist
$group = new groups;
@ -227,13 +233,17 @@ if (!class_exists('menu')) {
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
if (is_array($result)) {
foreach ($result as $row) {
$group_uuids[$row['group_name']] = $row['group_uuid'];
}
}
unset($sql, $prep_statement, $result);
//if there are no groups listed in v_menu_item_groups under menu_item_uuid then add the default groups
if (is_array($apps)) {
foreach($apps as $app) {
if (is_array($apps)) {
foreach ($app['menu'] as $sub_row) {
if (isset($sub_row['groups'])) foreach ($sub_row['groups'] as $group) {
$sql = "select count(*) as count from v_menu_item_groups ";
@ -271,6 +281,8 @@ if (!class_exists('menu')) {
}
}
}
}
}
//commit the transaction
if ($db_type == "sqlite") {
@ -291,6 +303,7 @@ if (!class_exists('menu')) {
$_SESSION['groups'][0]['group_name'] = 'public';
}
if (is_array($menu_array)) {
foreach($menu_array as $menu_field) {
//set the variables
$menu_item_link = $menu_field['menu_item_link'];
@ -352,6 +365,7 @@ if (!class_exists('menu')) {
$menu_html_full .= $menu_html;
} //end for each
}
return $menu_html_full;
} //end function
@ -366,7 +380,7 @@ if (!class_exists('menu')) {
$_SESSION['groups'][0]['group_name'] = 'public';
}
if (count($submenu_array) > 0) {
if (is_array($submenu_array)) {
//child menu found
$submenu_html = "<ul class='menu_sub'>\n";
@ -470,6 +484,7 @@ if (!class_exists('menu')) {
//save the menu into an array
$x = 0;
$a = Array();
if (is_array($result)) {
foreach($result as $row) {
//add the row to the array
$a[$x] = $row;
@ -483,6 +498,7 @@ if (!class_exists('menu')) {
//increment the row number
$x++;
} //end for each
}
//unset the variables
unset($prep_statement, $sql, $result);
@ -503,6 +519,11 @@ if (!class_exists('menu')) {
//set the level
$menu_item_level = $menu_item_level+1;
//if there are no groups then set the public group
if (!isset($_SESSION['groups'][0]['group_name'])) {
$_SESSION['groups'][0]['group_name'] = 'public';
}
//get the child menu from the database
$sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_icon, i.menu_item_uuid, i.menu_item_parent_uuid ";
$sql .= "from v_menu_items as i, v_menu_languages as l ";
@ -514,10 +535,6 @@ if (!class_exists('menu')) {
$sql .= "and i.menu_item_uuid in ";
$sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' ";
$sql .= "and ( ";
if (count($_SESSION['groups']) == 0) {
$sql .= "group_name = 'public' ";
}
else {
$x = 0;
foreach($_SESSION['groups'] as $row) {
if ($x == 0) {
@ -528,7 +545,6 @@ if (!class_exists('menu')) {
}
$x++;
}
}
$sql .= ") ";
$sql .= ") ";
$sql .= "order by l.menu_item_title, i.menu_item_order asc ";
@ -537,7 +553,7 @@ if (!class_exists('menu')) {
$sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_NAMED);
//save the child menu into an array
if (count($sub_result) > 0) {
if (is_array($sub_result)) {
foreach($sub_result as $row) {
//set the variables
$menu_item_link = $row['menu_item_link'];