public static function get_effective_default_contextlevel_purpose_and_category($contextlevel, $forcedpurposevalue = false,
                                                                                   $forcedcategoryvalue = false, $component = '') {
        // Get the defaults for this context level.
        list($purposeid, $categoryid) = self::get_defaults($contextlevel, $component);

        // Honour forced values.
        if ($forcedpurposevalue) {
            $purposeid = $forcedpurposevalue;
        }
        if ($forcedcategoryvalue) {
            $categoryid = $forcedcategoryvalue;
        }

        if ($contextlevel == CONTEXT_USER) {
            // Only user context levels inherit from a parent context level.
            list($parentpurposeid, $parentcategoryid) = self::get_defaults(CONTEXT_SYSTEM);

            if (context_instance::INHERIT == $purposeid || context_instance::NOTSET == $purposeid) {
                $purposeid = (int)$parentpurposeid;
            }

            if (context_instance::INHERIT == $categoryid || context_instance::NOTSET == $categoryid) {
                $categoryid = $parentcategoryid;
            }
        }

        return [$purposeid, $categoryid];
    }