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

#5400 Remove deprecated field : service_inherit_contact_from_host #5396

Merged
merged 9 commits into from
Jul 3, 2017
11 changes: 1 addition & 10 deletions www/class/centreonService.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,7 @@ public function insert($ret)
"service_high_flap_threshold, service_flap_detection_enabled, service_process_perf_data, " .
" service_retain_status_information, service_retain_nonstatus_information, " .
"service_notification_interval, service_notification_options, service_notifications_enabled, " .
"contact_additive_inheritance, cg_additive_inheritance, service_inherit_contacts_from_host, " .
"contact_additive_inheritance, cg_additive_inheritance, " .
"service_use_only_contacts_from_host, service_stalking_options, service_first_notification_delay, " .
"service_comment, command_command_id_arg, command_command_id_arg2, service_register, service_locked, " .
"service_activate) " .
Expand Down Expand Up @@ -1355,9 +1355,6 @@ public function insert($ret)
$rq .= "'2', ";
$rq .= (isset($ret["contact_additive_inheritance"]) ? 1 : 0) . ', ';
$rq .= (isset($ret["cg_additive_inheritance"]) ? 1 : 0) . ', ';
isset($ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"]) &&
$ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"] != null ?
$rq .= "'" . $ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"] . "', " :
$rq .= "'NULL', ";
isset($ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]) &&
$ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] != null ?
Expand Down Expand Up @@ -1526,12 +1523,6 @@ public function update($service_id, $ret)
$ret["service_notifications_enabled"]["service_notifications_enabled"] != 2 ?
$rq .= "'".$ret["service_notifications_enabled"]["service_notifications_enabled"]."', " : $rq .= "'2', ";

$rq .= "service_inherit_contacts_from_host = ";
isset($ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"]) &&
$ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"] != null ?
$rq .= "'".$ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"]."', " :
$rq .= "NULL, ";

$rq .= "service_use_only_contacts_from_host = ";
isset($ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]) &&
$ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] != null ?
Expand Down
9 changes: 4 additions & 5 deletions www/class/config-generate/abstract/service.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ abstract class AbstractService extends AbstractObject {
service_recovery_notification_delay as recovery_notification_delay,
service_stalking_options as stalking_options,
service_register as register,
service_inherit_contacts_from_host,
esi_notes as notes,
esi_notes_url as notes_url,
esi_action_url as action_url,
Expand Down Expand Up @@ -182,13 +181,13 @@ protected function getContacts(&$service) {
if (!is_null($service['contact_additive_inheritance']) && $service['contact_additive_inheritance'] == 1) {
$service['contacts'] = '+' . $service['contacts'];
}
}
}
}
}

protected function getContactGroups(&$service)
{
if (isset($service['service_use_only_contacts_from_host']) && $service['service_use_only_contacts_from_host'] == 1) {
{
if (isset($service['service_use_only_contacts_from_host']) && $service['service_use_only_contacts_from_host'] == 1) {
$service['contact_groups_cache'] = array();
$service['contact_groups'] = "";
} else {
Expand All @@ -209,7 +208,7 @@ protected function getContactGroups(&$service)
if (!is_null($service['cg_additive_inheritance']) && $service['cg_additive_inheritance'] == 1) {
$service['contact_groups'] = '+' . $service['contact_groups'];
}
}
}
}
}

Expand Down
20 changes: 10 additions & 10 deletions www/class/config-generate/service.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ private function browseContactsInStpl($service_id) {
}

$service_tpl_top_id = $service_tpl_id;
$services_tpl[$service_tpl_top_id]['has_tpl_contacts'] = 0;
$services_tpl[$service_tpl_top_id]['has_tpl_contact_groups'] = 0;
while (!is_null($service_tpl_id)) {
if (isset($loop[$service_tpl_id])) {
break;
Expand All @@ -135,12 +133,17 @@ private function browseContactsInStpl($service_id) {
$services_tpl[$service_tpl_top_id]['has_tpl_contact_groups'] = $services_tpl[$service_tpl_id]['has_tpl_contact_groups'];
break;
}

foreach (array('contact_groups', 'contacts') as $type) {
if (!is_null($services_tpl[$service_tpl_id][$type]) && $services_tpl[$service_tpl_id][$type] != '') {
$services_tpl[$service_tpl_top_id]['has_tpl_contacts'] = 1;
}

if (!is_null($services_tpl[$service_tpl_id]['contacts']) &&
$services_tpl[$service_tpl_id]['contacts'] != '') {
$services_tpl[$service_tpl_top_id]['has_tpl_contacts'] = 1;
}

if (!is_null($services_tpl[$service_tpl_id]['contact_groups']) &&
$services_tpl[$service_tpl_id]['contact_groups'] != '') {
$services_tpl[$service_tpl_top_id]['has_tpl_contact_groups'] = 1;
}

$service_tpl_id = isset($services_tpl[$service_tpl_id]['service_template_model_stm_id']) ? $services_tpl[$service_tpl_id]['service_template_model_stm_id'] : null;
}

Expand Down Expand Up @@ -168,9 +171,6 @@ private function getContactsFromHost($host_id, $service_id, $sOnlyContactHost) {
$this->service_cache[$service_id]['contact_from_host'] = 1;
} else {
$this->service_cache[$service_id]['contact_from_host'] = 0;
if (is_null($this->service_cache[$service_id]['service_inherit_contacts_from_host']) || $this->service_cache[$service_id]['service_inherit_contacts_from_host'] == 0) {
return 0;
}
if ($this->isServiceHasContacts($service_id)) {
return 0;
}
Expand Down
1 change: 0 additions & 1 deletion www/class/config-generate/servicetemplate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class ServiceTemplate extends AbstractService {
service_recovery_notification_delay as recovery_notification_delay,
service_stalking_options as stalking_options,
service_register as register,
service_inherit_contacts_from_host,
service_use_only_contacts_from_host,
esi_notes as notes,
esi_notes_url as notes_url,
Expand Down
30 changes: 1 addition & 29 deletions www/include/configuration/configObject/service/DB-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,6 @@ function insertServiceInDB($ret = array(), $macro_on_demand = null)
updateServiceNotifOptionTimeperiod($service_id, $ret);
updateServiceNotifOptionFirstNotificationDelay($service_id, $ret);
updateServiceHost($service_id, $ret);
updateServiceHostContactsInheritance($service_id, $ret);
updateServiceServiceGroup($service_id, $ret);
insertServiceExtInfos($service_id, $ret);
updateServiceTrap($service_id, $ret);
Expand Down Expand Up @@ -826,7 +825,7 @@ function insertService($ret = array(), $macro_on_demand = null)
"service_event_handler_enabled, service_low_flap_threshold, service_high_flap_threshold, service_flap_detection_enabled, " .
"service_retain_status_information, service_retain_nonstatus_information, service_notification_interval, " .
"service_notification_options, service_notifications_enabled, contact_additive_inheritance, cg_additive_inheritance, " .
"service_inherit_contacts_from_host, service_use_only_contacts_from_host, service_stalking_options, " .
"service_use_only_contacts_from_host, service_stalking_options, " .
"service_first_notification_delay, service_recovery_notification_delay," .
"service_comment, geo_coords, command_command_id_arg, command_command_id_arg2, " .
"service_register, service_activate, service_acknowledgement_timeout) " .
Expand Down Expand Up @@ -858,7 +857,6 @@ function insertService($ret = array(), $macro_on_demand = null)
isset($ret["service_notifications_enabled"]["service_notifications_enabled"]) && $ret["service_notifications_enabled"]["service_notifications_enabled"] != 2 ? $rq .= "'".$ret["service_notifications_enabled"]["service_notifications_enabled"]."', " : $rq .= "'2', ";
$rq .= (isset($ret["contact_additive_inheritance"]) ? 1 : 0) . ', ';
$rq .= (isset($ret["cg_additive_inheritance"]) ? 1 : 0) . ', ';
isset($ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"]) && $ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"] != null ? $rq .= "'".$ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"]."', " : $rq .= "'NULL', ";
isset($ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]) && $ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] != null ? $rq .= "'".$ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]."', " : $rq .= "'NULL', ";
isset($ret["service_stalOpts"]) && $ret["service_stalOpts"] != null ? $rq .= "'".implode(",", array_keys($ret["service_stalOpts"]))."', " : $rq .= "NULL, ";
isset($ret["service_first_notification_delay"]) && $ret["service_first_notification_delay"] != null ? $rq .= "'".$ret["service_first_notification_delay"]."', " : $rq .= "NULL, ";
Expand Down Expand Up @@ -1048,8 +1046,6 @@ function updateService($service_id = null, $from_MC = false, $params = array())
isset($ret["service_notifications_enabled"]["service_notifications_enabled"]) && $ret["service_notifications_enabled"]["service_notifications_enabled"] != 2 ? $rq .= "'".$ret["service_notifications_enabled"]["service_notifications_enabled"]."', " : $rq .= "'2', ";
$rq .= "service_recovery_notification_delay = ";
isset($ret['service_recovery_notification_delay']) && $ret['service_recovery_notification_delay'] != null ? $rq .= $ret['service_recovery_notification_delay'] . ', ' : $rq .= 'NULL, ';
$rq .= "service_inherit_contacts_from_host = ";
isset($ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"]) && $ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"] != null ? $rq .= "'".$ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"]."', " : $rq .= "NULL, ";
$rq .= "service_use_only_contacts_from_host = ";
isset($ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]) && $ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"] != null ? $rq .= "'".$ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]."', " : $rq .= "NULL, ";

Expand Down Expand Up @@ -1220,9 +1216,6 @@ function updateService_MC($service_id = null, $params = array())
if (isset($ret["mc_cg_additive_inheritance"]["mc_cg_additive_inheritance"]) && in_array($ret["mc_cg_additive_inheritance"]["mc_cg_additive_inheritance"], array('0', '1'))) {
$rq .= "cg_additive_inheritance = '" . $ret["mc_cg_additive_inheritance"]["mc_cg_additive_inheritance"] . "', ";
}
if (isset($ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"])) {
$rq .= "service_inherit_contacts_from_host = '".$ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"]."', ";
}
if (isset($ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"])) {
$rq .= "service_use_only_contacts_from_host = '".$ret["service_use_only_contacts_from_host"]["service_use_only_contacts_from_host"]."', ";
}
Expand Down Expand Up @@ -1744,27 +1737,6 @@ function updateServiceTrap_MC($service_id = null)
}
}
}

function updateServiceHostContactsInheritance($service_id = null, $ret = array())
{
global $form, $pearDB;

if (!$service_id) {
return;
}

if (isset($ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"])) {
$ret = $ret["service_inherit_contacts_from_host"]["service_inherit_contacts_from_host"];
} else {
$ret = $form->getSubmitValue("service_inherit_contacts_from_host");
}

$rq = "UPDATE service SET " ;
$rq .= "service_inherit_contacts_from_host = ";
isset($ret) && $ret != null ? $rq .= "'".$ret['service_inherit_contacts_from_host']["service_inherit_contacts_from_host"]."' " : $rq .= "NULL ";
$rq .= "WHERE service_id = '".$service_id."'";
$DBRESULT = $pearDB->query($rq);
}

function updateServiceHost($service_id = null, $ret = array(), $from_MC = false)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,13 @@ jQuery(function() {

function bindInhertance() {
if (jQuery("input[name='service_use_only_contacts_from_host[service_use_only_contacts_from_host]']:checked").val() == "1") {
jQuery("input[name='service_inherit_contacts_from_host[service_inherit_contacts_from_host]']").attr('disabled', 'disabled').removeAttr('checked');
jQuery("input[name='contact_additive_inheritance']").attr('disabled', 'disabled');
jQuery("input[name='cg_additive_inheritance']").attr('disabled', 'disabled');
jQuery("#service_cs").attr('disabled', 'disabled');
jQuery("#service_cs").select2("val", "");
jQuery("#service_cgs").attr('disabled', 'disabled');
jQuery("#service_cgs").select2("val", "");
} else {
jQuery("input[name='service_inherit_contacts_from_host[service_inherit_contacts_from_host]']").removeAttr('disabled');
jQuery("input[name='contact_additive_inheritance']").removeAttr('disabled');
jQuery("input[name='cg_additive_inheritance']").removeAttr('disabled');
jQuery("#service_cs").removeAttr('disabled');
Expand Down
16 changes: 10 additions & 6 deletions www/include/monitoring/common-Func.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,12 @@ function get_notified_infos_for_service($service_id, $host_id)

// Get Service Notifications options
$additive = false;
$DBRESULT = $pearDB->query("SELECT contact_additive_inheritance, cg_additive_inheritance, service_inherit_contacts_from_host
FROM service WHERE service_id = '" . CentreonDB::escape($service_id) . "'");
$DBRESULT = $pearDB->query(
"SELECT contact_additive_inheritance, cg_additive_inheritance, service_use_only_contacts_from_host " .
"FROM service WHERE service_id = '" . CentreonDB::escape($service_id) . "'"
);
$serviceParam = $DBRESULT->fetchRow();
$inherit_from_host = $serviceParam["service_inherit_contacts_from_host"];
$useOnlyContactsFromHost = $serviceParam["service_use_only_contacts_from_host"];

$serviceStack[] = array(
"service_id" => $service_id,
Expand Down Expand Up @@ -276,11 +278,13 @@ function get_notified_infos_for_service($service_id, $host_id)
}
}

if ((count($contacts) == 0) && (count($contactGroups) == 0) && ($inherit_from_host)) {
if ($useOnlyContactsFromHost || (count($contacts) == 0) && (count($contactGroups) == 0)) {
return get_notified_infos_for_host($host_id);
} else {
return array('contacts' => $contacts,
'contactGroups' => $contactGroups);
return array(
'contacts' => $contacts,
'contactGroups' => $contactGroups
);
}
}

Expand Down
1 change: 0 additions & 1 deletion www/install/createTables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,6 @@ CREATE TABLE `service` (
`service_notifications_enabled` enum('0','1','2') DEFAULT '2',
`contact_additive_inheritance` boolean DEFAULT 0,
`cg_additive_inheritance` boolean DEFAULT 0,
`service_inherit_contacts_from_host` enum('0','1') DEFAULT '1',
`service_use_only_contacts_from_host` enum('0','1') DEFAULT '0',
`service_first_notification_delay` int(11) DEFAULT NULL,
`service_acknowledgement_timeout` int(11) DEFAULT NULL,
Expand Down
4 changes: 3 additions & 1 deletion www/install/sql/centreon/Update-DB-2.8.9_to_2.8.10.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ INSERT INTO `nagios_macro` (`macro_name`) VALUES ('$HOSTTIMEZONE$');

ALTER TABLE `cfg_nagios` DROP COLUMN `log_initial_states`;
ALTER TABLE `cfg_nagios` ADD COLUMN `use_timezone` int(11) unsigned DEFAULT NULL AFTER `nagios_name`,
ADD CONSTRAINT `cfg_nagios_ibfk_27` FOREIGN KEY (`use_timezone`) REFERENCES `timezone` (`timezone_id`) ON DELETE CASCADE;
ADD CONSTRAINT `cfg_nagios_ibfk_27` FOREIGN KEY (`use_timezone`) REFERENCES `timezone` (`timezone_id`) ON DELETE CASCADE;

ALTER TABLE `service` DROP COLUMN `service_inherit_contacts_from_host`;