Checks to see if a role has a permission or not

@param integer $Role
ID
@param integer $Permission
ID
@return boolean

@todo: If we pass a Role that doesn't exist the method just returns false. We may want to check for a valid Role.
8465
function hasPermission($Role, $Permission)
	{
		$Res = Jf::sql ( "
					SELECT COUNT(*) AS Result
					FROM {$this->tablePrefix()}rolepermissions AS TRel
					JOIN {$this->tablePrefix()}permissions AS TP ON ( TP.ID= TRel.PermissionID)
					JOIN {$this->tablePrefix()}roles AS TR ON ( TR.ID = TRel.RoleID)
					WHERE TR.Lft BETWEEN
					(SELECT Lft FROM {$this->tablePrefix()}roles WHERE ID=?)
					AND
					(SELECT Rght FROM {$this->tablePrefix()}roles WHERE ID=?)
					/* the above section means any row that is a descendants of our role (if descendant roles have some permission, then our role has it two) */
					AND TP.ID IN (
					SELECT parent.ID
					FROM {$this->tablePrefix()}permissions AS node,
					{$this->tablePrefix()}permissions AS parent
					WHERE node.Lft BETWEEN parent.Lft AND parent.Rght
					AND ( node.ID=? )
					ORDER BY parent.Lft
					);
					/*
					the above section returns all the parents of (the path to) our permission, so if one of our role or its descendants
					has an assignment to any of them, we're good.
					*/
					", $Role, $Role, $Permission );
		return $Res [0] ['Result'] >= 1;
	}
1190327
public function hasRole($role)
    {
        return is_null($this->roles) || in_array($role, $this->roles, true);
    }
241325
public function hasPermission($permission)
    {
        if ($permission instanceof Permission) {
            $permission = $permission->name;
        }
        return $this->getRoleSet()->has_permission($permission);
    }
1102389
public function hasPermission($permission)
    {
        if (!$this->permissions->where('token', $permission)->isEmpty()) {
            return true;
        }

        foreach ($this->groups as $group) {
            foreach ($group->roles as $role) {
                if (!$role->permissions->where('token', $permission)->isEmpty()) {
                    return true;
                }
            }
        }

        foreach ($this->roles as $role) {
            if (!$role->permissions->where('token', $permission)->isEmpty()) {
                return true;
            }
        }

        return false;
    }
39822
public boolean hasPermissionById(String id, String permission) {
        Permission resolvedPermission = getPermissionResolver().resolvePermission(permission);
        return hasPermissionById(id, resolvedPermission);
    }
14896
public function hasPermissionThroughRole($permission)
    {
        if (! $this->isMethodRolesExists()) {
            return false;
        }

        if (! $permission = $this->preparePermission($permission)) {
            return false;   
        }

        foreach ($permission->roles as $role) { 
            if ($this->roles->contains($role)) {
                return true;
            }
        }

        return false;
    }
915121
public function checkPermission($roleId, $action)
    {
        if ($roleId == ROLE_ID_ADMINISTRATOR) {
            return true;
        }

        $this->_loadPermissions();
        $rule = $this->_permissions
            ->filter(function ($rule) use ($roleId, $action) {
                return $rule->get('role_id') == $roleId && $rule->get('action') == $action;
            })
            ->first();

        return !empty($rule);
    }
1223098
public function storeRolePermission(Role $role, Permission $permission)
    {
        $this->getTable()->insert([
            'role' => $role->getRoleName(),
            'type' => $permission->getType(),
            'action' => $permission->getAction(),
            'resource_type' => $permission->getResourceType(),
            'resource_id' => $permission->getResourceId(),
        ]);

        $this->resetPermissionsCacheForRole($role);
    }
100407
public function hasPermission($permissionName) {
		foreach ($this->role->sharedPermissionList as $permission) {
			if ($permission->name == $permissionName) {
				return true;
			}
		}

		return false;
	}
1004802
public function hasPermission($permission)
    {
        $permission = !is_string($permission) ?: Permission::where(['slug' => $permission])->first();
        
        if (config('laralum.superadmin_bypass_haspermission')) {
            return true;
        }
        
        if ($permission) {
            foreach ($this->roles as $role) {
                if ($role->hasPermission($permission)) {
                    return true;
                }
            }
        }

        return false;
    }
1115813
public function hasPermission($id)
    {
        if ($id instanceof Eloquent)
            $id = $id->getKey();

        return $this->permissions->contains('id', $id);
    }
142494
public function hasPermission($permission)
    {
        if ($this->isAdmin()) {
            return true;
        }

        if (is_null($this->permissions)) {
            $this->permissions = $this->getPermissions();
        }

        return in_array($permission, $this->permissions);
    }
484648
public function checkRole($role)
    {
        return $this->getRoles()->contains(function ($value) use ($role) {
            return $role == $value->id || Str::is($role, $value->slug);
        });
    }
676715
public function removeRolePermission(Role $role, Permission $permission)
    {
        $query = $this->getTable()
            ->where('role', $role->getRoleName())
            ->where('type', $permission->getType())
            ->where('action', $permission->getAction());

        if (is_null($permission->getResourceType())) {
            $query->whereNull('resource_type');
        } else {
            $query->where('resource_type', $permission->getResourceType());
        }

        if (is_null($permission->getResourceId())) {
            $query->whereNull('resource_id');
        } else {
            $query->where('resource_id', $permission->getResourceId());
        }

        $query->delete();

        $this->resetPermissionsCacheForRole($role);
    }
814858
public function hasPermission($permission)
    {
        if ($this->user() === null) {
            return null;
        }

        return in_array($permission, $this->permissions, true);
    }
846644
protected function checkPermission($permission = 'manage', $role = 'admin')
    {
        if ($this->auth->guest()) {
            return 401;
        }

        if ($this->auth->user()->can($permission) || $this->auth->user()->hasRole($role)) {
            return true;
        }

        return 403;
    }
1287162
public function getPermission($role)
    {
        if ($role instanceof RoleInterface || $role instanceof \Symfony\Component\Security\Core\Role\Role) {
            $role = $role->getRole();
        }
        if (isset($this->permissions[$role])) {
            return $this->permissions[$role];
        }

        return null;
    }