diff --git a/admin/registration/confirmregistration.php b/admin/registration/confirmregistration.php index 7c9d422184b01..ff99680ac8bf0 100644 --- a/admin/registration/confirmregistration.php +++ b/admin/registration/confirmregistration.php @@ -46,7 +46,7 @@ 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) { diff --git a/admin/registration/forms.php b/admin/registration/forms.php index 6fe95536333af..af05a7a34fec5 100644 --- a/admin/registration/forms.php +++ b/admin/registration/forms.php @@ -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); diff --git a/admin/registration/index.php b/admin/registration/index.php index 62f251a4b4455..ede6a67a47ec0 100644 --- a/admin/registration/index.php +++ b/admin/registration/index.php @@ -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 @@ 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 @@ 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 @@ // 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 @@ 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(); diff --git a/admin/registration/renewregistration.php b/admin/registration/renewregistration.php index 84e727be32300..bc05da60ffec4 100644 --- a/admin/registration/renewregistration.php +++ b/admin/registration/renewregistration.php @@ -40,7 +40,7 @@ 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 @@ 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); diff --git a/admin/renderer.php b/admin/renderer.php index 773ba4d3c1b87..5abd08eaebb2f 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -2112,6 +2112,27 @@ protected function legacy_log_store_writing_error() { * @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); } } diff --git a/admin/tool/lp/classes/output/manage_competency_frameworks_page.php b/admin/tool/lp/classes/output/manage_competency_frameworks_page.php index 7a2181b586d79..07a6dad7687b9 100644 --- a/admin/tool/lp/classes/output/manage_competency_frameworks_page.php +++ b/admin/tool/lp/classes/output/manage_competency_frameworks_page.php @@ -75,7 +75,7 @@ public function __construct(context $pagecontext) { ); $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' ); diff --git a/admin/tool/usertours/classes/manager.php b/admin/tool/usertours/classes/manager.php index 33cd752924820..40d2595ebc2c4 100644 --- a/admin/tool/usertours/classes/manager.php +++ b/admin/tool/usertours/classes/manager.php @@ -266,7 +266,7 @@ protected function print_tour_list() { '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', ], diff --git a/index.php b/index.php index 01b2b5ffb4c35..2346d39b54e71 100644 --- a/index.php +++ b/index.php @@ -91,18 +91,6 @@ // 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(); diff --git a/lang/en/admin.php b/lang/en/admin.php index 72c40fc83dca3..ea89b1d338e4c 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -1013,11 +1013,6 @@ $string['recaptchaprivatekey'] = 'ReCAPTCHA secret key'; $string['recaptchapublickey'] = 'ReCAPTCHA site key'; $string['register'] = 'Register your site'; -$string['registermoodlenet'] = '

We\'d love to stay in touch and provide you with important things for your Moodle site!

By registering:

'; -$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['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'] = '

We\'d love to stay in touch and provide you with important things for your Moodle site!

By registering:

'; +$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'; diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index 91d0a4fd0ca70..0595e0c0e12f5 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -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 diff --git a/lang/en/hub.php b/lang/en/hub.php index ebe023fa27b39..3df03bab86ebb 100644 --- a/lang/en/hub.php +++ b/lang/en/hub.php @@ -33,7 +33,6 @@ $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['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['operation'] = 'Actions'; $string['participantnumberaverage'] = 'Average number of participants ({$a})'; $string['policyagreed'] = 'Privacy notice and data processing agreement'; -$string['policyagreeddesc'] = 'I agree to the Privacy notice and data processing agreement for Moodle.net'; +$string['policyagreeddesc'] = 'I agree to the Privacy notice and data processing agreement'; $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['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_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['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_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['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.'; \ No newline at end of file +$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.'; \ No newline at end of file diff --git a/lib/classes/hub/api.php b/lib/classes/hub/api.php index 7c0ed3716e8fd..7f8979d93abb8 100644 --- a/lib/classes/hub/api.php +++ b/lib/classes/hub/api.php @@ -33,7 +33,7 @@ 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 @@ protected static function call($function, array $data = [], $allowpublic = false } /** - * 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 @@ protected static function call_rest($token, $function, array $data) { // 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 @@ protected static function call_rest($token, $function, array $data) { } /** - * 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 @@ protected static function process_curl_exception($token, $curloutput) { } /** - * Update site registration on moodle.net + * Update site registration on the hub. * * @param array $siteinfo * @throws moodle_exception @@ -139,20 +139,20 @@ public static function update_registration(array $siteinfo) { } /** - * 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 @@ public static function unregister_courses($courseids) { * * @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 @@ public static function register_course($courseinfo) { * * @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 @@ public static function add_screenshot($hubcourseid, \stored_file $file, $screens * * @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 @@ public static function download_course_backup($hubcourseid, $path) { * * @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) { diff --git a/lib/classes/hub/registration.php b/lib/classes/hub/registration.php index cead3bb7544ac..cd716ef00846f 100644 --- a/lib/classes/hub/registration.php +++ b/lib/classes/hub/registration.php @@ -32,7 +32,7 @@ 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 @@ public static function get_last_updated() { } /** - * 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 @@ public static function get_site_info($defaults = []) { 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 @@ public static function get_site_info($defaults = []) { } /** - * 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 @@ public static function get_stats_summary($siteinfo) { * @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 @@ public static function update_cron() { } /** - * Confirms registration by moodle.net + * Confirms registration by the sites directory. * * @param string $token * @param string $newtoken @@ -375,8 +373,8 @@ public static function site_privacy_options() { * 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 @@ public static function register($returnurl) { $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 @@ public static function reset_site_identifier($token) { } /** - * 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 @@ public static function get_moodlenet_info() { 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 @@ public static function get_new_registration_fields() { 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); diff --git a/lib/classes/hub/site_registration_form.php b/lib/classes/hub/site_registration_form.php index 0369aa3958d13..f58f9ef95606b 100644 --- a/lib/classes/hub/site_registration_form.php +++ b/lib/classes/hub/site_registration_form.php @@ -32,7 +32,7 @@ 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 * @package core @@ -161,16 +161,16 @@ public function definition() { $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); diff --git a/lib/classes/hub/site_unregistration_form.php b/lib/classes/hub/site_unregistration_form.php deleted file mode 100644 index 70fc070ee9416..0000000000000 --- a/lib/classes/hub/site_unregistration_form.php +++ /dev/null @@ -1,64 +0,0 @@ -. - -/** - * 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 - * @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); - } -} diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 5ab80e90dd786..37a3784520330 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; } diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index 4c475506574e9..802417a2334cb 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -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]); } -} \ No newline at end of file +} + +/** + * 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; +} diff --git a/lib/moodlelib.php b/lib/moodlelib.php index b69b4dda851cf..dc8b0b0d5474b 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -487,16 +487,9 @@ 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 diff --git a/lib/tests/upgradelib_test.php b/lib/tests/upgradelib_test.php index 108e1852f97aa..54e4b4dedb44d 100644 --- a/lib/tests/upgradelib_test.php +++ b/lib/tests/upgradelib_test.php @@ -1124,4 +1124,52 @@ public function test_upgrade_rename_prediction_actions_useful_incorrectly_flagge $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'); + } } diff --git a/theme/boost/lang/en/theme_boost.php b/theme/boost/lang/en/theme_boost.php index 1867cb3f4cd5c..1133f7bf9968f 100644 --- a/theme/boost/lang/en/theme_boost.php +++ b/theme/boost/lang/en/theme_boost.php @@ -40,7 +40,7 @@ $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 Boost presets for information on creating and sharing your own preset files, and see the Presets repository for presets that others have shared.'; +$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See Boost presets for information on creating and sharing your own preset files, and see the Presets repository 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.'; diff --git a/theme/classic/lang/en/theme_classic.php b/theme/classic/lang/en/theme_classic.php index 9dfd1d0626165..e6f2da470cb85 100644 --- a/theme/classic/lang/en/theme_classic.php +++ b/theme/classic/lang/en/theme_classic.php @@ -32,7 +32,7 @@ $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 Boost presets for information on creating and sharing your own preset files, and see the Presets repository for presets that others have shared.'; +$string['presetfiles_desc'] = 'Preset files can be used to dramatically alter the appearance of the theme. See Boost presets for information on creating and sharing your own preset files, and see the Presets repository 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'; diff --git a/version.php b/version.php index d49e5263e2b00..9abddbc4c2f4f 100644 --- a/version.php +++ b/version.php @@ -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.