Return true if Authenticated user role has the capability 'webservice/rest:use', otherwise false.

@return boolean
773656
private function is_protocol_cap_allowed() {
        global $DB, $CFG;

        // If the $this->restuse variable is not set, it needs to be set.
        if (empty($this->restuse) and $this->restuse!==false) {
            $params = array();
            $params['permission'] = CAP_ALLOW;
            $params['roleid'] = $CFG->defaultuserroleid;
            $params['capability'] = 'webservice/rest:use';
            $this->restuse = $DB->record_exists('role_capabilities', $params);
        }

        return $this->restuse;
    }
1089947
public function checkRegistryRequestsAnswers()
    {
        if (! (($this->db instanceof \Zend_Db_Adapter_Abstract) && ($this->session instanceof \Zend_Session_Namespace))) {
            return false;
        }

        // Checks if this is the current user
        if (! $this->_vars instanceof \Zend_Session_Namespace) {
            $sessionStore = $this->session;

            $notCurrent = true;
            foreach (array('user_id', 'user_organization_id') as $key) {
                if ($sessionStore->__isset($key) && $this->_vars->offsetExists($key)) {
                    $notCurrent = $sessionStore->__get($key) != $this->_vars->offsetGet($key);
                } else {
                    $notCurrent = $sessionStore->__isset($key) || $this->_vars->offsetExists($key);
                }

                if ($notCurrent) {
                    break;
                }
            }
            if (! $notCurrent) {
                // When this is the case, use the \Zend_Session_Namespace object with the current set values
                // This way changes to this user object are reflected in the CurrentUser object and vice versa.
                $this->setAsCurrentUser();
            }
        }

        // Change a numeric role id to it's string value
        $this->_getRole('user_role');
        if ($this->_hasVar('current_user_role')) {
            $this->_getRole('current_user_role');
        }

        return (boolean) $this->acl && $this->userLoader;
    }
1288860
public function check_capabilities() {
		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
			return false;
		}

		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
			return false;
		}

		return true;
	}
1309949
public function is($roles)
	{
		if (!$this->user())
		{
			return false;
		}

		$userRoles = $this->getUser()->roles;

		foreach ((array)$roles as $role)
		{
			if (in_array(mb_strtolower($role), $userRoles)
				|| in_array($role, $userRoles)
			)
			{
				return true;
			}
		}

		return false;
	}
635235
public boolean isUserInRole(String role)
    {
        if (WCCustomProperties.CHECK_REQUEST_OBJECT_IN_USE){
            checkRequestObjectInUse();
        }
        boolean userInRole;

        IWebAppSecurityCollaborator webAppSec = CollaboratorHelperImpl.getCurrentSecurityCollaborator();
        if (webAppSec != null) {
            userInRole = webAppSec.isUserInRole(role, this);
        } else {
            // No IWebAppSecurityCollaborator means no security, so not authenticated 
            userInRole = false;
        }

        if (TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
            logger.logp(Level.FINE, CLASS_NAME,"isUserInRole", " role --> " + role + " result --> " + String.valueOf(userInRole));
        }
        return userInRole;
    }
822173
public boolean isUserInRole(String role) {
        if (!isEnabled()) {
            throw new IllegalStateException("security module is disabled");
        }
        checkInit();
        SecurityProvider securityProvider = context.getSecurityProvider();
        boolean contained = role == ALL_ROLE || securityProvider.isUserInRole(role);
        LOGGER.debug("isUserInRole returns {} for role {}", contained, role);
        return contained;
    }
1225827
public function isAuthenticated()
    {
        try {
            $session = $this->sessionStorage->retrieveAccessToken($this->getServiceName());
            if (!$session) {
                return false;
            }
            return $session->getEndOfLife() > time();
        } catch (TokenNotFoundException $e) {
            return false;
        }
    }
1055342
public function isUsage()
    {
        $options = array('help', 'usage', 'option.h');
        foreach ($options as $option) {
            if ($this->request->get($option)) return true;
        }
        return false;
    }
796313
public boolean hasPermission(Authentication authentication,
                                 Object privilege) {
        return checkRole(authentication, privilege, true)
            || checkPermission(authentication, null, privilege, false, true);
    }
615219
public function checkAccess($user_id, $roles)
    {
        if ($this->isRoot($user_id)) {
            return true;
        }
        if (is_array($roles)) {
            return $this->hasRoles($user_id, $roles);
        } elseif (strpos($roles, '|') !== false) {
            return $this->hasAnyRole($user_id, explode('|', $roles));
        } else {
            return $this->hasRoles($user_id, explode('&', $roles));
        }
    }
825337
@Override
	public boolean isUserInRole(String role) {
		boolean inRole = false;

		Authentication authentication = getAuthentication();
		if (authentication != null) {
			Collection<? extends GrantedAuthority> authorities = authentication
					.getAuthorities();
			for (GrantedAuthority authority : authorities) {
				if (role.equals(authority.getAuthority())) {
					inRole = true;
					break;
				}
			}
		}
		return inRole;
	}
865262
public function isLoggedIn()
    {
        $roleModel = new \erdiko\users\models\Role;
        $roleGeneral = $roleModel->findByName('user');

		// @todo update exception message for clarity
        if (empty($roleGeneral)){
            throw  new \Exception('Error, role user not found.');
        }

		return ( ( $this->_user->getId() > 0 ) && ( $this->_user->getRole() !== $roleGeneral->getId() ) );
	}
1109091
public function getIsNgRestContext()
    {
        if ($this->scenario == RestActiveController::SCENARIO_RESTCREATE
            || $this->scenario == RestActiveController::SCENARIO_RESTUPDATE
            || $this->getNgRestCallType()) {
            return true;
        }
        
        return false;
    }
273374
private function hasRole()
    {
        return isset($this->config['role'])
            && \is_string($this->config['role'])
            && 0 === strpos($this->config['role'], 'ROLE_');
    }
560704
@Override
    public boolean isGranted(String resourceName, Collection<String> requiredRoles,
                             Collection<String> assignedRoles, Subject subject) {

        /*
         * New for Servlet 3.1 "**" means all authenticated users. The subject
         * is checked prior to isGranted() being called. So return true if the
         * subject is not null and if "**" is a required role.
         * 
         * If "_starstar_" is passed in that means a user had defined a role called
         * "**". We need to convert "_starstar_" back to "**" before the check
         * against assignedRoles.
         */
        if (subject != null && requiredRoles.contains(ALL_AUTHENTICATED_ROLE) && isEEVersionAtLeast7())
            return true;

        if (assignedRoles != null) {

            Iterator<String> iter = requiredRoles.iterator();
            while (iter.hasNext()) {
                String r = iter.next();
                if (r.equals(STARSTAR_ROLE))
                    r = "**";
                if (assignedRoles.contains(r)) {
                    return true;
                }
            }
        }
        return false;
    }
667762
public function userHasRole(string $role): bool
    {
        $user = $this->getUser();
        
        if($user->hasRole($role))
            return true;
        
        if (null === $userRoles = $user->getRoles())
            return false;
        
        foreach ($userRoles as $userRole) {
            try {
                if(\in_array($role, $this->getRoles($userRole)))
                    return true;                
            } catch (UndefinedRoleException $e) {
                continue;
            }
        }
        
        return false;
    }
505374
public function user_can( $capability = null ) {
		if ( ! isset( $capability ) ) {
			$capability = $this->app->get_config( 'capability', 'default_user', 'manage_options' );
		}
		if ( false === $capability ) {
			return true;
		}
		if ( '' === $capability ) {
			return false;
		}

		return $this->has_cap( $capability ) || in_array( $capability, $this->user_roles );
	}