public static function delete_all_publications($advertised = true, $shared = true) {
        global $DB;

        if (!$advertised && !$shared) {
            // Nothing to do.
            return true;
        }

        $params = ['huburl' => HUB_MOODLEORGHUBURL];
        if (!$advertised || !$shared) {
            // Retrieve ONLY advertised or ONLY shared.
            $params['enrollable'] = $advertised ? 1 : 0;
        }

        if (!$publications = $DB->get_records('course_published', $params)) {
            // Nothing to unpublish.
            return true;
        }

        foreach ($publications as $publication) {
            $hubcourseids[] = $publication->hubcourseid;
        }

        api::unregister_courses($hubcourseids);

        // Delete the published courses from local db.
        $DB->delete_records('course_published', $params);
        return true;
    }