public static function register($returnurl) {
        global $DB, $SESSION;

        if (self::is_registered()) {
            // Caller of this method must make sure that site is not registered.
            throw new \coding_exception('Site already registered');
        }

        $hub = self::get_registration(false);
        if (empty($hub)) {
            // Create a new record in 'registration_hubs'.
            $hub = new stdClass();
            $hub->token = get_site_identifier();
            $hub->secret = $hub->token;
            $hub->huburl = HUB_MOODLEORGHUBURL;
            $hub->hubname = 'Moodle.net';
            $hub->confirmed = 0;
            $hub->timemodified = time();
            $hub->id = $DB->insert_record('registration_hubs', $hub);
            self::$registration = null;
        }

        $params = self::get_site_info();
        $params['token'] = $hub->token;

        $SESSION->registrationredirect = $returnurl;
        redirect(new moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/siteregistration.php', $params));
    }
public static function register($returnurl) {
        global $DB, $SESSION;

        if (self::is_registered()) {
            // Caller of this method must make sure that site is not registered.
            throw new \coding_exception('Site already registered');
        }

        $hub = self::get_registration(false);
        if (empty($hub)) {
            // Create a new record in 'registration_hubs'.
            $hub = new stdClass();
            $hub->token = get_site_identifier();
            $hub->secret = $hub->token;
            $hub->huburl = HUB_MOODLEORGHUBURL;
            $hub->hubname = 'Moodle.net';
            $hub->confirmed = 0;
            $hub->timemodified = time();
            $hub->id = $DB->insert_record('registration_hubs', $hub);
            self::$registration = null;
        }

        $params = self::get_site_info();
        $params['token'] = $hub->token;

        $SESSION->registrationredirect = $returnurl;
        redirect(new moodle_url(HUB_MOODLEORGHUBURL . '/local/hub/siteregistration.php', $params));
    }
public static function register ( $ returnurl ) { global $ DB , $ SESSION ; if ( self :: is_registered ( ) ) { // Caller of this method must make sure that site is not registered. throw new \ coding_exception ( 'Site already registered' ) ; } $ hub = self :: get_registration ( false ) ; if ( empty ( $ hub ) ) { // Create a new record in 'registration_hubs'. $ hub = new stdClass ( ) ; $ hub -> token = get_site_identifier ( ) ; $ hub -> secret = $ hub -> token ; $ hub -> huburl = HUB_MOODLEORGHUBURL ; $ hub -> hubname = 'Moodle.net' ; $ hub -> confirmed = 0 ; $ hub -> timemodified = time ( ) ; $ hub -> id = $ DB -> insert_record ( 'registration_hubs' , $ hub ) ; self :: $ registration = null ; } $ params = self :: get_site_info ( ) ; $ params [ 'token' ] = $ hub -> token ; $ SESSION -> registrationredirect = $ returnurl ; redirect ( new moodle_url ( HUB_MOODLEORGHUBURL . '/local/hub/siteregistration.php' , $ params ) ) ; }
Registers a site

This method will make sure that unconfirmed registration record is created and then redirect to
registration script on https://moodle.net
Moodle.net will check that the site is accessible, register it and redirect back
to /admin/registration/confirmregistration.php

@param string $returnurl
@throws \coding_exception
Registers a site