From 3a4d556acf7d5183c43534e1c677bc44f245232f Mon Sep 17 00:00:00 2001 From: REJack Date: Sun, 11 Nov 2018 19:46:25 +0100 Subject: [PATCH] enhanced `add_subgroup()` to check if group and subgroup already linked (#221) --- application/libraries/Aauth.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index 302dfe8..bc9fc30 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -1440,6 +1440,22 @@ class Aauth { return FALSE; } + if ($group_groups = $this->get_subgroups($group_id)) { + foreach ($group_groups as $item) { + if ($item->subgroup_id == $subgroup_id) { + return false; + } + } + } + + if ($subgroup_groups = $this->get_subgroups($subgroup_id)) { + foreach ($subgroup_groups as $item) { + if ($item->subgroup_id == $group_id) { + return false; + } + } + } + $query = $this->aauth_db->where('group_id',$group_id); $query = $this->aauth_db->where('subgroup_id',$subgroup_id); $query = $this->aauth_db->get($this->config_vars['group_to_group']);