Skip to content

Commit 9becdd3

Browse files
committed
added get_group_perms($group_par) & get_user_perms($user_id = FALSE)
1 parent 5c9da3d commit 9becdd3

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

application/libraries/Aauth.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,27 @@ public function get_user_groups($user_id = FALSE){
11331133
return $query->result();
11341134
}
11351135

1136+
/**
1137+
* Get user permissions
1138+
* Get user permissions from user id ( ! Case sensitive)
1139+
* @param int|bool $user_id User id to get or FALSE for current user
1140+
* @return int Group id
1141+
*/
1142+
public function get_user_perms ( $user_id = FALSE ) {
1143+
if( ! $user_id) { $user_id = $this->CI->session->userdata('id'); }
1144+
1145+
if($user_id){
1146+
$query = $this->aauth_db->select($this->config_vars['perms'].'.*');
1147+
$query = $this->aauth_db->where('user_id', $user_id);
1148+
$query = $this->aauth_db->join($this->config_vars['perms'], $this->config_vars['perms'].'.id = '.$this->config_vars['perm_to_user'].'.perm_id');
1149+
$query = $this->aauth_db->get($this->config_vars['perm_to_user']);
1150+
1151+
return $query->result();
1152+
}
1153+
1154+
return FALSE;
1155+
}
1156+
11361157
//tested
11371158
/**
11381159
* Update activity
@@ -1505,6 +1526,25 @@ public function get_group ( $group_par ) {
15051526
return FALSE;
15061527
}
15071528

1529+
/**
1530+
* Get group permissions
1531+
* Get group permissions from group name or id ( ! Case sensitive)
1532+
* @param int|string $group_par Group id or name to get
1533+
* @return int Group id
1534+
*/
1535+
public function get_group_perms ( $group_par ) {
1536+
if ($group_id = $this->get_group_id($group_par)) {
1537+
$query = $this->aauth_db->select($this->config_vars['perms'].'.*');
1538+
$query = $this->aauth_db->where('group_id', $group_id);
1539+
$query = $this->aauth_db->join($this->config_vars['perms'], $this->config_vars['perms'].'.id = '.$this->config_vars['perm_to_group'].'.perm_id');
1540+
$query = $this->aauth_db->get($this->config_vars['perm_to_group']);
1541+
1542+
return $query->result();
1543+
}
1544+
1545+
return FALSE;
1546+
}
1547+
15081548
/**
15091549
* Get subgroups
15101550
* Get subgroups from group name or id ( ! Case sensitive)

0 commit comments

Comments
 (0)