diff --git a/lang/en/hub.php b/lang/en/hub.php index fcd85b0c573..4a9937d657f 100644 --- a/lang/en/hub.php +++ b/lang/en/hub.php @@ -111,6 +111,8 @@ $string['nosearch'] = 'Don\'t publish hub or courses'; $string['notregisteredonhub'] = 'Your administrator needs to register this site with Moodle.net before you can share a course.'; $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['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})'; diff --git a/lib/classes/hub/registration.php b/lib/classes/hub/registration.php index 187ab859a67..dc09ffbb6a3 100644 --- a/lib/classes/hub/registration.php +++ b/lib/classes/hub/registration.php @@ -43,7 +43,8 @@ class registration { /** @var Fields used in a site registration form. * IMPORTANT: any new fields with non-empty defaults have to be added to CONFIRM_NEW_FIELDS */ const FORM_FIELDS = ['name', 'description', 'contactname', 'contactemail', 'contactphone', 'imageurl', 'privacy', 'street', - 'regioncode', 'countrycode', 'geolocation', 'contactable', 'emailalert', 'emailalertemail', 'commnews', 'commnewsemail', 'language']; + 'regioncode', 'countrycode', 'geolocation', 'contactable', 'emailalert', 'emailalertemail', 'commnews', 'commnewsemail', + 'language', 'policyagreed']; /** @var List of new FORM_FIELDS or siteinfo fields added indexed by the version when they were added. * If site was already registered, admin will be promted to confirm new registration data manually. Until registration is manually confirmed, diff --git a/lib/classes/hub/site_registration_form.php b/lib/classes/hub/site_registration_form.php index ee7368d9505..510a2da42b0 100644 --- a/lib/classes/hub/site_registration_form.php +++ b/lib/classes/hub/site_registration_form.php @@ -64,7 +64,8 @@ class site_registration_form extends \moodleform { 'language' => explode('_', current_language())[0], 'geolocation' => '', 'emailalert' => 1, - 'commnews' => 1 + 'commnews' => 1, + 'policyagreed' => 0 ]); @@ -151,6 +152,10 @@ class site_registration_form extends \moodleform { $mform->addElement('hidden', 'imageurl', ''); // TODO: temporary. $mform->setType('imageurl', PARAM_URL); + $mform->addElement('checkbox', 'policyagreed', get_string('policyagreed', 'hub'), + get_string('policyagreeddesc', 'hub', HUB_MOODLEORGHUBURL . '/privacy')); + $mform->addRule('policyagreed', $strrequired, 'required', null, 'client'); + $mform->addElement('header', 'sitestats', get_string('sendfollowinginfo', 'hub')); $mform->setExpanded('sitestats', !empty($highlightfields)); $mform->addElement('static', 'urlstring', get_string('siteurl', 'hub'), $siteinfo['url']); @@ -182,7 +187,9 @@ class site_registration_form extends \moodleform { if (empty($siteinfo['commnewsnewemail'])) { $siteinfo['commnewsemail'] = ''; } - $this->set_data($siteinfo); + + // Set data. Always require to check policyagreed even if it was checked earlier. + $this->set_data(['policyagreed' => 0] + $siteinfo); } /** @@ -262,7 +269,8 @@ class site_registration_form extends \moodleform { if (debugging('', DEBUG_DEVELOPER)) { // Display debugging message for developers who added fields to the form and forgot to add them to registration::FORM_FIELDS. - $keys = array_diff(array_keys((array)$data), ['returnurl', 'mform_isexpanded_id_sitestats', 'submitbutton', 'update']); + $keys = array_diff(array_keys((array)$data), + ['returnurl', 'mform_isexpanded_id_sitestats', 'submitbutton', 'update']); if ($extrafields = array_diff($keys, registration::FORM_FIELDS)) { debugging('Found extra fields in the form results: ' . join(', ', $extrafields), DEBUG_DEVELOPER); }