From d6b9833c377ae1dfc52334708eea73171c5cccc6 Mon Sep 17 00:00:00 2001 From: Raphael Jackstadt Date: Sun, 5 Nov 2017 17:58:50 +0100 Subject: [PATCH] added list_group_perms($group_par) Thanks @oniricosistemas for the nice function --- application/libraries/Aauth.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index 54dd9f2..79b32fe 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -1583,6 +1583,31 @@ class Aauth { return $this->aauth_db->delete($this->config_vars['perms']); } + /** + * List Group Permissions + * List all permissions by Group + * @param int $group_par Group id or name to check + * @return object Array of permissions + */ + public function list_group_perms($group_par) { + if(empty($group_par)){ + return false; + } + + $group_par = $this->get_group_id($group_par); + + $this->aauth_db->select('*'); + $this->aauth_db->from($this->config_vars['perms']); + $this->aauth_db->join($this->config_vars['perm_to_group'], "perm_id = ".$this->config_vars['perms'].".id"); + $this->aauth_db->where($this->config_vars['perm_to_group'].'.group_id', $group_par); + + $query = $this->aauth_db->get(); + if ($query->num_rows() == 0) + return FALSE; + + return $query->result(); + } + /** * Is user allowed * Check if user allowed to do specified action, admin always allowed