From ef467fff042848a44624eeac2476e50c1a6fe47a Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Tue, 12 Sep 2017 15:20:03 +0800 Subject: [PATCH] MDL-59495 registration: register site on moodle.net only Remove support for alternative hubs --- admin/index.php | 2 +- admin/registration/confirmregistration.php | 49 ++-- admin/registration/forms.php | 2 +- admin/registration/index.php | 319 +++++++-------------- admin/registration/{forms.php => register.php} | 10 +- admin/registration/renderer.php | 46 --- .../{forms.php => renewregistration.php} | 36 ++- admin/renderer.php | 8 +- admin/settings/server.php | 3 - admin/settings/top.php | 9 +- lib/classes/task/registration_cron_task.php | 6 +- lib/db/upgrade.php | 20 ++ version.php | 2 +- 13 files changed, 193 insertions(+), 319 deletions(-) rewrite admin/registration/index.php (85%) copy admin/registration/{forms.php => register.php} (84%) copy admin/registration/{forms.php => renewregistration.php} (59%) diff --git a/admin/index.php b/admin/index.php index ba80a968322..88a7d4cd99a 100644 --- a/admin/index.php +++ b/admin/index.php @@ -857,7 +857,7 @@ if ($updateschecker->enabled()) { $buggyiconvnomb = (!function_exists('mb_convert_encoding') and @iconv('UTF-8', 'UTF-8//IGNORE', '100'.chr(130).'€') !== '100€'); //check if the site is registered on Moodle.org -$registered = $DB->count_records('registration_hubs', array('huburl' => HUB_MOODLEORGHUBURL, 'confirmed' => 1)); +$registered = \core\hub\registration::is_registered(); // Check if there are any cache warnings. $cachewarnings = cache_helper::warnings(); // Check if there are events 1 API handlers. diff --git a/admin/registration/confirmregistration.php b/admin/registration/confirmregistration.php index 77b2fb23983..7fe7689e90c 100644 --- a/admin/registration/confirmregistration.php +++ b/admin/registration/confirmregistration.php @@ -20,7 +20,7 @@ // // /////////////////////////////////////////////////////////////////////////// -/* +/** * @package moodle * @subpackage registration * @author Jerome Mouneyrac @@ -36,7 +36,6 @@ require('../../config.php'); require_once($CFG->libdir . '/adminlib.php'); -require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php'); $newtoken = optional_param('newtoken', '', PARAM_ALPHANUM); $url = optional_param('url', '', PARAM_URL); @@ -44,7 +43,11 @@ $hubname = optional_param('hubname', '', PARAM_TEXT); $token = optional_param('token', '', PARAM_TEXT); $error = optional_param('error', '', PARAM_ALPHANUM); -admin_externalpage_setup('registrationhubs'); +admin_externalpage_setup('registrationmoodleorg'); + +if ($url !== HUB_MOODLEORGHUBURL) { + throw new moodle_exception('errorotherhubsnotsupported', 'hub'); +} if (!empty($error) and $error == 'urlalreadyexist') { throw new moodle_exception('urlalreadyregistered', 'hub', @@ -52,38 +55,20 @@ if (!empty($error) and $error == 'urlalreadyexist') { } //check that we are waiting a confirmation from this hub, and check that the token is correct -$registrationmanager = new registration_manager(); -$registeredhub = $registrationmanager->get_unconfirmedhub($url); -if (!empty($registeredhub) and $registeredhub->token == $token) { - - echo $OUTPUT->header(); - echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main'); +core\hub\registration::confirm_registration($token, $newtoken, $hubname); - $registeredhub->token = $newtoken; - $registeredhub->confirmed = 1; - $registeredhub->hubname = $hubname; - $registrationmanager->update_registeredhub($registeredhub); +echo $OUTPUT->header(); +echo $OUTPUT->heading(get_string('registrationconfirmed', 'hub'), 3, 'main'); - // Display notification message. - echo $OUTPUT->notification(get_string('registrationconfirmedon', 'hub'), 'notifysuccess'); +// Display notification message. +echo $OUTPUT->notification(get_string('registrationconfirmedon', 'hub'), 'notifysuccess'); - //display continue button - $registrationpage = new moodle_url('/admin/registration/index.php'); - $continuebutton = $OUTPUT->render(new single_button($registrationpage, get_string('continue', 'hub'))); - $continuebutton = html_writer::tag('div', $continuebutton, array('class' => 'mdl-align')); - echo $continuebutton; +// Display continue button. +$registrationpage = new moodle_url('/admin/registration/index.php'); +$continuebutton = $OUTPUT->render(new single_button($registrationpage, get_string('continue'))); +$continuebutton = html_writer::tag('div', $continuebutton, array('class' => 'mdl-align')); +echo $continuebutton; - if (!extension_loaded('xmlrpc')) { - //display notice about xmlrpc - $xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', ''); - $xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub'); - echo $OUTPUT->notification($xmlrpcnotification); - } - - echo $OUTPUT->footer(); -} else { - throw new moodle_exception('wrongtoken', 'hub', - $CFG->wwwroot . '/' . $CFG->admin . '/registration/index.php'); -} +echo $OUTPUT->footer(); diff --git a/admin/registration/forms.php b/admin/registration/forms.php index f68536424fb..6fe95536333 100644 --- a/admin/registration/forms.php +++ b/admin/registration/forms.php @@ -33,4 +33,4 @@ defined('MOODLE_INTERNAL') || die(); debugging('Support for alternative hubs has been removed from Moodle in 3.4. For communication with moodle.net ' . - 'see lib/classes/moodlenet/ .', DEBUG_DEVELOPER); + 'see lib/classes/hub/ .', DEBUG_DEVELOPER); diff --git a/admin/registration/index.php b/admin/registration/index.php dissimilarity index 85% index b9aeb18f8d7..0adb27ba71d 100644 --- a/admin/registration/index.php +++ b/admin/registration/index.php @@ -1,208 +1,111 @@ -. - -/* - * @package moodle - * @subpackage registration - * @author Jerome Mouneyrac - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL - * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com - * - * On this page the administrator selects which hub he wants to register (except for moodle.net) - * Admins can register with moodle.net via the site admin menu "Registration" link. - * On this page the administrator can also unregister from any hubs including moodle.net. - */ - -require('../../config.php'); - -require_once($CFG->libdir . '/adminlib.php'); -require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php'); -require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/forms.php'); -require_once($CFG->dirroot . '/course/publish/lib.php'); -require_once($CFG->dirroot . "/webservice/xmlrpc/lib.php"); - -admin_externalpage_setup('registrationhubs'); - -$renderer = $PAGE->get_renderer('core', 'register'); - -$unregistration = optional_param('unregistration', 0, PARAM_INT); -$cleanregdata = optional_param('cleanregdata', 0, PARAM_BOOL); -$confirm = optional_param('confirm', 0, PARAM_INT); -$huburl = optional_param('huburl', '', PARAM_URL); -$cancel = optional_param('cancel', null, PARAM_ALPHA); - -$registrationmanager = new registration_manager(); -$publicationmanager = new course_publish_manager(); -$errormessage = ''; -if (empty($cancel) and $unregistration and $confirm and confirm_sesskey()) { - - $hub = $registrationmanager->get_registeredhub($huburl); - - //unpublish course and unregister the site by web service - if (!$cleanregdata) { - - //check if we need to unpublish courses - //enrollable courses - $unpublishalladvertisedcourses = optional_param('unpublishalladvertisedcourses', 0, PARAM_INT); - $hubcourseids = array(); - if ($unpublishalladvertisedcourses) { - $enrollablecourses = $publicationmanager->get_publications($huburl, null, 1); - if (!empty($enrollablecourses)) { - foreach ($enrollablecourses as $enrollablecourse) { - $hubcourseids[] = $enrollablecourse->hubcourseid; - } - } - } - //downloadable courses - $unpublishalluploadedcourses = optional_param('unpublishalluploadedcourses', 0, PARAM_INT); - if ($unpublishalluploadedcourses) { - $downloadablecourses = $publicationmanager->get_publications($huburl, null, 0); - if (!empty($downloadablecourses)) { - foreach ($downloadablecourses as $downloadablecourse) { - $hubcourseids[] = $downloadablecourse->hubcourseid; - } - } - } - - //unpublish the courses by web service - if (!empty($hubcourseids)) { - $function = 'hub_unregister_courses'; - $params = array('courseids' => $hubcourseids); - $serverurl = $huburl . "/local/hub/webservice/webservices.php"; - $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token); - try { - $result = $xmlrpcclient->call($function, $params); - //delete the published courses - if (!empty($enrollablecourses)) { - $publicationmanager->delete_hub_publications($huburl, 1); - } - if (!empty($downloadablecourses)) { - $publicationmanager->delete_hub_publications($huburl, 0); - } - } catch (Exception $e) { - $errormessage = $e->getMessage(); - $errormessage .= html_writer::empty_tag('br') . - get_string('errorunpublishcourses', 'hub'); - $confirm = false; - $cleanregdata = 1; - } - } - } - - //course unpublish went ok, unregister the site now - if ($confirm) { - $function = 'hub_unregister_site'; - $params = array(); - $serverurl = $huburl . "/local/hub/webservice/webservices.php"; - $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token); - try { - $result = $xmlrpcclient->call($function, $params); - } catch (Exception $e) { - if (!$cleanregdata) { - $errormessage = $e->getMessage(); - $confirm = false; - $cleanregdata = 1; - } - } - } - - //check that we are still processing the unregistration, - //it could have been unset if an exception were previsouly catched - if ($confirm) { - $registrationmanager->delete_registeredhub($huburl); - } -} - -if (empty($cancel) and $unregistration and !$confirm) { - - echo $OUTPUT->header(); - - //do not check sesskey if confirm = false because this script is linked into email message - if (!empty($errormessage)) { - echo $OUTPUT->notification(get_string('unregistrationerror', 'hub', $errormessage)); - } - - $hub = $registrationmanager->get_registeredhub($huburl); - echo $OUTPUT->heading(get_string('unregisterfrom', 'hub', $hub->hubname), 3, 'main'); - if ($cleanregdata) { - $siteunregistrationform = new site_clean_registration_data_form('', - array('huburl' => $huburl, 'hubname' => $hub->hubname)); - } else { - $siteunregistrationform = new site_unregistration_form('', - array('huburl' => $huburl, 'hubname' => $hub->hubname)); - } - - $siteunregistrationform->display(); -} else { - $registeredonmoodleorg = false; - $moodleorghub = $registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL); - if (!empty($moodleorghub)) { - $registeredonmoodleorg = true; - } - - // load the hub selector form - $hubselectorform = new hub_selector_form(); - $fromform = $hubselectorform->get_data(); - $selectedhuburl = optional_param('publichub', false, PARAM_URL); - $unlistedhuburl = optional_param('unlistedurl', false, PARAM_TEXT); - $password = optional_param('password', '', PARAM_RAW); - $registeringhuburl = null; - if (!empty($unlistedhuburl)) { - if (clean_param($unlistedhuburl, PARAM_URL) !== '') { - $registeringhuburl = $unlistedhuburl; - } - } else if (!empty($selectedhuburl)) { - $registeringhuburl = $selectedhuburl; - } - - // a hub has been selected, redirect to the hub registration page - if (empty($cancel) and !empty($registeringhuburl) and confirm_sesskey()) { - $hubname = optional_param(clean_param($registeringhuburl, PARAM_ALPHANUMEXT), '', PARAM_TEXT); - $params = array('sesskey' => sesskey(), 'huburl' => $registeringhuburl, - 'password' => $password, 'hubname' => $hubname); - redirect(new moodle_url($CFG->wwwroot . "/" . $CFG->admin . "/registration/register.php", - $params)); - } - - echo $OUTPUT->header(); - - //check if the site is registered on Moodle.org and display a message about registering on MOOCH - $adminrenderer = $PAGE->get_renderer('core', 'admin'); - echo $adminrenderer->warn_if_not_registered(); - - //do not check sesskey if confirm = false because this script is linked into email message - if (!empty($errormessage)) { - echo $OUTPUT->notification(get_string('unregistrationerror', 'hub', $errormessage)); - } - - echo $OUTPUT->heading(get_string('registerwith', 'hub')); - - $hubselectorform->display(); - - if (extension_loaded('xmlrpc')) { - $hubs = $registrationmanager->get_registered_on_hubs(); - if (!empty($hubs)) { - echo $OUTPUT->heading(get_string('registeredon', 'hub'), 3, 'main'); - echo $renderer->registeredonhublisting($hubs); - } - } else { //display notice about xmlrpc - $xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', ''); - $xmlrpcnotification .= get_string('xmlrpcdisabledregistration', 'hub'); - echo $OUTPUT->notification($xmlrpcnotification); - } -} -echo $OUTPUT->footer(); +. + +/** + * @package moodle + * @subpackage registration + * @author Jerome Mouneyrac + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL + * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com + * + * This page displays the site registration form for Moodle.net. + * It handles redirection to the hub to continue the registration workflow process. + * It also handles update operation by web service. + */ + +require_once('../../config.php'); +require_once($CFG->libdir . '/adminlib.php'); + +admin_externalpage_setup('registrationmoodleorg'); + +$unregistration = optional_param('unregistration', 0, PARAM_INT); + +if ($unregistration && \core\hub\registration::is_registered()) { + $siteunregistrationform = new \core\hub\site_unregistration_form(); + + if ($siteunregistrationform->is_cancelled()) { + redirect(new moodle_url('/admin/registration/index.php')); + } else if ($data = $siteunregistrationform->get_data()) { + if (\core\hub\registration::unregister($data->unpublishalladvertisedcourses, + $data->unpublishalluploadedcourses)) { + redirect(new moodle_url('/admin/registration/index.php')); + } + } + + echo $OUTPUT->header(); + echo $OUTPUT->heading(get_string('unregisterfrom', 'hub', 'Moodle.net'), 3, 'main'); + $siteunregistrationform->display(); + echo $OUTPUT->footer(); + exit; +} + +$siteregistrationform = new \core\hub\site_registration_form(); +if ($fromform = $siteregistrationform->get_data()) { + + // Save the settings. + \core\hub\registration::save_site_info($fromform); + + if (\core\hub\registration::is_registered()) { + \core\hub\registration::update_manual(); + redirect(new moodle_url('/admin/registration/index.php')); + } else { + \core\hub\registration::register(); + // This method will redirect away. + } + +} + +// OUTPUT SECTION. + +echo $OUTPUT->header(); + +// Current status of registration on Moodle.net. + +$notificationtype = \core\output\notification::NOTIFY_ERROR; +if (\core\hub\registration::is_registered()) { + $lastupdated = \core\hub\registration::get_last_updated(); + if ($lastupdated == 0) { + $registrationmessage = get_string('pleaserefreshregistrationunknown', 'admin'); + } else { + $lastupdated = userdate($lastupdated, get_string('strftimedate', 'langconfig')); + $registrationmessage = get_string('pleaserefreshregistration', 'admin', $lastupdated); + $notificationtype = \core\output\notification::NOTIFY_INFO; + } + echo $OUTPUT->notification($registrationmessage, $notificationtype); +} else { + $registrationmessage = get_string('registrationwarning', 'admin'); + echo $OUTPUT->notification($registrationmessage, $notificationtype); +} + +// Heading. +if (\core\hub\registration::is_registered()) { + echo $OUTPUT->heading(get_string('updatesite', 'hub', 'Moodle.net')); +} else { + echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin')); +} + +$renderer = $PAGE->get_renderer('core', 'register'); +echo $renderer->moodleorg_registration_message(); + +$siteregistrationform->display(); + +if (\core\hub\registration::is_registered()) { + // Unregister link. + $unregisterhuburl = new moodle_url("/admin/registration/index.php", ['unregistration' => 1]); + echo html_writer::div(html_writer::link($unregisterhuburl, get_string('unregister', 'hub')), 'unregister'); +} +echo $OUTPUT->footer(); diff --git a/admin/registration/forms.php b/admin/registration/register.php similarity index 84% copy from admin/registration/forms.php copy to admin/registration/register.php index f68536424fb..ee2d534bdd0 100644 --- a/admin/registration/forms.php +++ b/admin/registration/register.php @@ -27,10 +27,12 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com * - * The forms needed by registration pages. + * This page displays the site registration form for Moodle.org/MOOCH or for a different hub. + * It handles redirection to the hub to continue the registration workflow process. + * It also handles update operation by web service. */ -defined('MOODLE_INTERNAL') || die(); -debugging('Support for alternative hubs has been removed from Moodle in 3.4. For communication with moodle.net ' . - 'see lib/classes/moodlenet/ .', DEBUG_DEVELOPER); +require_once('../../config.php'); + +redirect(new moodle_url('/admin/registration/index.php')); \ No newline at end of file diff --git a/admin/registration/renderer.php b/admin/registration/renderer.php index 09d2735866a..196d680e140 100644 --- a/admin/registration/renderer.php +++ b/admin/registration/renderer.php @@ -46,50 +46,4 @@ class core_register_renderer extends plugin_renderer_base { $moodleorgregmsg .= html_writer::alist($items); return $moodleorgregmsg; } - - /** - * Display a box message confirming a site registration (add or update) - * @param string $confirmationmessage - * @return string - */ - public function registration_confirmation($confirmationmessage) { - $linktositelist = html_writer::tag('a', get_string('sitelist', 'hub'), - array('href' => new moodle_url('/local/hub/index.php'))); - $message = $confirmationmessage . html_writer::empty_tag('br') . $linktositelist; - return $this->output->box($message); - } - - /** - * Display the listing of registered on hub - */ - public function registeredonhublisting($hubs) { - global $CFG; - $table = new html_table(); - $table->head = array(get_string('hub', 'hub'), get_string('operation', 'hub')); - $table->size = array('80%', '20%'); - - foreach ($hubs as $hub) { - if ($hub->huburl == HUB_MOODLEORGHUBURL) { - $hub->hubname = get_string('registeredmoodleorg', 'hub', $hub->hubname); - } - $hublink = html_writer::tag('a', $hub->hubname, array('href' => $hub->huburl)); - $hublinkcell = html_writer::tag('div', $hublink, array('class' => 'registeredhubrow')); - - $unregisterhuburl = new moodle_url("/" . $CFG->admin . "/registration/index.php", - array('sesskey' => sesskey(), 'huburl' => $hub->huburl, - 'unregistration' => 1)); - $unregisterbutton = new single_button($unregisterhuburl, - get_string('unregister', 'hub')); - $unregisterbutton->class = 'centeredbutton'; - $unregisterbuttonhtml = $this->output->render($unregisterbutton); - - //add button cells - $cells = array($hublinkcell, $unregisterbuttonhtml); - $row = new html_table_row($cells); - $table->data[] = $row; - } - - return html_writer::table($table); - } - } diff --git a/admin/registration/forms.php b/admin/registration/renewregistration.php similarity index 59% copy from admin/registration/forms.php copy to admin/registration/renewregistration.php index f68536424fb..7926e0fc85f 100644 --- a/admin/registration/forms.php +++ b/admin/registration/renewregistration.php @@ -27,10 +27,38 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com * - * The forms needed by registration pages. + * The administrator is redirect to this page from the hub to renew a registration + * process because */ -defined('MOODLE_INTERNAL') || die(); +require('../../config.php'); +require_once($CFG->libdir . '/adminlib.php'); + +$url = optional_param('url', '', PARAM_URL); +$token = optional_param('token', '', PARAM_TEXT); + +admin_externalpage_setup('registrationmoodleorg'); + +if ($url !== HUB_MOODLEORGHUBURL) { + throw new moodle_exception('errorotherhubsnotsupported', 'hub'); +} + +// Check that we are waiting a confirmation from this hub, and check that the token is correct. +\core\hub\registration::reset_site_identifier($token); + +echo $OUTPUT->header(); +echo $OUTPUT->heading(get_string('renewregistration', 'hub'), 3, 'main'); +$hublink = html_writer::tag('a', 'Moodle.net', array('href' => HUB_MOODLEORGHUBURL)); + +$deletedregmsg = get_string('previousregistrationdeleted', 'hub', $hublink); + +$button = new single_button(new moodle_url('/admin/registration/index.php'), + get_string('restartregistration', 'hub')); +$button->class = 'restartregbutton'; + +echo html_writer::tag('div', $deletedregmsg . $OUTPUT->render($button), + array('class' => 'mdl-align')); + +echo $OUTPUT->footer(); + -debugging('Support for alternative hubs has been removed from Moodle in 3.4. For communication with moodle.net ' . - 'see lib/classes/moodlenet/ .', DEBUG_DEVELOPER); diff --git a/admin/renderer.php b/admin/renderer.php index 561b24a22b1..7dd48081979 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -805,8 +805,7 @@ class core_admin_renderer extends plugin_renderer_base { if (!$registered) { if (has_capability('moodle/site:config', context_system::instance())) { - $registerbutton = $this->single_button(new moodle_url('/admin/registration/register.php', - array('huburl' => HUB_MOODLEORGHUBURL, 'hubname' => 'Moodle.net')), + $registerbutton = $this->single_button(new moodle_url('/admin/registration/index.php'), get_string('register', 'admin')); $str = 'registrationwarning'; } else { @@ -828,10 +827,7 @@ class core_admin_renderer extends plugin_renderer_base { * @return string */ public function warn_if_not_registered() { - global $CFG; - require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php'); - $registrationmanager = new registration_manager(); - return $this->registration_warning($registrationmanager->get_registeredhub(HUB_MOODLEORGHUBURL) ? true : false); + return $this->registration_warning(\core\hub\registration::is_registered()); } /** diff --git a/admin/settings/server.php b/admin/settings/server.php index e84707740f6..c0d57c3fcd7 100644 --- a/admin/settings/server.php +++ b/admin/settings/server.php @@ -211,9 +211,6 @@ $temp->add(new admin_setting_configtext('curltimeoutkbitrate', new lang_string(' $ADMIN->add('server', $temp); -$ADMIN->add('server', new admin_externalpage('adminregistration', new lang_string('hubs', 'admin'), - "$CFG->wwwroot/$CFG->admin/registration/index.php")); - // E-mail settings. $ADMIN->add('server', new admin_category('email', new lang_string('categoryemail', 'admin'))); diff --git a/admin/settings/top.php b/admin/settings/top.php index be45ef66acc..17621cbd671 100644 --- a/admin/settings/top.php +++ b/admin/settings/top.php @@ -11,14 +11,7 @@ $hassiteconfig = has_capability('moodle/site:config', $systemcontext); $ADMIN->add('root', new admin_externalpage('adminnotifications', new lang_string('notifications'), "$CFG->wwwroot/$CFG->admin/index.php")); $ADMIN->add('root', new admin_externalpage('registrationmoodleorg', new lang_string('registration', 'admin'), - "$CFG->wwwroot/$CFG->admin/registration/register.php?huburl=" . HUB_MOODLEORGHUBURL . "&hubname=Moodle.net&sesskey=" . sesskey())); -$ADMIN->add('root', new admin_externalpage('registrationhub', new lang_string('registerwith', 'hub'), - "$CFG->wwwroot/$CFG->admin/registration/register.php", 'moodle/site:config', true)); -$ADMIN->add('root', new admin_externalpage('registrationhubs', new lang_string('hubs', 'admin'), - "$CFG->wwwroot/$CFG->admin/registration/index.php", 'moodle/site:config', true)); -$ADMIN->add('root', new admin_externalpage('siteregistrationconfirmed', - new lang_string('registrationconfirmed', 'hub'), - $CFG->wwwroot."/".$CFG->admin."/registration/confirmregistration.php", 'moodle/site:config', true)); + new moodle_url("/admin/registration/index.php"))); // hidden upgrade script $ADMIN->add('root', new admin_externalpage('upgradesettings', new lang_string('upgradesettings', 'admin'), "$CFG->wwwroot/$CFG->admin/upgradesettings.php", 'moodle/site:config', true)); diff --git a/lib/classes/task/registration_cron_task.php b/lib/classes/task/registration_cron_task.php index b8ed0099741..fbc64ae4c88 100644 --- a/lib/classes/task/registration_cron_task.php +++ b/lib/classes/task/registration_cron_task.php @@ -42,11 +42,7 @@ class registration_cron_task extends scheduled_task { * Throw exceptions on errors (the job will be retried). */ public function execute() { - global $CFG; - - require_once($CFG->dirroot . '/' . $CFG->admin . '/registration/lib.php'); - $registrationmanager = new \registration_manager(); - $registrationmanager->cron(); + \core\hub\registration::update_cron(); } } diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index df03600054a..fc1789c5c14 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2494,5 +2494,25 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2017091201.00); } + if ($oldversion < 2017092202.00) { + + // Rename several fields in registration data to match the names of the properties that are sent to moodle.net. + $renames = [ + 'site_address_httpsmoodlenet' => 'site_street_httpsmoodlenet', + 'site_region_httpsmoodlenet' => 'site_regioncode_httpsmoodlenet', + 'site_country_httpsmoodlenet' => 'site_countrycode_httpsmoodlenet']; + foreach ($renames as $oldparamname => $newparamname) { + try { + $DB->execute("UPDATE {config_plugins} SET name = ? WHERE name = ? AND plugin = ?", + [$newparamname, $oldparamname, 'hub']); + } catch (dml_exception $e) { + // Exception can happen if the config value with the new name already exists, ignore it and move on. + } + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2017092202.00); + } + return true; } diff --git a/version.php b/version.php index 0e612ededcf..e16ff8969f2 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2017092200.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2017092202.00; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. -- 2.11.4.GIT