diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index 4665c4ba..a4b4c4e8 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -133,7 +133,7 @@ class HostController extends ObjectController $this->addHostServiceSetTables($host, $tables); foreach ($parents as $parent) { - $this->addHostServiceSetTables($host, $tables); + $this->addHostServiceSetTables($parent, $tables, $host); } $title = $this->translate('Applied services'); @@ -149,9 +149,12 @@ class HostController extends ObjectController $this->view->tables = $tables; } - protected function addHostServiceSetTables(IcingaHost $host, & $tables) + protected function addHostServiceSetTables(IcingaHost $host, & $tables, IcingaHost $affectedHost = null) { $db = $this->db(); + if ($affectedHost === null) { + $affectedHost = $host; + } $query = $db->getDbAdapter()->select() ->from( @@ -168,12 +171,12 @@ class HostController extends ObjectController )->where('hs.host_id = ?', $host->id); $sets = IcingaServiceSet::loadAll($db, $query, 'object_name'); - foreach ($sets as $name => $set) { $title = sprintf($this->translate('%s (Service set)'), $name); $table = $this->loadTable('IcingaServiceSetService') ->setServiceSet($set) ->setHost($host) + ->setAffectedHost($affectedHost) ->setTitle($title) ->setConnection($db); diff --git a/application/tables/IcingaServiceSetServiceTable.php b/application/tables/IcingaServiceSetServiceTable.php index 97642fb2..36cc2710 100644 --- a/application/tables/IcingaServiceSetServiceTable.php +++ b/application/tables/IcingaServiceSetServiceTable.php @@ -15,6 +15,8 @@ class IcingaServiceSetServiceTable extends QuickTable /** @var IcingaHost */ protected $host; + protected $affectedHost; + protected $searchColumns = array( 'service', ); @@ -43,6 +45,12 @@ class IcingaServiceSetServiceTable extends QuickTable return $this; } + public function setAffectedHost(IcingaHost $host) + { + $this->affectedHost = $host; + return $this; + } + public function setServiceSet(IcingaServiceSet $set) { $this->set = $set; @@ -62,7 +70,7 @@ class IcingaServiceSetServiceTable extends QuickTable { if ($this->host) { $params = array( - 'name' => $this->host->getObjectName(), + 'name' => $this->affectedHost->getObjectName(), 'service' => $row->service, 'set' => $row->service_set ); @@ -93,20 +101,38 @@ class IcingaServiceSetServiceTable extends QuickTable $title = $view->escape(array_shift($row)); $htm = "\n \n"; - - $deleteLink = $view->qlink( - $view->translate('Remove'), - 'director/host/removeset', - array( - 'name' => $this->host->getObjectName(), - 'setId' => $this->set->id - ), - array( - 'class' => 'icon-cancel', - 'style' => 'float: right; font-weight: normal', - 'title' => $view->translate('Remove this set from this host') - ) - ); + if ($this->affectedHost->id !== $this->host->id) { + $deleteLink = $view->qlink( + $this->host->getObjectName(), + 'director/host/services', + array( + 'name' => $this->host->getObjectName(), + ), + array( + 'class' => 'icon-paste', + 'style' => 'float: right; font-weight: normal', + 'data-base-target' => '_next', + 'title' => sprintf( + $view->translate('This set has been inherited from %s'), + $this->host->getObjectName() + ) + ) + ); + } else { + $deleteLink = $view->qlink( + $view->translate('Remove'), + 'director/host/removeset', + array( + 'name' => $this->host->getObjectName(), + 'setId' => $this->set->id + ), + array( + 'class' => 'icon-cancel', + 'style' => 'float: right; font-weight: normal', + 'title' => $view->translate('Remove this set from this host') + ) + ); + } $htm .= ' ' . $view->escape($title) . "$deleteLink\n";