Skip to content

Commit

Permalink
DbUserGroupBackend: Do not use the repository abstraction internally
Browse files Browse the repository at this point in the history
That's overhead which is not necessary.

refs #8826
  • Loading branch information
Johannes Meyer committed May 13, 2015
1 parent 7d98206 commit 47dfcf5
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions library/Icinga/Authentication/UserGroup/DbUserGroupBackend.php
Expand Up @@ -102,19 +102,23 @@ public function update($table, array $bind, Filter $filter = null)
*/
public function getMemberships(User $user)
{
$groupStmt = $this->ds->select()
->from($this->prependTablePrefix('group'), array('name', 'parent'))
->getSelectQuery()
->query();
$groups = array();
$groupsStmt = $this->select(array('group_name', 'parent_name'))->getQuery()->getSelectQuery()->query();
foreach ($groupsStmt as $group) {
$groups[$group->group_name] = $group->parent_name;
foreach ($groupStmt as $group) {
$groups[$group->name] = $group->parent;
}

$memberships = array();
$membershipsStmt = $this->ds->getDbAdapter() // TODO: Use the join feature, once available
->select()
->from($this->ds->getTablePrefix() . 'group_membership', array('group_name'))
->where('username = ?', $user->getUsername())
$membershipStmt = $this->ds->select() // TODO: Join this table
->from($this->prependTablePrefix('group_membership'), array('group_name'))
->where('username', $user->getUsername())
->getSelectQuery()
->query();
foreach ($membershipsStmt as $membership) {
$memberships = array();

foreach ($membershipStmt as $membership) {
$memberships[] = $membership->group_name;
$parent = $groups[$membership->group_name];
while ($parent !== null) {
Expand Down

0 comments on commit 47dfcf5

Please sign in to comment.