Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
fix(remote server): do not show host commands and shortcuts items if …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Dimitar Kalinov authored and chgautier committed Jan 18, 2019
1 parent 52fa3d1 commit dac871f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
21 changes: 17 additions & 4 deletions www/include/monitoring/objectDetails/hostDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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"] = "";
Expand Down Expand Up @@ -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
);

Expand All @@ -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));
Expand Down Expand Up @@ -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 "<div class='msg' align='center'>" .
Expand Down
14 changes: 7 additions & 7 deletions www/include/monitoring/objectDetails/template/hostDetails.ihtml
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
<h4>{t}Host commands and shortcuts{/t}</h4>
</td>
</tr>
{if $lcaTopo.60101 || $admin == 1}
{if ($lcaTopo.60101 || $admin == 1) && !$isRemote}
<tr class='list_two'>
<td class="ListColLeft ColPopup">
<a href='./main.php?p=60101&host_id={$host_id}&o=c'>{$lnk_host_config} {$host_data.host_name}</a>
Expand Down Expand Up @@ -424,28 +424,28 @@
</td>
</tr>
{/if}
{if $aclAct.host_notifications_for_services || $admin == 1}
{if ($aclAct.host_notifications_for_services || $admin == 1) && !$isRemote}
<tr class='list_one'>
<td class="ListColLeft ColPopup" id="host_notifications_for_services">
<a href="#" onClick="send_command('host_notifications_for_services', '1');">{$m_mon_disable_not_all_services}</a>
</td>
</tr>
{/if}
{if $aclAct.host_notifications_for_services || $admin == 1}
{if ($aclAct.host_notifications_for_services || $admin == 1) && !$isRemote}
<tr class='list_two'>
<td class="ListColLeft ColPopup" id="host_notifications_for_services">
<a href="#" onClick="send_command('host_notifications_for_services', '0');">{$m_mon_enable_not_all_services}</a>
</td>
</tr>
{/if}
{if $aclAct.service_schedule_check || $admin == 1}
{if ($aclAct.service_schedule_check || $admin == 1) && !$isRemote}
<tr class='list_one'>
<td class="ListColLeft ColPopup" id ="host_schedule_check">
<a href="#" onClick="send_command('host_schedule_check', '0');">{$m_mon_SCH_immediate_check}</a>
</td>
</tr>
{/if}
{if $aclAct.service_schedule_forced_check || $admin == 1}
{if ($aclAct.service_schedule_forced_check || $admin == 1) && !$isRemote}
<tr class='list_two'>
<td class="ListColLeft ColPopup" id="host_schedule_check">
<a href="#" onClick="send_command('host_schedule_check', '1');">{$m_mon_SCH_immediate_check_f}</a>
Expand All @@ -459,14 +459,14 @@
</td>
</tr>
{/if}
{if $aclAct.host_checks_for_services || $admin == 1}
{if ($aclAct.host_checks_for_services || $admin == 1) && !$isRemote}
<tr class='list_two'>
<td class="ListColLeft ColPopup" id="host_checks_for_services">
<a href="#" onClick="send_command('host_checks_for_services', '1');">{$m_mon_diable_check_all_svc}</a>
</td>
</tr>
{/if}
{if $aclAct.host_checks_for_services || $admin == 1}
{if ($aclAct.host_checks_for_services || $admin == 1) && !$isRemote}
<tr class='list_one'>
<td class="ListColLeft ColPopup" id="host_checks_for_services">
<a href="#" onClick="send_command('host_checks_for_services', '0');">{$m_mon_enable_check_all_svc}</a>
Expand Down

0 comments on commit dac871f

Please sign in to comment.