From 60ce78c958e517f6711d7308e54313c2cb48f1bb Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 29 May 2015 08:57:49 +0200 Subject: [PATCH] DbUserGroupBackend: Adjust how to load the name of a group's parent refs #8826 --- .../UserGroup/DbUserGroupBackend.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php b/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php index 2cf177e01..10e2b8036 100644 --- a/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php +++ b/library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php @@ -115,10 +115,23 @@ class DbUserGroupBackend extends DbRepository implements UserGroupBackendInterfa */ public function getMemberships(User $user) { + $groupQuery = $this->ds + ->select() + ->from( + array('g' => $this->prependTablePrefix('group')), + array( + 'group_name' => 'g.name', + 'parent_name' => 'gg.name' + ) + )->joinLeft( + array('gg' => $this->prependTablePrefix('group')), + 'g.parent = gg.id', + array() + ); + $groups = array(); - foreach ($this->ds->select()->from($this->prependTablePrefix('group'), array('name', 'parent')) as $group) { - // Using the raw query here due to the non-existent necessity to join, convert, or... - $groups[$group->name] = $group->parent; + foreach ($groupQuery as $group) { + $groups[$group->group_name] = $group->parent_name; } $membershipQuery = $this