protected function get_role_users_for_expired_context(expired_context $expiredctx, \context $context) : \stdClass {
        $expiredroles = $expiredctx->get('expiredroles');
        $expiredroleusers = [];
        if (!empty($expiredroles)) {
            // Find the list of expired role users.
            $expiredroleuserassignments = get_role_users($expiredroles, $context, true, 'ra.id, u.id AS userid', 'ra.id');
            $expiredroleusers = array_map(function($assignment) {
                return $assignment->userid;
            }, $expiredroleuserassignments);
        }
        $expiredroleusers = array_unique($expiredroleusers);

        $unexpiredroles = $expiredctx->get('unexpiredroles');
        $unexpiredroleusers = [];
        if (!empty($unexpiredroles)) {
            // Find the list of unexpired role users.
            $unexpiredroleuserassignments = get_role_users($unexpiredroles, $context, true, 'ra.id, u.id AS userid', 'ra.id');
            $unexpiredroleusers = array_map(function($assignment) {
                return $assignment->userid;
            }, $unexpiredroleuserassignments);
        }
        $unexpiredroleusers = array_unique($unexpiredroleusers);

        if (!$expiredctx->get('defaultexpired')) {
            $tofilter = get_users_roles($context, $expiredroleusers);
            $tofilter = array_filter($tofilter, function($userroles) use ($expiredroles) {
                // Each iteration contains the list of role assignment for a specific user.
                // All roles that the user holds must match those in the list of expired roles.
                foreach ($userroles as $ra) {
                    if (false === array_search($ra->roleid, $expiredroles)) {
                        // This role was not found in the list of assignments.
                        return true;
                    }
                }

                return false;
            });
            $unexpiredroleusers = array_merge($unexpiredroleusers, array_keys($tofilter));
        }

        return (object) [
            'expired' => $expiredroleusers,
            'unexpired' => $unexpiredroleusers,
        ];
    }
protected function get_role_users_for_expired_context(expired_context $expiredctx, \context $context) : \stdClass {
        $expiredroles = $expiredctx->get('expiredroles');
        $expiredroleusers = [];
        if (!empty($expiredroles)) {
            // Find the list of expired role users.
            $expiredroleuserassignments = get_role_users($expiredroles, $context, true, 'ra.id, u.id AS userid', 'ra.id');
            $expiredroleusers = array_map(function($assignment) {
                return $assignment->userid;
            }, $expiredroleuserassignments);
        }
        $expiredroleusers = array_unique($expiredroleusers);

        $unexpiredroles = $expiredctx->get('unexpiredroles');
        $unexpiredroleusers = [];
        if (!empty($unexpiredroles)) {
            // Find the list of unexpired role users.
            $unexpiredroleuserassignments = get_role_users($unexpiredroles, $context, true, 'ra.id, u.id AS userid', 'ra.id');
            $unexpiredroleusers = array_map(function($assignment) {
                return $assignment->userid;
            }, $unexpiredroleuserassignments);
        }
        $unexpiredroleusers = array_unique($unexpiredroleusers);

        if (!$expiredctx->get('defaultexpired')) {
            $tofilter = get_users_roles($context, $expiredroleusers);
            $tofilter = array_filter($tofilter, function($userroles) use ($expiredroles) {
                // Each iteration contains the list of role assignment for a specific user.
                // All roles that the user holds must match those in the list of expired roles.
                foreach ($userroles as $ra) {
                    if (false === array_search($ra->roleid, $expiredroles)) {
                        // This role was not found in the list of assignments.
                        return true;
                    }
                }

                return false;
            });
            $unexpiredroleusers = array_merge($unexpiredroleusers, array_keys($tofilter));
        }

        return (object) [
            'expired' => $expiredroleusers,
            'unexpired' => $unexpiredroleusers,
        ];
    }
protected function get_role_users_for_expired_context ( expired_context $ expiredctx , \ context $ context ) : \ stdClass { $ expiredroles = $ expiredctx -> get ( 'expiredroles' ) ; $ expiredroleusers = [ ] ; if ( ! empty ( $ expiredroles ) ) { // Find the list of expired role users. $ expiredroleuserassignments = get_role_users ( $ expiredroles , $ context , true , 'ra.id, u.id AS userid' , 'ra.id' ) ; $ expiredroleusers = array_map ( function ( $ assignment ) { return $ assignment -> userid ; } , $ expiredroleuserassignments ) ; } $ expiredroleusers = array_unique ( $ expiredroleusers ) ; $ unexpiredroles = $ expiredctx -> get ( 'unexpiredroles' ) ; $ unexpiredroleusers = [ ] ; if ( ! empty ( $ unexpiredroles ) ) { // Find the list of unexpired role users. $ unexpiredroleuserassignments = get_role_users ( $ unexpiredroles , $ context , true , 'ra.id, u.id AS userid' , 'ra.id' ) ; $ unexpiredroleusers = array_map ( function ( $ assignment ) { return $ assignment -> userid ; } , $ unexpiredroleuserassignments ) ; } $ unexpiredroleusers = array_unique ( $ unexpiredroleusers ) ; if ( ! $ expiredctx -> get ( 'defaultexpired' ) ) { $ tofilter = get_users_roles ( $ context , $ expiredroleusers ) ; $ tofilter = array_filter ( $ tofilter , function ( $ userroles ) use ( $ expiredroles ) { // Each iteration contains the list of role assignment for a specific user. // All roles that the user holds must match those in the list of expired roles. foreach ( $ userroles as $ ra ) { if ( false === array_search ( $ ra -> roleid , $ expiredroles ) ) { // This role was not found in the list of assignments. return true ; } } return false ; } ) ; $ unexpiredroleusers = array_merge ( $ unexpiredroleusers , array_keys ( $ tofilter ) ) ; } return ( object ) [ 'expired' => $ expiredroleusers , 'unexpired' => $ unexpiredroleusers , ] ; }
Get the list of actual users for the combination of expired, and unexpired roles.

@param   expired_context $expiredctx
@param   \context        $context
@return  \stdClass
Get the list of actual users for the combination of expired and unexpired roles .