From a3ef4709aeb756f30f665b3ee90d4de0d1c2ce13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Wed, 21 Mar 2018 18:04:56 +0100 Subject: [PATCH 1/2] MDL-61658 user: Fix parsing of the agedigitalconsentmap setting When parsing and validating the value of the Digital age of consent (agedigitalconsentmap) field, we want to load all country codes. Not just the ones whitelisted for drop down menus that users can choose from. --- auth/classes/digital_consent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auth/classes/digital_consent.php b/auth/classes/digital_consent.php index e3e7e59bd61..3f7e3afc36b 100644 --- a/auth/classes/digital_consent.php +++ b/auth/classes/digital_consent.php @@ -71,7 +71,7 @@ class digital_consent { public static function parse_age_digital_consent_map($ageconsentmap) { $ageconsentmapparsed = array(); - $countries = get_string_manager()->get_list_of_countries(); + $countries = get_string_manager()->get_list_of_countries(true); $isdefaultvaluepresent = false; $lines = preg_split('/\r|\n/', $ageconsentmap, -1, PREG_SPLIT_NO_EMPTY); foreach ($lines as $line) { From c3ab2178205e3528dafdac989b8f8712aac1854e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Thu, 15 Mar 2018 13:17:31 +0100 Subject: [PATCH 2/2] MDL-61658 user: Fix displaying of user's country name In these cases we want to use the method get_list_of_countries() to obtain translated names of all potential country codes. The country code is already there in the database. So it does not matter if the country is among those whitelisted in $CFG->allcountrycodes - we want to see its name anyway. --- admin/user.php | 2 +- blocks/myprofile/block_myprofile.php | 2 +- user/classes/participants_table.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/admin/user.php b/admin/user.php index ac0f5f94cb6..80e462d2743 100644 --- a/admin/user.php +++ b/admin/user.php @@ -246,7 +246,7 @@ } else { - $countries = get_string_manager()->get_list_of_countries(false); + $countries = get_string_manager()->get_list_of_countries(true); if (empty($mnethosts)) { $mnethosts = $DB->get_records('mnet_host', null, 'id', 'id,wwwroot,name'); } diff --git a/blocks/myprofile/block_myprofile.php b/blocks/myprofile/block_myprofile.php index fa9c1662e5b..b596f15aea4 100644 --- a/blocks/myprofile/block_myprofile.php +++ b/blocks/myprofile/block_myprofile.php @@ -75,7 +75,7 @@ class block_myprofile extends block_base { $this->content->text .= '
'.fullname($USER).'
'; if(!isset($this->config->display_country) || $this->config->display_country == 1) { - $countries = get_string_manager()->get_list_of_countries(); + $countries = get_string_manager()->get_list_of_countries(true); if (isset($countries[$USER->country])) { $this->content->text .= '
'; $this->content->text .= get_string('country') . ': ' . $countries[$USER->country]; diff --git a/user/classes/participants_table.php b/user/classes/participants_table.php index bc66a9efbe1..a53caf185f3 100644 --- a/user/classes/participants_table.php +++ b/user/classes/participants_table.php @@ -226,7 +226,7 @@ class participants_table extends \table_sql { $this->enrolid = $enrolid; $this->status = $status; $this->selectall = $selectall; - $this->countries = get_string_manager()->get_list_of_countries(); + $this->countries = get_string_manager()->get_list_of_countries(true); $this->extrafields = $extrafields; $this->context = $context; if ($canseegroups) {