Merge branch 'MDL-66118-master-byebyemoodlenet' of git://github.com/mudrd8mz/moodle

This commit is contained in:
Andrew Nicols 2019-10-09 07:43:33 +08:00
commit 13ef95e3de
22 changed files with 245 additions and 176 deletions

View File

@ -46,7 +46,7 @@ $error = optional_param('error', '', PARAM_ALPHANUM);
admin_externalpage_setup('registrationmoodleorg');
if ($url !== HUB_MOODLEORGHUBURL) {
// Allow other plugins to confirm registration on hubs other than moodle.net . Plugins implementing this
// Allow other plugins to confirm registration on custom hubs. Plugins implementing this
// callback need to redirect or exit. See https://docs.moodle.org/en/Hub_registration .
$callbacks = get_plugins_with_function('hub_registration');
foreach ($callbacks as $plugintype => $plugins) {

View File

@ -32,5 +32,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/hub/ .', DEBUG_DEVELOPER);
debugging('Support for alternative hubs has been removed from Moodle in 3.4.', DEBUG_DEVELOPER);

View File

@ -22,7 +22,7 @@
* @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.
* This page displays the site registration form.
* It handles redirection to the hub to continue the registration workflow process.
* It also handles update operation by web service.
*/
@ -32,24 +32,25 @@ require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('registrationmoodleorg');
$unregistration = optional_param('unregistration', 0, PARAM_INT);
$unregistration = optional_param('unregistration', false, PARAM_BOOL);
$confirm = optional_param('confirm', false, PARAM_BOOL);
if ($unregistration && \core\hub\registration::is_registered()) {
$siteunregistrationform = new \core\hub\site_unregistration_form();
if ($confirm) {
require_sesskey();
\core\hub\registration::unregister(false, false);
if ($siteunregistrationform->is_cancelled()) {
redirect(new moodle_url('/admin/registration/index.php'));
} else if ($data = $siteunregistrationform->get_data()) {
\core\hub\registration::unregister($data->unpublishalladvertisedcourses,
$data->unpublishalluploadedcourses);
if (!\core\hub\registration::is_registered()) {
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->confirm(
get_string('registerwithmoodleorgremove', 'core_hub'),
new moodle_url(new moodle_url('/admin/registration/index.php', ['unregistration' => 1, 'confirm' => 1])),
new moodle_url(new moodle_url('/admin/registration/index.php'))
);
echo $OUTPUT->footer();
exit;
}
@ -82,7 +83,7 @@ if ($fromform = $siteregistrationform->get_data()) {
echo $OUTPUT->header();
// Current status of registration on Moodle.net.
// Current status of registration.
$notificationtype = \core\output\notification::NOTIFY_ERROR;
if (\core\hub\registration::is_registered()) {
@ -104,11 +105,11 @@ if (\core\hub\registration::is_registered()) {
// Heading.
if (\core\hub\registration::is_registered()) {
echo $OUTPUT->heading(get_string('updatesite', 'hub', 'Moodle.net'));
echo $OUTPUT->heading(get_string('registerwithmoodleorgupdate', 'core_hub'));
} else if ($isinitialregistration) {
echo $OUTPUT->heading(get_string('completeregistration', 'hub'));
echo $OUTPUT->heading(get_string('registerwithmoodleorgcomplete', 'core_hub'));
} else {
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'admin'));
echo $OUTPUT->heading(get_string('registerwithmoodleorg', 'core_hub'));
}
$renderer = $PAGE->get_renderer('core', 'admin');
@ -119,8 +120,9 @@ $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 html_writer::div(html_writer::link($unregisterhuburl, get_string('unregister', 'hub')), 'unregister mt-2');
} else if ($isinitialregistration) {
echo html_writer::div(html_writer::link(new moodle_url($returnurl), get_string('skipregistration', 'hub')), 'skipregistration');
echo html_writer::div(html_writer::link(new moodle_url($returnurl), get_string('skipregistration', 'hub')),
'skipregistration mt-2');
}
echo $OUTPUT->footer();

View File

@ -40,7 +40,7 @@ $token = optional_param('token', '', PARAM_TEXT);
admin_externalpage_setup('registrationmoodleorg');
if ($url !== HUB_MOODLEORGHUBURL) {
// Allow other plugins to renew registration on hubs other than moodle.net . Plugins implementing this
// Allow other plugins to renew registration on custom hubs. Plugins implementing this
// callback need to redirect or exit. See https://docs.moodle.org/en/Hub_registration .
$callbacks = get_plugins_with_function('hub_registration');
foreach ($callbacks as $plugintype => $plugins) {
@ -56,7 +56,7 @@ if ($url !== HUB_MOODLEORGHUBURL) {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('renewregistration', 'hub'), 3, 'main');
$hublink = html_writer::tag('a', 'Moodle.net', array('href' => HUB_MOODLEORGHUBURL));
$hublink = html_writer::tag('a', HUB_MOODLEORGHUBURL, array('href' => HUB_MOODLEORGHUBURL));
$deletedregmsg = get_string('previousregistrationdeleted', 'hub', $hublink);

View File

@ -2112,6 +2112,27 @@ class core_admin_renderer extends plugin_renderer_base {
* @return string
*/
public function moodleorg_registration_message() {
return format_text(get_string('registermoodlenet', 'admin'), FORMAT_HTML, ['noclean' => true]);
$out = format_text(get_string('registerwithmoodleorginfo', 'core_hub'), FORMAT_MARKDOWN);
$out .= html_writer::link(
new moodle_url('/admin/settings.php', ['section' => 'moodleservices']),
$this->output->pix_icon('i/info', '').' '.get_string('registerwithmoodleorginfoapp', 'core_hub'),
['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
);
$out .= html_writer::link(
HUB_MOODLEORGHUBURL,
$this->output->pix_icon('i/stats', '').' '.get_string('registerwithmoodleorginfostats', 'core_hub'),
['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
);
$out .= html_writer::link(
HUB_MOODLEORGHUBURL.'/sites',
$this->output->pix_icon('i/location', '').' '.get_string('registerwithmoodleorginfosites', 'core_hub'),
['class' => 'btn btn-link', 'role' => 'opener', 'target' => '_href']
);
return $this->output->box($out);
}
}

View File

@ -75,7 +75,7 @@ class manage_competency_frameworks_page implements renderable, templatable {
);
$this->navigation[] = $addpage;
$competenciesrepository = new single_button(
new moodle_url('https://moodle.net/competencies'),
new moodle_url('https://archive.moodle.net/competencies'),
get_string('competencyframeworksrepository', 'tool_lp'),
'get'
);

View File

@ -266,7 +266,7 @@ class manager {
'title' => get_string('importtour', 'tool_usertours'),
],
(object) [
'link' => new \moodle_url('https://moodle.net/tours'),
'link' => new \moodle_url('https://archive.moodle.net/tours'),
'linkproperties' => [
'target' => '_blank',
],

View File

@ -91,18 +91,6 @@ if (get_home_page() != HOMEPAGE_SITE) {
// Trigger event.
course_view(context_course::instance(SITEID));
// If the hub plugin is installed then we let it take over the homepage here.
if (file_exists($CFG->dirroot.'/local/hub/lib.php') and get_config('local_hub', 'hubenabled')) {
require_once($CFG->dirroot.'/local/hub/lib.php');
$hub = new local_hub();
$continue = $hub->display_homepage();
// Function display_homepage() returns true if the hub home page is not displayed
// ...mostly when search form is not displayed for not logged users.
if (empty($continue)) {
exit;
}
}
$PAGE->set_pagetype('site-index');
$PAGE->set_docs_path('');
$editing = $PAGE->user_is_editing();

View File

@ -1013,11 +1013,6 @@ $string['quizattemptsupgradedmessage'] = 'In Moodle 2.1 there was a major upgrad
$string['recaptchaprivatekey'] = 'ReCAPTCHA secret key';
$string['recaptchapublickey'] = 'ReCAPTCHA site key';
$string['register'] = 'Register your site';
$string['registermoodlenet'] = '<p>We\'d love to stay in touch and provide you with important things for your Moodle site!</p><p>By registering:</p><ul><li>You can subscribe to receive notifications of new Moodle releases, security alerts and other important news.</li><li>You can access and activate mobile push notifications from your Moodle site through our free <a href="https://download.moodle.org/mobile/">Moodle app</a>.</li><li>You are contributing to our <a href="https://moodle.net/stats/">Moodle statistics</a> of the worldwide community, which help us improve Moodle and our community sites.</li><li>If you wish, your site can be included in the <a href="https://moodle.net/sites/">list of registered Moodle sites</a> in your country.</li></ul>';
$string['registermoodleorg'] = 'When you register your site';
$string['registermoodleorgli1'] = 'You are added to a low-volume mailing list for important notifications such as security alerts and new releases of Moodle.';
$string['registermoodleorgli2'] = 'Statistics about your site will be added to the {$a} of the worldwide Moodle community.';
$string['registerwithmoodleorg'] = 'Register your site';
$string['registration'] = 'Registration';
$string['registration_help'] = 'By registering:
@ -1434,3 +1429,8 @@ $string['allowblockstodock'] = 'Allow blocks to use the dock';
$string['configallowblockstodock'] = 'If enabled and supported by the selected theme users can choose to move blocks to a special dock.';
// Deprecated since Moodle 3.8.
$string['configuserquota'] = 'The maximum number of bytes that a user can store in their own private file area. {$a->bytes} bytes == {$a->displaysize}';
$string['registermoodlenet'] = '<p>We\'d love to stay in touch and provide you with important things for your Moodle site!</p><p>By registering:</p><ul><li>You can subscribe to receive notifications of new Moodle releases, security alerts and other important news.</li><li>You can access and activate mobile push notifications from your Moodle site through our free <a href="https://download.moodle.org/mobile/">Moodle app</a>.</li><li>You are contributing to our <a href="https://stats.moodle.org">Moodle statistics</a> of the worldwide community, which help us improve Moodle and our community sites.</li><li>If you wish, your site can be included in the <a href="https://stats.moodle.org/sites/">list of registered Moodle sites</a> in your country.</li></ul>';
$string['registermoodleorg'] = 'When you register your site';
$string['registermoodleorgli1'] = 'You are added to a low-volume mailing list for important notifications such as security alerts and new releases of Moodle.';
$string['registermoodleorgli2'] = 'Statistics about your site will be added to the {$a} of the worldwide Moodle community.';
$string['registerwithmoodleorg'] = 'Register your site';

View File

@ -106,3 +106,12 @@ unpublishalluploadedcourses,core_hub
unpublishconfirmation,core_hub
unpublishcourse,core_hub
updatestatus,core_hub
registermoodlenet,core_admin
registermoodleorg,core_admin
registermoodleorgli1,core_admin
registermoodleorgli2,core_admin
registerwithmoodleorg,core_admin
completeregistration,core_hub
registersite,core_hub
updatesite,core_hub
unregisterexplained,core_hub

View File

@ -33,7 +33,6 @@ $string['audiencestudents'] = 'Students';
$string['audienceadmins'] = 'Moodle administrators';
$string['badgesnumber'] = 'Number of badges ({$a})';
$string['communityremoved'] = 'That course link has been removed from your list';
$string['completeregistration'] = 'Complete registration with Moodle.net';
$string['confirmregistration'] = 'Confirm registration';
$string['coursename'] = 'Name';
$string['coursepublished'] = 'This course has been shared successfully on \'{$a}\'.';
@ -55,7 +54,7 @@ $string['eduleveltertiary'] = 'Tertiary';
$string['emailalert'] = 'Email notifications';
$string['emailalert_help'] = 'If this is enabled the hub administrator will send you emails about security issues and other important news.';
$string['enrollable'] = 'Enrollable';
$string['errorotherhubsnotsupported'] = 'This page can no longer be used for registration with sites other than Moodle.net';
$string['errorotherhubsnotsupported'] = 'This page can no longer be used for registration with custom sites directories.';
$string['errorws'] = '{$a}';
$string['errorwstokenreset'] = '{$a}. Registration token on this site has been reset. You can now register your site again.';
$string['errorregistrationupdate'] = 'An error occurred during registration update ({$a})';
@ -86,7 +85,7 @@ $string['none'] = 'None';
$string['operation'] = 'Actions';
$string['participantnumberaverage'] = 'Average number of participants ({$a})';
$string['policyagreed'] = 'Privacy notice and data processing agreement';
$string['policyagreeddesc'] = 'I agree to the <a href="{$a}" target="_blank">Privacy notice and data processing agreement</a> for Moodle.net';
$string['policyagreeddesc'] = 'I agree to the <a href="{$a}" target="_blank">Privacy notice and data processing agreement</a>';
$string['postaladdress'] = 'Postal address';
$string['postaladdress_help'] = 'Postal address of this site, or of the entity represented by this site.';
$string['postsnumber'] = 'Number of posts ({$a})';
@ -97,7 +96,19 @@ $string['registeredsites'] = 'Registered sites';
$string['registrationinfo'] = 'Registration information';
$string['registereduserdevices'] = 'Number of users with registered mobile devices ({$a})';
$string['registeredactiveuserdevices'] = 'Number of active users with registered mobile devices which are receiving notifications ({$a})';
$string['registersite'] = 'Register with {$a}';
$string['registerwithmoodleorg'] = 'Register your site';
$string['registerwithmoodleorgupdate'] = 'Update your site registration';
$string['registerwithmoodleorgcomplete'] = 'Complete your site registration';
$string['registerwithmoodleorginfo'] = 'We\'d love to stay in touch and provide you with important things for your Moodle site! By registering:
* You can subscribe to receive notifications of new Moodle releases, security alerts and other important news.
* You can access and activate mobile push notifications from your Moodle site through our free Moodle app.
* You are contributing to our Moodle statistics of the worldwide community, which help us improve Moodle and our community sites.
* If you wish, your site can be included in the list of registered Moodle sites in your country.';
$string['registerwithmoodleorginfoapp'] = 'About the Moodle app';
$string['registerwithmoodleorginfostats'] = 'Moodle statistics';
$string['registerwithmoodleorginfosites'] = 'Other sites in my country';
$string['registerwithmoodleorgremove'] = 'You are going to unregister your site. If you continue, you will no longer have access to important notifications and security alerts. Your users will not be able to receive push notifications from your site to their Moodle mobile app. Are you sure you want to unregister your site?';
$string['registrationconfirmed'] = 'Site registration confirmed';
$string['registrationconfirmedon'] = 'Thank you for registering your site. Registration information will be kept up to date by the \'Site registration\' scheduled task.';
$string['renewregistration'] = 'Renew registration';
@ -151,13 +162,11 @@ $string['subject'] = 'Subject';
$string['subject_help'] = 'Select the main subject area which the course covers.';
$string['type'] = 'Shared';
$string['unregister'] = 'Unregister';
$string['unregisterfrom'] = 'Unregister from {$a}';
$string['unregistrationerror'] = 'An error occurred when the site tried to unregister from Moodle.net: {$a}';
$string['unregistrationerror'] = 'An error occurred while attempting to unregister the site: {$a}';
$string['update'] = 'Update';
$string['updatesite'] = 'Update registration on {$a}';
$string['updatesiteregistration'] = 'Update registration';
$string['usedifferentemail'] = 'Use different email';
$string['unregisterexplained'] = 'If the site with URL {$a} is registered on Moodle.net its registration will be removed.';
$string['urlalreadyregistered'] = 'Your site seems to be already registered on Moodle.net, which means something has gone wrong. Please contact the Moodle.net administrator to reset your registration so you can try again.';
$string['urlalreadyregistered'] = 'Your site seems to be already registered, which means something has gone wrong. Please contact the sites directory administrator to reset your registration so you can try again.';
$string['usersnumber'] = 'Number of users ({$a})';
$string['wrongtoken'] = 'The registration failed for some unknown reason (network?). Please try again.';
@ -168,6 +177,7 @@ $string['advertised'] = 'For people to join';
$string['advertiseon'] = 'Share this course on {$a}';
$string['readvertiseon'] = 'Update advertising information on {$a}';
$string['advertisepublication_help'] = 'This course will be listed on Moodle.net as a course that people can enrol in and participate. Email-based self-registration should be enabled on the site and you need to enable self enrolment in this course.';
$string['completeregistration'] = 'Complete registration with Moodle.net';
$string['courseunpublished'] = 'The course {$a->courseshortname} is no longer shared on {$a->hubname}.';
$string['courseurl'] = 'Course URL';
$string['courseurl_help'] = 'It is the URL of your course. This URL is displayed as a link in a search result.';
@ -201,6 +211,7 @@ $string['publisheremail'] = 'Publisher email';
$string['publisheremail_help'] = 'The publisher email address allows the hub administrator to alert the publisher about any changes to the status of the published course.';
$string['publishername'] = 'Publisher';
$string['publishername_help'] = 'The publisher is the person or organisation that is the official publisher of the course. Unless you are publishing it on behalf of someone else, it will usually be you.';
$string['registersite'] = 'Register with {$a}';
$string['removefromhub'] = 'Remove from Moodle.net';
$string['screenshots'] = 'Screenshots';
$string['screenshots_help'] = 'Any screenshots of the course will be displayed in search results.';
@ -219,4 +230,7 @@ $string['unpublishalladvertisedcourses'] = 'Remove all courses that were shared
$string['unpublishalluploadedcourses'] = 'Remove all courses that were shared on Moodle.net for people to download';
$string['unpublishconfirmation'] = 'Do you really want to remove the course "{$a->courseshortname}" from "{$a->hubname}"';
$string['unpublishcourse'] = 'Stop sharing {$a}';
$string['updatestatus'] = 'Check it now.';
$string['updatesite'] = 'Update registration on {$a}';
$string['updatestatus'] = 'Check it now.';
$string['unregisterfrom'] = 'Unregister from {$a}';
$string['unregisterexplained'] = 'If the site with URL {$a} is registered, then its registration will be removed.';

View File

@ -33,7 +33,7 @@ use coding_exception;
use moodle_url;
/**
* Methods to communicate with moodle.net web services
* Provides methods to communicate with the hub (sites directory) web services.
*
* @package core
* @copyright 2017 Marina Glancy
@ -51,11 +51,11 @@ class api {
const HUB_BACKUP_FILE_TYPE = 'backup';
/**
* Calls moodle.net WS
* Calls a remote function exposed via web services on the hub.
*
* @param string $function name of WS function
* @param array $data parameters of WS function
* @param bool $allowpublic allow request without moodle.net registration
* @param bool $allowpublic allow request without registration on the hub
* @return mixed depends on the function
* @throws moodle_exception
*/
@ -71,7 +71,7 @@ class api {
}
/**
* Performs REST request to moodle.net (using GET method)
* Performs a REST request to the hub site (using the GET method).
*
* @param string $token
* @param string $function
@ -95,7 +95,7 @@ class api {
// Connection error.
throw new moodle_exception('errorconnect', 'hub', '', $curl->error);
} else if (isset($curloutput['exception'])) {
// Exception occurred on moodle.net .
// Exception occurred on the remote side.
self::process_curl_exception($token, $curloutput);
} else if ($info['http_code'] != 200) {
throw new moodle_exception('errorconnect', 'hub', '', $info['http_code']);
@ -105,7 +105,7 @@ class api {
}
/**
* Analyses exception received from moodle.net
* Analyses exception received from the hub server.
*
* @param string $token token used for CURL request
* @param array $curloutput output from CURL request
@ -128,7 +128,7 @@ class api {
}
/**
* Update site registration on moodle.net
* Update site registration on the hub.
*
* @param array $siteinfo
* @throws moodle_exception
@ -139,20 +139,20 @@ class api {
}
/**
* Returns information about moodle.net
* Returns information about the hub.
*
* Example of the return array:
* {
* "courses": 384,
* "description": "Moodle.net connects you with free content and courses shared by Moodle ...",
* "downloadablecourses": 190,
* "enrollablecourses": 194,
* "description": "Official Moodle sites directory.",
* "downloadablecourses": 0,
* "enrollablecourses": 0,
* "hublogo": 1,
* "language": "en",
* "name": "Moodle.net",
* "name": "moodle",
* "sites": 274175,
* "url": "https://moodle.net",
* "imgurl": "https://moodle.net/local/hub/webservice/download.php?filetype=hubscreenshot"
* "url": "https://stats.moodle.org",
* "imgurl": "https://stats.moodle.org/local/hub/webservice/download.php?filetype=hubscreenshot"
* }
*
* @return array
@ -327,7 +327,7 @@ class api {
*
* @param array|\stdClass $courseinfo
* @return int id of the published course on the hub
* @throws moodle_exception if communication to moodle.net failed or course could not be published
* @throws moodle_exception if the communication with the hub failed or the course could not be published
*/
public static function register_course($courseinfo) {
debugging("This function has been deprecated as part of the Moodle.net sunsetting process.");
@ -339,7 +339,7 @@ class api {
*
* @deprecated since Moodle 3.8. Moodle.net has been sunsetted making this function useless.
*
* @param int $hubcourseid id of the published course on moodle.net, it must be published from this site
* @param int $hubcourseid id of the published course on the hub, it must be published from this site
* @param \stored_file $file
* @param int $screenshotnumber ordinal number of the screenshot
*/
@ -352,7 +352,7 @@ class api {
*
* @deprecated since Moodle 3.8. Moodle.net has been sunsetted making this function useless.
*
* @param int $hubcourseid id of the course on moodle.net
* @param int $hubcourseid id of the course on the hub
* @param string $path local path (in tempdir) to save the downloaded backup to.
*/
public static function download_course_backup($hubcourseid, $path) {
@ -364,7 +364,7 @@ class api {
*
* @deprecated since Moodle 3.8. Moodle.net has been sunsetted making this function useless.
*
* @param int $hubcourseid id of the published course on moodle.net, it must be published from this site
* @param int $hubcourseid id of the published course on the hub, it must be published from this site
* @param \stored_file $backupfile
*/
public static function upload_course_backup($hubcourseid, \stored_file $backupfile) {

View File

@ -32,7 +32,7 @@ use stdClass;
use html_writer;
/**
* Methods to use when publishing and searching courses on moodle.net
* Methods to use when registering the site at the moodle sites directory.
*
* @package core
* @copyright 2017 Marina Glancy
@ -147,7 +147,7 @@ class registration {
}
/**
* Calculates and prepares site information to send to moodle.net as part of registration or update
* Calculates and prepares site information to send to the sites directory as a part of registration.
*
* @param array $defaults default values for inputs in the registration form (if site was never registered before)
* @return array site info
@ -158,9 +158,8 @@ class registration {
require_once($CFG->dirroot . "/course/lib.php");
$siteinfo = array();
$cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT);
foreach (self::FORM_FIELDS as $field) {
$siteinfo[$field] = get_config('hub', 'site_'.$field.'_' . $cleanhuburl);
$siteinfo[$field] = get_config('hub', 'site_'.$field);
if ($siteinfo[$field] === false) {
$siteinfo[$field] = array_key_exists($field, $defaults) ? $defaults[$field] : null;
}
@ -210,7 +209,7 @@ class registration {
}
/**
* Human-readable summary of data that will be sent to moodle.net
* Human-readable summary of data that will be sent to the sites directory.
*
* @param array $siteinfo result of get_site_info()
* @return string
@ -264,13 +263,12 @@ class registration {
* @param stdClass $formdata data from {@link site_registration_form}
*/
public static function save_site_info($formdata) {
$cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT);
foreach (self::FORM_FIELDS as $field) {
set_config('site_' . $field . '_' . $cleanhuburl, $formdata->$field, 'hub');
set_config('site_' . $field, $formdata->$field, 'hub');
}
// Even if the the connection with moodle.net fails, admin has manually submitted the form which means they don't need
// Even if the connection with the sites directory fails, admin has manually submitted the form which means they don't need
// to be redirected to the site registration page any more.
set_config('site_regupdateversion_' . $cleanhuburl, max(array_keys(self::CONFIRM_NEW_FIELDS)), 'hub');
set_config('site_regupdateversion', max(array_keys(self::CONFIRM_NEW_FIELDS)), 'hub');
}
/**
@ -329,7 +327,7 @@ class registration {
}
/**
* Confirms registration by moodle.net
* Confirms registration by the sites directory.
*
* @param string $token
* @param string $newtoken
@ -375,8 +373,8 @@ class registration {
* 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
* registration script on the sites directory.
* The sites directory will check that the site is accessible, register it and redirect back
* to /admin/registration/confirmregistration.php
*
* @param string $returnurl
@ -397,7 +395,7 @@ class registration {
$hub->token = get_site_identifier();
$hub->secret = $hub->token;
$hub->huburl = HUB_MOODLEORGHUBURL;
$hub->hubname = 'Moodle.net';
$hub->hubname = 'moodle';
$hub->confirmed = 0;
$hub->timemodified = time();
$hub->id = $DB->insert_record('registration_hubs', $hub);
@ -487,20 +485,20 @@ class registration {
}
/**
* Returns information about moodle.net
* Returns information about the sites directory.
*
* Example of the return array:
* {
* "courses": 384,
* "description": "Moodle.net connects you with free content and courses shared by Moodle ...",
* "downloadablecourses": 190,
* "enrollablecourses": 194,
* "description": "Official moodle sites directory",
* "downloadablecourses": 0,
* "enrollablecourses": 0,
* "hublogo": 1,
* "language": "en",
* "name": "Moodle.net",
* "name": "moodle",
* "sites": 274175,
* "url": "https://moodle.net",
* "imgurl": moodle_url : "https://moodle.net/local/hub/webservice/download.php?filetype=hubscreenshot"
* "url": "https://stats.moodle.org",
* "imgurl": "https://stats.moodle.org/local/hub/webservice/download.php?filetype=hubscreenshot"
* }
*
* @return array|null
@ -509,8 +507,8 @@ class registration {
try {
return api::get_hub_info();
} catch (moodle_exception $e) {
// Ignore error, we only need it for displaying information about moodle.net, if this request
// fails, it's not a big deal.
// Ignore error, we only need it for displaying information about the sites directory.
// If this request fails, it's not a big deal.
return null;
}
}
@ -555,8 +553,7 @@ class registration {
return $fieldsneedconfirm;
}
$cleanhuburl = clean_param(HUB_MOODLEORGHUBURL, PARAM_ALPHANUMEXT);
$lastupdated = (int)get_config('hub', 'site_regupdateversion_' . $cleanhuburl);
$lastupdated = (int)get_config('hub', 'site_regupdateversion');
foreach (self::CONFIRM_NEW_FIELDS as $version => $fields) {
if ($version > $lastupdated) {
$fieldsneedconfirm = array_merge($fieldsneedconfirm, $fields);

View File

@ -32,7 +32,7 @@ global $CFG;
require_once($CFG->libdir . '/formslib.php');
/**
* The site registration form. Information will be sent to moodle.net
* The site registration form. Information will be sent to the sites directory.
*
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @package core
@ -161,16 +161,16 @@ class site_registration_form extends \moodleform {
$mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $siteinfo['url']);
$mform->addHelpButton('urlstring', 'siteurl', 'hub');
// Display statistic that are going to be retrieve by moodle.net.
// Display statistic that are going to be retrieve by the sites directory.
$mform->addElement('static', 'siteinfosummary', get_string('sendfollowinginfo', 'hub'), registration::get_stats_summary($siteinfo));
// Check if it's a first registration or update.
if (registration::is_registered()) {
$buttonlabel = get_string('updatesite', 'hub', 'Moodle.net');
$buttonlabel = get_string('updatesiteregistration', 'core_hub');
$mform->addElement('hidden', 'update', true);
$mform->setType('update', PARAM_BOOL);
} else {
$buttonlabel = get_string('registersite', 'hub', 'Moodle.net');
$buttonlabel = get_string('register', 'core_admin');
}
$this->add_action_buttons(false, $buttonlabel);

View File

@ -1,64 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class site_unregistration_form
*
* @package core
* @copyright 2017 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\hub;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->libdir . '/formslib.php');
/**
* This form display a unregistration form.
*
* @author Jerome Mouneyrac <jerome@mouneyrac.com>
* @package core
* @copyright 2017 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class site_unregistration_form extends \moodleform {
/**
* Form definition
*/
public function definition() {
global $CFG;
$mform = & $this->_form;
$mform->addElement('header', 'site', get_string('unregister', 'hub'));
$unregisterlabel = get_string('unregister', 'hub');
$mform->addElement('advcheckbox', 'unpublishalladvertisedcourses', '',
' ' . get_string('unpublishalladvertisedcourses', 'hub'));
$mform->setType('unpublishalladvertisedcourses', PARAM_INT);
$mform->addElement('advcheckbox', 'unpublishalluploadedcourses', '',
' ' . get_string('unpublishalluploadedcourses', 'hub'));
$mform->setType('unpublishalluploadedcourses', PARAM_INT);
$mform->addElement('hidden', 'unregistration', 1);
$mform->setType('unregistration', PARAM_INT);
$mform->addElement('static', 'explanation', '', get_string('unregisterexplained', 'hub', $CFG->wwwroot));
$this->add_action_buttons(true, $unregisterlabel);
}
}

View File

@ -3556,5 +3556,23 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019092700.01);
}
if ($oldversion < 2019100800.02) {
// Rename the official moodle sites directory the site is registered with.
$DB->execute("UPDATE {registration_hubs}
SET hubname = ?, huburl = ?
WHERE huburl = ?", ['moodle', 'https://stats.moodle.org', 'https://moodle.net']);
// Convert the hub site specific settings to the new naming format without the hub URL in the name.
$hubconfig = get_config('hub');
if (!empty($hubconfig)) {
foreach (upgrade_convert_hub_config_site_param_names($hubconfig, 'https://moodle.net') as $name => $value) {
set_config($name, $value, 'hub');
}
}
upgrade_main_savepoint(true, 2019100800.02);
}
return true;
}

View File

@ -350,10 +350,10 @@ function upgrade_course_letter_boundary($courseid = null) {
}
$lettercolumnsql = '';
if ($usergradelettercolumnsetting) {
// the system default is to show a column with letters (and the course uses the defaults).
// The system default is to show a column with letters (and the course uses the defaults).
$lettercolumnsql = '(gss.value is NULL OR ' . $DB->sql_compare_text('gss.value') . ' <> \'0\')';
} else {
// the course displays a column with letters.
// The course displays a column with letters.
$lettercolumnsql = $DB->sql_compare_text('gss.value') . ' = \'1\'';
}
@ -608,4 +608,48 @@ function upgrade_rename_prediction_actions_useful_incorrectly_flagged() {
$DB->execute($updatesql, $params + ['modelid' => $model->id]);
}
}
}
/**
* Convert the site settings for the 'hub' component in the config_plugins table.
*
* @param stdClass $hubconfig Settings loaded for the 'hub' component.
* @param string $huburl The URL of the hub to use as the valid one in case of conflict.
* @return stdClass List of new settings to be applied (including null values to be unset).
*/
function upgrade_convert_hub_config_site_param_names(stdClass $hubconfig, string $huburl): stdClass {
$cleanhuburl = clean_param($huburl, PARAM_ALPHANUMEXT);
$converted = [];
foreach ($hubconfig as $oldname => $value) {
if (preg_match('/^site_([a-z]+)([A-Za-z0-9_-]*)/', $oldname, $matches)) {
$newname = 'site_'.$matches[1];
if ($oldname === $newname) {
// There is an existing value with the new naming convention already.
$converted[$newname] = $value;
} else if (!array_key_exists($newname, $converted)) {
// Add the value under a new name and mark the original to be unset.
$converted[$newname] = $value;
$converted[$oldname] = null;
} else if ($matches[2] === '_'.$cleanhuburl) {
// The new name already exists, overwrite only if coming from the valid hub.
$converted[$newname] = $value;
$converted[$oldname] = null;
} else {
// Just unset the old value.
$converted[$oldname] = null;
}
} else {
// Not a hub-specific site setting, just keep it.
$converted[$oldname] = $value;
}
}
return (object) $converted;
}

View File

@ -487,16 +487,9 @@ define('HOMEPAGE_MY', 1);
define('HOMEPAGE_USER', 2);
/**
* Hub directory url (should be moodle.org)
* URL of the Moodle sites registration portal.
*/
define('HUB_HUBDIRECTORYURL', "https://hubdirectory.moodle.org");
/**
* Moodle.net url (should be moodle.net)
*/
define('HUB_MOODLEORGHUBURL', "https://moodle.net");
define('HUB_OLDMOODLEORGHUBURL', "http://hub.moodle.org");
defined('HUB_MOODLEORGHUBURL') || define('HUB_MOODLEORGHUBURL', 'https://stats.moodle.org');
/**
* Moodle mobile app service name

View File

@ -1124,4 +1124,52 @@ class core_upgradelib_testcase extends advanced_testcase {
$this->assertEquals(1, $DB->count_records('analytics_prediction_actions',
['actionname' => \core_analytics\prediction::ACTION_INCORRECTLY_FLAGGED]));
}
/**
* Test the functionality of the {@link upgrade_convert_hub_config_site_param_names()} function.
*/
public function test_upgrade_convert_hub_config_site_param_names() {
$config = (object) [
// This is how site settings related to registration at https://moodle.net are stored.
'site_name_httpsmoodlenet' => 'Foo Site',
'site_language_httpsmoodlenet' => 'en',
'site_emailalert_httpsmoodlenet' => 1,
// These are unexpected relics of a value as registered at the old http://hub.moodle.org site.
'site_name_httphubmoodleorg' => 'Bar Site',
'site_description_httphubmoodleorg' => 'Old description',
// This is the target value we are converting to - here it already somehow exists.
'site_emailalert' => 0,
// This is a setting not related to particular hub.
'custom' => 'Do not touch this',
// A setting defined for multiple alternative hubs.
'site_foo_httpfirsthuborg' => 'First',
'site_foo_httpanotherhubcom' => 'Another',
'site_foo_httpyetanotherhubcom' => 'Yet another',
// A setting defined for multiple alternative hubs and one referential one.
'site_bar_httpfirsthuborg' => 'First',
'site_bar_httpanotherhubcom' => 'Another',
'site_bar_httpsmoodlenet' => 'One hub to rule them all!',
'site_bar_httpyetanotherhubcom' => 'Yet another',
];
$converted = upgrade_convert_hub_config_site_param_names($config, 'https://moodle.net');
// Values defined for the moodle.net take precedence over the ones defined for other hubs.
$this->assertSame($converted->site_name, 'Foo Site');
$this->assertSame($converted->site_bar, 'One hub to rule them all!');
$this->assertNull($converted->site_name_httpsmoodlenet);
$this->assertNull($converted->site_bar_httpfirsthuborg);
$this->assertNull($converted->site_bar_httpanotherhubcom);
$this->assertNull($converted->site_bar_httpyetanotherhubcom);
// Values defined for alternative hubs only do not have any guaranteed value. Just for convenience, we use the first one.
$this->assertSame($converted->site_foo, 'First');
$this->assertNull($converted->site_foo_httpfirsthuborg);
$this->assertNull($converted->site_foo_httpanotherhubcom);
$this->assertNull($converted->site_foo_httpyetanotherhubcom);
// Values that are already defined with the new name format are kept.
$this->assertSame($converted->site_emailalert, 0);
// Eventual custom values not following the expected hub-specific naming format, are kept.
$this->assertSame($converted->custom, 'Do not touch this');
}
}

View File

@ -40,7 +40,7 @@ $string['generalsettings'] = 'General settings';
$string['nobootswatch'] = 'None';
$string['pluginname'] = 'Boost';
$string['presetfiles'] = 'Additional theme preset files';
$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See <a href="https://docs.moodle.org/dev/Boost_Presets">Boost presets</a> for information on creating and sharing your own preset files, and see the <a href="https://moodle.net/boost">Presets repository</a> for presets that others have shared.';
$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See <a href="https://docs.moodle.org/dev/Boost_Presets">Boost presets</a> for information on creating and sharing your own preset files, and see the <a href="https://archive.moodle.net/boost">Presets repository</a> for presets that others have shared.';
$string['preset'] = 'Theme preset';
$string['preset_desc'] = 'Pick a preset to broadly change the look of the theme.';
$string['privacy:metadata'] = 'The Boost theme does not store any personal data about any user.';

View File

@ -32,7 +32,7 @@ $string['navbardark'] = 'Use a dark style navbar';
$string['navbardarkdesc'] = 'Swaps text and background colours for the navbar at the top of the page between dark and light.';
$string['pluginname'] = 'Classic';
$string['presetfiles'] = 'Additional theme preset files';
$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See <a href=https://docs.moodle.org/dev/Boost_Presets>Boost presets</a> for information on creating and sharing your own preset files, and see the <a href=https://moodle.net/boost>Presets repository</a> for presets that others have shared.';
$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See <a href="https://docs.moodle.org/dev/Boost_Presets">Boost presets</a> for information on creating and sharing your own preset files, and see the <a href="https://archive.moodle.net/boost">Presets repository</a> for presets that others have shared.';
$string['preset'] = 'Theme preset';
$string['preset_desc'] = 'Pick a preset to broadly change the look of the theme.';
$string['region-side-post'] = 'Right';

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2019100800.01; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2019100800.02; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.