Teknik is a suite of services with attractive and functional interfaces. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627
  1. <?php
  2. class Role
  3. {
  4. protected $permissions;
  5. protected function __construct() {
  6. $this->permissions = array();
  7. }
  8. // return a role object with associated permissions
  9. public static function getRolePerms($role_id, $db)
  10. {
  11. $role = new Role();
  12. $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_desc");
  13. foreach ($results as $result)
  14. {
  15. $role->permissions[$result["perm_desc"]] = true;
  16. }
  17. return $role;
  18. }
  19. // check if a permission is set
  20. public function hasPerm($permission) {
  21. return isset($this->permissions[$permission]);
  22. }
  23. }
  24. ?>