Skip to content

Commit

Permalink
MDL-53492 registration: use https://moodle.net as hub url
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Jul 31, 2017
1 parent 505bbe7 commit 7d792ae
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion admin/registration/forms.php
Expand Up @@ -128,7 +128,7 @@ public function definition() {

//remove moodle.org from the hub list
foreach ($hubs as $key => $hub) {
if ($hub['url'] == HUB_MOODLEORGHUBURL) {
if ($hub['url'] == HUB_MOODLEORGHUBURL || $hub['url'] == HUB_OLDMOODLEORGHUBURL) {
unset($hubs[$key]);
}
}
Expand Down
7 changes: 7 additions & 0 deletions blocks/community/forms.php
Expand Up @@ -109,6 +109,13 @@ public function definition() {
$mform->addElement('static', 'errorhub', '', $error);
}

// Hubdirectory returns old URL for the moodle.net hub, substitute it.
foreach ($hubs as $key => $hub) {
if ($hub['url'] === HUB_OLDMOODLEORGHUBURL) {
$hubs[$key]['url'] = HUB_MOODLEORGHUBURL;
}
}

//display list of registered on hub
$registrationmanager = new registration_manager();
$registeredhubs = $registrationmanager->get_registered_on_hubs();
Expand Down
29 changes: 29 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -2214,5 +2214,34 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2017072000.02);
}

if ($oldversion < 2017072701.00) {

// If the site was previously registered with http://hub.moodle.org change the registration to
// point to https://moodle.net - this is the correct hub address using https protocol.
$oldhuburl = "http://hub.moodle.org";
$newhuburl = "https://moodle.net";
$cleanoldhuburl = preg_replace('/[^A-Za-z0-9_-]/i', '', $oldhuburl);
$cleannewhuburl = preg_replace('/[^A-Za-z0-9_-]/i', '', $newhuburl);

// Update existing registration.
$DB->execute("UPDATE {registration_hubs} SET hubname = ?, huburl = ? WHERE huburl = ?",
['Moodle.net', $newhuburl, $oldhuburl]);

// Update settings of existing registration.
$sqlnamelike = $DB->sql_like('name', '?');
$entries = $DB->get_records_sql("SELECT * FROM {config_plugins} where plugin=? and " . $sqlnamelike,
['hub', '%' . $DB->sql_like_escape('_' . $cleanoldhuburl)]);
foreach ($entries as $entry) {
$newname = substr($entry->name, 0, -strlen($cleanoldhuburl)) . $cleannewhuburl;
$DB->update_record('config_plugins', ['id' => $entry->id, 'name' => $newname]);
}

// Update published courses.
$DB->execute('UPDATE {course_published} SET huburl = ? WHERE huburl = ?', [$newhuburl, $oldhuburl]);

// Main savepoint reached.
upgrade_main_savepoint(true, 2017072701.00);
}

return true;
}
7 changes: 4 additions & 3 deletions lib/moodlelib.php
Expand Up @@ -488,13 +488,14 @@
/**
* Hub directory url (should be moodle.org)
*/
define('HUB_HUBDIRECTORYURL', "http://hubdirectory.moodle.org");
define('HUB_HUBDIRECTORYURL', "https://hubdirectory.moodle.org");


/**
* Moodle.org url (should be moodle.org)
* Moodle.net url (should be moodle.net)
*/
define('HUB_MOODLEORGHUBURL', "http://hub.moodle.org");
define('HUB_MOODLEORGHUBURL', "https://moodle.net");
define('HUB_OLDMOODLEORGHUBURL', "http://hub.moodle.org");

/**
* Moodle mobile app service name
Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2017072700.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2017072701.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit 7d792ae

Please sign in to comment.