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;
    }
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;
    }
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 ; }
Delete all publications

@param int $advertised search for advertised courses
@param int $shared search for shared courses
@throws moodle_exception
Delete all publications