Checks the current users permissions against one or more permissions

@param string|array $perm
One permission by it'S name or an array of permissionnames

@return bool
425270
protected function checkAccess($permission): bool
    {
        return $this->app->core->user->permissions[$this->app->getName()]->allowedTo($permission);
    }
663864
def check_perms(perms, user, slug, raise_exception=False):
    """"""
    if isinstance(perms, string_types):
        perms = {perms}
    else:
        perms = set(perms)

    allowed_users = ACLRule.get_users_for(perms, slug)

    if allowed_users:
        return user in allowed_users

    if perms.issubset(set(WALIKI_ANONYMOUS_USER_PERMISSIONS)):
        return True

    if is_authenticated(user) and perms.issubset(set(WALIKI_LOGGED_USER_PERMISSIONS)):
        return True

    # First check if the user has the permission (even anon users)
    if user.has_perms(['waliki.%s' % p for p in perms]):
        return True
    # In case the 403 handler should be called raise the exception
    if raise_exception:
        raise PermissionDenied
    # As the last resort, show the login form
    return False
54040
def parse_permissions(perms):
    
    if isinstance(perms, six.string_types):
        perms = perms.split(',')
    perms = [perm.strip().lower() for perm in perms]
    if 'all' in perms:
        return ALL_PERMISSIONS
    return validate_permissions(perms)
110663
public void checkPermission(Permission perm, AddOnModel addOnModel) throws IzouPermissionException {
        try {
            rootPermission.checkPermission(perm, addOnModel);
            //its root
            return;
        } catch (IzouPermissionException ignored) {
            //its just not root
        }
        standardCheck.stream()
                .filter(permissionModule -> permissionModule.canCheckPermission(perm))
                .forEach(permissionModule -> permissionModule.checkPermission(perm, addOnModel));
    }
580530
private function hasCharacterPermission(array $permission)
    {

        $map = $this->getAffiliationMap();

        // Owning a character grants you '*' permissions to the owned object. In this
        // context, '*' acts as a wildcard for *all* permissions
        foreach ($map['char'] as $char => $permissions) {

            // in case the permissions array is not related to the character for which we're requesting access
            // skip
            if ($char != $this->getCharacterId())
                continue;

            // in case a wildcard access has been assigned (user is owner), grant access
            if (in_array('character.*', $permissions))
                return true;

            // yeah, this is dumb. So if we have an array permission, we need to
            // loop and check each in there.
            foreach ($permission as $sub_permission) {

                // check only character wildcard and specific permission
                if (in_array($sub_permission, $permissions))
                    return true;
            }
        }

        return false;
    }
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;
    }
829346
def has_perm(self, perm):
        
        if '.' in perm:
            app_label, codename = perm.split('.')
            permissions = self.permissions.filter(
                content_type__app_label = app_label, 
                codename = codename)
            groups = self.groups.filter(
                permissions__content_type__app_label = app_label,
                permissions__codename = codename )
        else:
            permissions = self.permissions.filter(codename = perm)
            groups = self.groups.filter(permissions__codename = perm)
        return permissions.exists() or groups.exists()
110256
public function can($permission, $requireAll = false)
    {
        if (is_array($permission)) {
            foreach ($permission as $permName) {
                $hasPerm = $this->can($permName);

                if ($hasPerm && !$requireAll) {
                    return true;
                } elseif (!$hasPerm && $requireAll) {
                    return false;
                }
            }

            // If we've made it this far and $requireAll is FALSE, then NONE of the perms were found
            // If we've made it this far and $requireAll is TRUE, then ALL of the perms were found.
            // Return the value of $requireAll;
            return $requireAll;
        } else {
            foreach ($this->cachedRoles() as $role) {
                // Validate against the Permission table
                foreach ($role->cachedPermissions() as $perm) {
                    if (str_is( $permission, $perm->name) ) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
443633
def delete_user_permissions(self, user, perm, obj, check_groups=False):
        
        user_perms = self.user_permissions(user, perm, obj, check_groups=False)
        if not user_perms.filter(object_id=obj.id):
            return
        perms = self.user_permissions(user, perm, obj).filter(object_id=obj.id)
        perms.delete()
1119326
public function hasPermission($permission)
    {
        if ($this->id == self::ADMINISTRATOR_ID) {
            return true;
        }

        return $this->permissions->contains('permission', $permission);
    }
243334
protected function userHasPermission(array $permissions)
    {
        if ( ! count($permissions)) {
            return true;
        }

        return (bool) count(
            array_filter($permissions, function ($permission) {
                return array_get($this->userPermissions, $permission);
            })
        );
    }
241325
public function hasPermission($permission)
    {
        if ($permission instanceof Permission) {
            $permission = $permission->name;
        }
        return $this->getRoleSet()->has_permission($permission);
    }
342123
public function has($permissions, $all = true)
    {
        if (! is_array($permissions)) {
            $permissions    =   (array) $permissions;
        }

        $permissions=   array_unique($permissions);
        $filtered   =   [];
        $usersRoles =   $this->roles;
        $allowed    =   false;
        $filtered   =   array_where($permissions, [$this, 'permissionFilter']);
        $filteredCount  =   count($filtered);

        // Does the permission lookup require all permissions to be found?
        if (true === $all) {
            return count($permissions) === $filteredCount;
        }

        // Nope, just as long as they have one of them
        return 0 < $filteredCount;
    }
186763
public function hasPermission($permission)
    {
        foreach ($this->permissions()->get() as $p) {
            if ($p->name == $permission) {
                return true;
            }
        }
        return false;
    }
100407
public function hasPermission($permissionName) {
		foreach ($this->role->sharedPermissionList as $permission) {
			if ($permission->name == $permissionName) {
				return true;
			}
		}

		return false;
	}
543013
protected function parsePermissions($perm, $user = '') {
		$res   = array();
		$parts = array();
		$owner = $user? ($user == $this->options['user']) : $this->options['owner'];
		for ($i = 0, $l = strlen($perm); $i < $l; $i++) {
			$parts[] = substr($perm, $i, 1);
		}

		$read = ($owner && $parts[0] == 'r') || $parts[4] == 'r' || $parts[7] == 'r';
		
		return array(
			'read'  => $parts[0] == 'd' ? $read && (($owner && $parts[3] == 'x') || $parts[6] == 'x' || $parts[9] == 'x') : $read,
			'write' => ($owner && $parts[2] == 'w') || $parts[5] == 'w' || $parts[8] == 'w'
		);
	}
893989
public function checkAccess(array $permissions = [], bool $force = false): bool
    {
        // Guests are not allowed by default
        if ($this->isGuest()) {
            return false;
        }

        // Allow access to all users when permissions argument is empty
        if (empty($permissions)) {
            return true;
        }

        // Administrators are supermen :P
        if ($this->isAdmin()) {
            return true;
        }

        // User has the right to do this?
        if (count(array_intersect($permissions, $this->perissions)) > 0) {
            return true;
        }

        // You aren't allowed, by default.
        return false;
    }