mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 09:14:09 +02:00
parent
fe332897be
commit
785746fb26
@ -11,12 +11,10 @@ class GroupMembershipCache
|
|||||||
|
|
||||||
protected $table;
|
protected $table;
|
||||||
|
|
||||||
protected $groupsClass;
|
protected $groupClass;
|
||||||
|
|
||||||
protected $memberships;
|
protected $memberships;
|
||||||
|
|
||||||
protected $membershipsById;
|
|
||||||
|
|
||||||
/** @var Db Director database connection */
|
/** @var Db Director database connection */
|
||||||
protected $connection;
|
protected $connection;
|
||||||
|
|
||||||
@ -35,7 +33,7 @@ class GroupMembershipCache
|
|||||||
protected function loadAllMemberships()
|
protected function loadAllMemberships()
|
||||||
{
|
{
|
||||||
$db = $this->connection->getDbAdapter();
|
$db = $this->connection->getDbAdapter();
|
||||||
$this->memberships = $this->membershipsById = array();
|
$this->memberships = array();
|
||||||
|
|
||||||
$type = $this->type;
|
$type = $this->type;
|
||||||
$table = $this->table;
|
$table = $this->table;
|
||||||
@ -58,11 +56,11 @@ class GroupMembershipCache
|
|||||||
)->order('g.object_name');
|
)->order('g.object_name');
|
||||||
|
|
||||||
foreach ($db->fetchAll($query) as $row) {
|
foreach ($db->fetchAll($query) as $row) {
|
||||||
if (! array_key_exists($row->object_id, $this->membershipsById)) {
|
if (! array_key_exists($row->object_id, $this->memberships)) {
|
||||||
$this->membershipsById[$row->object_id] = array();
|
$this->memberships[$row->object_id] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->membershipsById[$row->object_id][$row->group_id] = $row->group_name;
|
$this->memberships[$row->object_id][$row->group_id] = $row->group_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +85,10 @@ class GroupMembershipCache
|
|||||||
public function getGroupsForObject(IcingaObject $object)
|
public function getGroupsForObject(IcingaObject $object)
|
||||||
{
|
{
|
||||||
$groups = array();
|
$groups = array();
|
||||||
$class = $this->groupsClass;
|
$class = $this->groupClass;
|
||||||
|
|
||||||
foreach ($this->listGroupIdsForObject($object) as $id) {
|
foreach ($this->listGroupIdsForObject($object) as $id) {
|
||||||
$groups[] = $class::loadWithAutoIncId($id, $this->connection);
|
$object = $class::loadWithAutoIncId($id, $this->connection);
|
||||||
|
$groups[$object->object_name] = $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $groups;
|
return $groups;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user