Browse Source

Moved permission asking to User class

tags/v1.3^2
Teknikode 6 years ago
parent
commit
d44a6f3b6e
2 changed files with 19 additions and 19 deletions
  1. 19
    0
      includes/classes/User.class.php
  2. 0
    19
      includes/classes/UserTools.class.php

+ 19
- 0
includes/classes/User.class.php View File

@@ -88,5 +88,24 @@ class User {
$db->delete('users', 'id=?', array($this->id));
return true;
}
// check if user has a specific privilege
public function hasPrivilege($perm)
{
foreach ($this->roles as $role)
{
if ($role->hasPerm($perm))
{
return true;
}
}
return false;
}
// check if a user has a specific role
public function hasRole($role_name)
{
return isset($this->roles[$role_name]);
}
}
?>

+ 0
- 19
includes/classes/UserTools.class.php View File

@@ -139,25 +139,6 @@ class UserTools {
$result = $this->db->select('users', "id=?", array($id));
return new User($result, $this->db);
}
// check if user has a specific privilege
public function hasPrivilege($perm)
{
foreach ($this->roles as $role)
{
if ($role->hasPerm($perm))
{
return true;
}
}
return false;
}
// check if a user has a specific role
public function hasRole($role_name)
{
return isset($this->roles[$role_name]);
}
// insert a new role permission association
public function insertPerm($role_id, $perm_id)

Loading…
Cancel
Save