From dac871f3d6c696773e520c9bae9dfc2fea4487c9 Mon Sep 17 00:00:00 2001 From: Dimitar Kalinov Date: Wed, 16 Jan 2019 15:50:57 +0200 Subject: [PATCH] fix(remote server): do not show host commands and shortcuts items if centreon remote server - hide Configure host, Disable/enable service notifications, Schedule an immidiate check of all services (incl. forced), Disable/enable all service checks on this host --- .../monitoring/objectDetails/hostDetails.php | 21 +++++++++++++++---- .../objectDetails/template/hostDetails.ihtml | 14 ++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/www/include/monitoring/objectDetails/hostDetails.php b/www/include/monitoring/objectDetails/hostDetails.php index 367fe5f3572..345bc68efbe 100644 --- a/www/include/monitoring/objectDetails/hostDetails.php +++ b/www/include/monitoring/objectDetails/hostDetails.php @@ -317,7 +317,7 @@ ENT_QUOTES, "UTF-8" ); - $host_status[$host_name]["current_state"] = $tab_host_status[$data["current_state"]]; + $host_status[$host_name]["current_state"] = $tab_host_status[$data["current_state"]] ?? ''; if (isset($host_status[$host_name]["notes_url"]) && $host_status[$host_name]["notes_url"]) { $host_status[$host_name]["notes_url"] = str_replace("\$HOSTNAME\$", $data["host_name"], $data["notes_url"]); $host_status[$host_name]["notes_url"] = str_replace( @@ -397,7 +397,7 @@ } $host_status[$host_name]["status_class"] = - $tab_color_host[strtolower($host_status[$host_name]["current_state"])]; + $tab_color_host[strtolower($host_status[$host_name]["current_state"])] ?? ''; if (!$host_status[$host_name]["next_check"]) { $host_status[$host_name]["next_check"] = ""; @@ -634,7 +634,7 @@ $notesurl = str_replace("\$HOSTSTATE\$", $host_status[$host_name]["current_state"], $notesurl); $notesurl = str_replace( "\$HOSTSTATEID\$", - $tab_host_statusid[$host_status[$host_name]["current_state"]], + $tab_host_statusid[$host_status[$host_name]["current_state"]] ?? '', $notesurl ); @@ -651,7 +651,7 @@ $actionurl = str_replace("\$HOSTSTATE\$", $host_status[$host_name]["current_state"], $actionurl); $actionurl = str_replace( "\$HOSTSTATEID\$", - $tab_host_statusid[$host_status[$host_name]["current_state"]], + $tab_host_statusid[$host_status[$host_name]["current_state"]] ?? '', $actionurl ); $tpl->assign("h_ext_action_url", CentreonUtils::escapeSecure($actionurl)); @@ -694,6 +694,19 @@ $tpl->assign("tools", $tools); } + // Check if central or remote server + $DBRESULT = $pearDB->query("SELECT `value` FROM `informations` WHERE `key` = 'isRemote'"); + $result = $DBRESULT->fetchRow(); + if ($result === false) { + $isRemote = false; + } else { + $isRemote = array_map("myDecode", $result); + $isRemote = ($isRemote['value'] === 'yes') ? true : false; + } + $DBRESULT->closeCursor(); + $tpl->assign("isRemote", $isRemote); + + $tpl->display("hostDetails.ihtml"); } else { echo "
" . diff --git a/www/include/monitoring/objectDetails/template/hostDetails.ihtml b/www/include/monitoring/objectDetails/template/hostDetails.ihtml index f977a149b9a..8236208ab95 100644 --- a/www/include/monitoring/objectDetails/template/hostDetails.ihtml +++ b/www/include/monitoring/objectDetails/template/hostDetails.ihtml @@ -375,7 +375,7 @@

{t}Host commands and shortcuts{/t}

- {if $lcaTopo.60101 || $admin == 1} + {if ($lcaTopo.60101 || $admin == 1) && !$isRemote} {$lnk_host_config} {$host_data.host_name} @@ -424,28 +424,28 @@ {/if} - {if $aclAct.host_notifications_for_services || $admin == 1} + {if ($aclAct.host_notifications_for_services || $admin == 1) && !$isRemote} {$m_mon_disable_not_all_services} {/if} - {if $aclAct.host_notifications_for_services || $admin == 1} + {if ($aclAct.host_notifications_for_services || $admin == 1) && !$isRemote} {$m_mon_enable_not_all_services} {/if} - {if $aclAct.service_schedule_check || $admin == 1} + {if ($aclAct.service_schedule_check || $admin == 1) && !$isRemote} {$m_mon_SCH_immediate_check} {/if} - {if $aclAct.service_schedule_forced_check || $admin == 1} + {if ($aclAct.service_schedule_forced_check || $admin == 1) && !$isRemote} {$m_mon_SCH_immediate_check_f} @@ -459,14 +459,14 @@ {/if} - {if $aclAct.host_checks_for_services || $admin == 1} + {if ($aclAct.host_checks_for_services || $admin == 1) && !$isRemote} {$m_mon_diable_check_all_svc} {/if} - {if $aclAct.host_checks_for_services || $admin == 1} + {if ($aclAct.host_checks_for_services || $admin == 1) && !$isRemote} {$m_mon_enable_check_all_svc}