mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 00:34:05 +02:00
IcingaHostForm: Move getAppliedGroups to IcingaObject
This commit is contained in:
parent
cceb588d24
commit
26e58834f6
@ -283,24 +283,7 @@ class IcingaHostForm extends DirectorObjectForm
|
||||
return [];
|
||||
}
|
||||
|
||||
$db = $this->getDb()->getDbAdapter();
|
||||
$query = $db->select()->from(
|
||||
['hghr' => 'icinga_hostgroup_host_resolved'],
|
||||
['hg.object_name']
|
||||
)->join(
|
||||
['hg' => 'icinga_hostgroup'],
|
||||
'hg.id = hghr.hostgroup_id',
|
||||
[]
|
||||
)->joinLeft(
|
||||
['hgh' => 'icinga_hostgroup_host'],
|
||||
'hgh.hostgroup_id = hghr.hostgroup_id',
|
||||
[]
|
||||
)->where(
|
||||
'hghr.host_id = ?',
|
||||
$this->object()->get('id')
|
||||
)->where('hgh.host_id IS NULL')->order('hg.object_name');
|
||||
|
||||
return $db->fetchCol($query);
|
||||
return $this->object()->getAppliedGroups();
|
||||
}
|
||||
|
||||
protected function hasHostGroupRestriction()
|
||||
|
@ -853,6 +853,34 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
||||
|
||||
return $this->groups->hasBeenModified();
|
||||
}
|
||||
|
||||
public function getAppliedGroups()
|
||||
{
|
||||
$this->assertGroupsSupport();
|
||||
if (! $this instanceof IcingaHost) {
|
||||
throw new ProgrammingError('getAppliedGroups is only available for hosts currently!');
|
||||
}
|
||||
|
||||
$type = strtolower($this->type);
|
||||
$query = $this->db->select()->from(
|
||||
['gr' => "icinga_${type}group_${type}_resolved"],
|
||||
['g.object_name']
|
||||
)->join(
|
||||
['g' => "icinga_${type}group"],
|
||||
"g.id = gr.${type}group_id",
|
||||
[]
|
||||
)->joinLeft(
|
||||
['go' => "icinga_${type}group_${type}"],
|
||||
"go.${type}group_id = gr.${type}group_id",
|
||||
[]
|
||||
)->where(
|
||||
"gr.${type}_id = ?",
|
||||
$this->id
|
||||
)->where("go.${type}_id IS NULL")->order('g.object_name');
|
||||
|
||||
return $this->db->fetchCol($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return IcingaTimePeriodRanges
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user