public static function is_context_expired_or_unprotected_for_user(\context $context, \stdClass $user) : bool {
        // User/course contexts can't expire if no purpose is set in the system context.
        if (!data_registry::defaults_set()) {
            return false;
        }

        $parents = $context->get_parent_contexts(true);
        foreach ($parents as $parent) {
            if ($parent instanceof \context_course) {
                // This is a context within a course. Check whether _this context_ is expired as a function of a course.
                return self::is_course_context_expired_or_unprotected_for_user($context, $user);
            }

            if ($parent instanceof \context_user) {
                // This is a context within a user. Check whether the _user_ has expired.
                return self::are_user_context_dependencies_expired($parent);
            }
        }

        return false;
    }
public static function is_context_expired_or_unprotected_for_user(\context $context, \stdClass $user) : bool {
        // User/course contexts can't expire if no purpose is set in the system context.
        if (!data_registry::defaults_set()) {
            return false;
        }

        $parents = $context->get_parent_contexts(true);
        foreach ($parents as $parent) {
            if ($parent instanceof \context_course) {
                // This is a context within a course. Check whether _this context_ is expired as a function of a course.
                return self::is_course_context_expired_or_unprotected_for_user($context, $user);
            }

            if ($parent instanceof \context_user) {
                // This is a context within a user. Check whether the _user_ has expired.
                return self::are_user_context_dependencies_expired($parent);
            }
        }

        return false;
    }
public static function is_context_expired_or_unprotected_for_user ( \ context $ context , \ stdClass $ user ) : bool { // User/course contexts can't expire if no purpose is set in the system context. if ( ! data_registry :: defaults_set ( ) ) { return false ; } $ parents = $ context -> get_parent_contexts ( true ) ; foreach ( $ parents as $ parent ) { if ( $ parent instanceof \ context_course ) { // This is a context within a course. Check whether _this context_ is expired as a function of a course. return self :: is_course_context_expired_or_unprotected_for_user ( $ context , $ user ) ; } if ( $ parent instanceof \ context_user ) { // This is a context within a user. Check whether the _user_ has expired. return self :: are_user_context_dependencies_expired ( $ parent ) ; } } return false ; }
Determine whether the supplied context has expired or unprotected for the specified user.

@param   \context    $context
@param   \stdClass   $user
@return  bool
Determine whether the supplied context has expired or unprotected for the specified user .