Check user access by pair module-privilege

@param  string $module
@param  string $privilege

@return bool
966783
public function isAllowed($module, $privilege): bool
    {
        if ($privilege) {
            $user = Auth::getIdentity();
            return $user && $user->hasPrivilege($module, $privilege);
        }
        return true;
    }
740089
private function checkPermission($permission)
    {
        if (!$permission)
        {
            return;
        }

        $user = $this->securityApi->getUser(true);
        if ($user instanceof Permissible && $user->hasAccess($permission))
        {
            return;
        }

        throw Unauthorized::permissionDenied($permission, $this->securityApi);
    }
621859
def permitted_to? (privilege, options = {}, &block)
      options = {
        :user =>  Authorization.current_user,
        :object => self
      }.merge(options)
      Authorization::Engine.instance.permit?(privilege,
          {:user => options[:user],
           :object => options[:object]},
          &block)
    end
831053
public function hasFunctionAccess( $user, $functionName, $contentObject, $languageCode, $comment = null, $scope = null, $node = null )
    {
        $result = $user->hasAccessTo( self::$moduleName, $functionName );

        if ( $result['accessWord'] !== 'limited' )
        {
            $return = ( $result['accessWord'] === 'yes' ) and ( $scope !== 'personal' );
        }
        else
        {
            foreach( $result['policies'] as $limitationArray )
            {
                // eZDebug::writeDebug( $limitationArray, "limitationArray for function $functionName" );

                $return = true;
                foreach( $limitationArray as $limitationKey => $limitation )
                {
                    // deal with limitation checking
                    $resultItem = $this->checkPermission( $user, $limitationKey, $limitation,
                        $contentObject, $languageCode, $comment, $scope, $node );
                    ezDebugSetting::writeNotice( 'extension-ezcomments',
                        "Permission check result for function '$functionName' with limitation '$limitationKey': " . ( $resultItem === true ? 'true' : 'false' ), __METHOD__ );
                    $return = ( $return and $resultItem );
                }

                if ( $return === true )
                    break;
            }
        }
        return $return;
    }
716255
public function access($permission, $user_id = null)
    {
        if ($this->isSuperadmin($user_id)) {
            return true;
        }

        if ($permission === GC_PERM_SUPERADMIN) {
            return false;
        }

        return in_array($permission, $this->getPermissions($user_id));
    }
1160452
public function canView($member = null)
    {
        if (!$member) {
            $member = Security::getCurrentUser();
        }

        // extended access checks
        $results = $this->extend('canView', $member);
        if ($results && is_array($results)) {
            if (!min($results)) {
                return false;
            }
        }

        // user needs access to CMS_ACCESS_SecurityAdmin
        if (Permission::checkMember($member, "CMS_ACCESS_SecurityAdmin")) {
            return true;
        }

        return false;
    }
647915
function isAllowed(/*iAuthResource*/ $resource = null, /*iIdentity*/ $role = null)
    {
        $role = ($role) ?: $this->identity();

        if (!is_object($resource)
            || (!$resource instanceof PermResource || !method_exists($resource, 'getRouteMatch'))
        )
            throw new \Exception('Invalid Resource Type, Can`t Check The Permissions.');

        $return = true;

        $matchedRouteName = $resource->getRouteMatch()->getMatchedRouteName();

        // Access Admin Route Need Authorized User
        if ($matchedRouteName == \yimaAdminor\Module::ADMIN_ROUTE_NAME)
            $return = $return && $role->hasAuthenticated();

        return $return;
    }
987161
public String checkAccess (Permission perm, Object context)
    {
        if (_permPolicy == null) {
            _permPolicy = createPermissionPolicy();
        }
        return _permPolicy.checkAccess(perm, context);
    }
746746
function canModifyStatus( $statusID, $user = false )
    {
        if ( $user === false )
            $user = eZUser::currentUser();
        else if ( is_numeric( $user ) )
            $user = eZUser::fetch( $user );

        if ( !is_object( $user ) )
        {
            eZDebug::writeError( "Cannot check status access without a user", __METHOD__ );
            return false;
        }

        $accessResult = $user->hasAccessTo( 'shop' , 'setstatus' );
        $accessWord = $accessResult['accessWord'];
        $access = false;

        $currentStatusID = $this->attribute( "status_id" );

        if ( $accessWord == 'yes' )
            $access = true;

        if ( $accessWord == 'limited' )
        {
            $limitationList = $accessResult['policies'];
            $access = true;
            foreach ( $limitationList as $pid => $limit )
            {
                $access = true;
                foreach ( $limit as $name => $value )
                {
                    if ( $name == 'FromStatus' )
                    {
                        if ( !in_array( $currentStatusID, $value )  )
                            $access = false;
                    }
                    if ( $name == 'ToStatus' )
                    {
                        if ( !in_array( $statusID, $value ) )
                            $access = false;
                    }
                    if ( !$access )
                        break;
                }
                if ( $access )
                    break;
            }
        }
        return $access;
    }
611517
public function equals($privilege)
    {
        if (is_scalar($privilege)) {
            $privilege = new self($privilege);
        } elseif (!$privilege instanceof self) {
            throw new \InvalidArgumentException('$privilege is expected to be of type string or Gobline\Acl\Privilege');
        }

        return $privilege->getName() === $this->name;
    }
874906
public function can($action, $method_code = null, $module_id = null) : bool {
		if (empty($this->controller_id)) return false;
		// module id
		if (empty($module_id)) {
			$module_id = $this->module_id;
			if (empty($module_id)) {
				Throw new \Exception('You must specify correct module #');
			}
		}
		// run permission
		return $this->canExtended($this->controller_id, $method_code ?? $this->method_code, $action, $module_id);
	}
21629
public function has_access_to_module($module_name)
    {
        switch ($module_name) {
            case 'admin':
                return (
                    ($this->has_right(self::BAS_MODIFY_STRUCT) ||
                    $this->has_right(self::COLL_MODIFY_STRUCT) ||
                    $this->has_right(self::BAS_MANAGE) ||
                    $this->has_right(self::COLL_MANAGE) ||
                    $this->has_right(self::CANADMIN) ||
                    $this->is_admin()) );
                break;
            case 'thesaurus':
                return ($this->has_right(self::BAS_MODIF_TH) === true );
                break;
            case 'upload':
                return ($this->has_right(self::CANADDRECORD) === true);
                break;
            case 'report':
                return ($this->has_right(self::CANREPORT) === true);
                break;
            default:
                break;
        }

        return true;
    }
287954
public function isEnabled($module)
	{
		$result = $this->byName($module);

		return (is_object($result) && $result->id);
	}
469182
public function isAllowed($role, $resource, $privilege): bool
    {
        // collect current acl
        $this->listCurrentAcl[$role . $resource . $privilege] = [
            'role'      => $role,
            'resource'  => $resource,
            'privilege' => $privilege,
        ];

        // for policy none
        if ($this->policy == self::POLICY_NONE) {
            return true;
        }

        // auto-fix missing resource in acl
        if ($resource && !isset($this->resource[$resource])) {
            $this->saveResource(['id' => null, 'resource' => $resource]);
        }
        return $this->permission->isAllowed($role, $resource, $privilege);
    }
496998
private function check_permissions() {
        $this->postcap = has_capability('moodle/comment:post', $this->context);
        $this->viewcap = has_capability('moodle/comment:view', $this->context);
        if (!empty($this->plugintype)) {
            $permissions = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'permissions', array($this->comment_param), array('post'=>false, 'view'=>false));
            $this->postcap = $this->postcap && $permissions['post'];
            $this->viewcap = $this->viewcap && $permissions['view'];
        }
    }
259147
public function isModuleCurrent(string $module): bool
	{
		return strpos($this->getAction(true), $module) !== false;
	}
420780
public function hasAccess($accessLevel)
    {
        foreach ($this->permissions as $permission) {
            /**
             * If the user has the \Globa\* access level he can
             * do everything
             */
            if ($permission == '\\Global\\*') {
                return true;
            }
            
            if ($permission == $accessLevel) {
                return true;
            }
            
            // If there is a star in the permission and everything before 
            // the star is equal with the access level, the user has access
            // to the given access level.
            $posStar = strpos($permission, '*');
            if ($posStar !== false) {
                $startPermission = substr($permission, 0, $posStar);
                $startAccessLevel = substr($accessLevel, 0, $posStar);
                
                if ($startPermission == $startAccessLevel) {
                    return true;
                }
            } 
        }
    
        return false;
    }