Browse Source

Fixed grabbing of permissions

tags/v1.3^2
Teknikode 6 years ago
parent
commit
daf5fbade3
2 changed files with 26 additions and 7 deletions
  1. 13
    3
      includes/classes/Role.class.php
  2. 13
    4
      includes/classes/User.class.php

+ 13
- 3
includes/classes/Role.class.php View File

@@ -11,10 +11,20 @@ class Role
public static function getRolePerms($role_id, $db)
{
$role = new Role();
$db->select_raw("role_perm as rp JOIN permissions as p ON rp.perm_id = p.perm_id", "WHERE rp.role_id=?", array($role_id), "p.perm_name");
foreach ($results as $result)
$perm_list = $db->select_raw("role_perm as rp JOIN permissions as p ON rp.perm_id = p.perm_id", "WHERE rp.role_id=?", array($role_id), "p.perm_name");
$perms = array();
foreach ($perm_list as $perm)
{
$role->permissions[$result["perm_name"]] = true;
if (!is_array($perm))
{
$perms = array($perm_list);
break;
}
array_push($perms, $perm);
}
foreach ($perms as $perm)
{
$role->permissions[$perm["perm_name"]] = true;
}
return $role;
}

+ 13
- 4
includes/classes/User.class.php View File

@@ -37,11 +37,20 @@ class User {
$this->blog_title = (isset($data['blog_title'])) ? $data['blog_title'] : "";
$this->blog_desc = (isset($data['blog_desc'])) ? $data['blog_desc'] : "";
$this->roles = array();
$results = $db->select("user_role as ur JOIN roles as r ON ur.role_id = r.role_id", "ur.user_id=?", array($this->id), "ur.role_id, r.role_name");
$users = array();
foreach ($results as $result)
$user_list = $db->select("user_role as ur JOIN roles as r ON ur.role_id = r.role_id", "ur.user_id=?", array($this->id), "ur.role_id, r.role_name");
$users = array();
foreach ($user_list as $user)
{
$this->roles[$result["role_name"]] = Role::getRolePerms($result["role_id"], $db);
if (!is_array($user))
{
$users = array($user_list);
break;
}
array_push($users, $user);
}
foreach ($users as $user)
{
$this->roles[$user["role_name"]] = Role::getRolePerms($user["role_id"], $db);
}
}

Loading…
Cancel
Save