From 254b57937501d7cd7ec6eadbadff5d9f3083d00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Wed, 2 Oct 2019 21:57:01 +0200 Subject: [PATCH] MDL-66118 hub: Replace the unregister form with a confirmation Now that unpublishalladvertisedcourses and unpublishalluploadedcourses became irrelevant, there is no reason for an empty form. --- admin/registration/index.php | 24 ++++---- lang/en/deprecated.txt | 1 + lang/en/hub.php | 6 +- lib/classes/hub/site_unregistration_form.php | 64 -------------------- 4 files changed, 17 insertions(+), 78 deletions(-) delete mode 100644 lib/classes/hub/site_unregistration_form.php diff --git a/admin/registration/index.php b/admin/registration/index.php index 2b1a01f8b36..ede6a67a47e 100644 --- a/admin/registration/index.php +++ b/admin/registration/index.php @@ -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('registerwithmoodleorgremove', 'core_hub'), 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; } @@ -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(); diff --git a/lang/en/deprecated.txt b/lang/en/deprecated.txt index 5f5e3fc52a3..0595e0c0e12 100644 --- a/lang/en/deprecated.txt +++ b/lang/en/deprecated.txt @@ -114,3 +114,4 @@ 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 4a6edb5d4ff..3df03bab86e 100644 --- a/lang/en/hub.php +++ b/lang/en/hub.php @@ -108,7 +108,7 @@ $string['registerwithmoodleorginfo'] = 'We\'d love to stay in touch and provide $string['registerwithmoodleorginfoapp'] = 'About the Moodle app'; $string['registerwithmoodleorginfostats'] = 'Moodle statistics'; $string['registerwithmoodleorginfosites'] = 'Other sites in my country'; -$string['registerwithmoodleorgremove'] = 'Unregistering your site'; +$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'; @@ -166,7 +166,6 @@ $string['unregistrationerror'] = 'An error occurred while attempting to unregist $string['update'] = 'Update'; $string['updatesiteregistration'] = 'Update registration'; $string['usedifferentemail'] = 'Use different email'; -$string['unregisterexplained'] = 'If the site with URL {$a} is registered, then its registration will be removed.'; $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.'; @@ -233,4 +232,5 @@ $string['unpublishconfirmation'] = 'Do you really want to remove the course "{$a $string['unpublishcourse'] = 'Stop sharing {$a}'; $string['updatesite'] = 'Update registration on {$a}'; $string['updatestatus'] = 'Check it now.'; -$string['unregisterfrom'] = 'Unregister from {$a}'; \ No newline at end of file +$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/site_unregistration_form.php b/lib/classes/hub/site_unregistration_form.php deleted file mode 100644 index 70fc070ee94..00000000000 --- 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); - } -}