Skip to content

Commit

Permalink
Merge branch 'MDL-79296-main' of https://github.com/rmady/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
HuongNV13 committed Jan 11, 2024
2 parents e75d017 + 5a7afb7 commit a365498
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 10 additions & 4 deletions auth/email/classes/external.php
Expand Up @@ -108,6 +108,9 @@ public static function get_signup_settings() {
if (!empty($CFG->country)) {
$result['country'] = $CFG->country;
}
if (!empty($CFG->extendedusernamechars)) {
$result['extendedusernamechars'] = $CFG->extendedusernamechars;
}

if ($fields = profile_get_signup_fields()) {
$result['profilefields'] = array();
Expand Down Expand Up @@ -140,7 +143,7 @@ public static function get_signup_settings() {
public static function get_signup_settings_returns() {

return new external_single_structure(
array(
[
'namefields' => new external_multiple_structure(
new external_value(PARAM_NOTAGS, 'The order of the name fields')
),
Expand All @@ -149,9 +152,12 @@ public static function get_signup_settings_returns() {
'sitepolicyhandler' => new external_value(PARAM_PLUGIN, 'Site policy handler', VALUE_OPTIONAL),
'defaultcity' => new external_value(PARAM_NOTAGS, 'Default city', VALUE_OPTIONAL),
'country' => new external_value(PARAM_ALPHA, 'Default country', VALUE_OPTIONAL),
'extendedusernamechars' => new external_value(
PARAM_BOOL, 'Extended characters in usernames or not', VALUE_OPTIONAL
),
'profilefields' => new external_multiple_structure(
new external_single_structure(
array(
[
'id' => new external_value(PARAM_INT, 'Profile field id', VALUE_OPTIONAL),
'shortname' => new external_value(PARAM_ALPHANUMEXT, 'Profile field shortname', VALUE_OPTIONAL),
'name' => new external_value(PARAM_RAW, 'Profield field name', VALUE_OPTIONAL),
Expand All @@ -173,15 +179,15 @@ public static function get_signup_settings_returns() {
'param3' => new external_value(PARAM_RAW, 'Profield field settings', VALUE_OPTIONAL),
'param4' => new external_value(PARAM_RAW, 'Profield field settings', VALUE_OPTIONAL),
'param5' => new external_value(PARAM_RAW, 'Profield field settings', VALUE_OPTIONAL),
)
]
), 'Required profile fields', VALUE_OPTIONAL
),
'recaptchapublickey' => new external_value(PARAM_RAW, 'Recaptcha public key', VALUE_OPTIONAL),
'recaptchachallengehash' => new external_value(PARAM_RAW, 'Recaptcha challenge hash', VALUE_OPTIONAL),
'recaptchachallengeimage' => new external_value(PARAM_URL, 'Recaptcha challenge noscript image', VALUE_OPTIONAL),
'recaptchachallengejs' => new external_value(PARAM_URL, 'Recaptcha challenge js url', VALUE_OPTIONAL),
'warnings' => new external_warnings(),
)
]
);
}

Expand Down
2 changes: 2 additions & 0 deletions auth/email/tests/external/external_test.php
Expand Up @@ -74,6 +74,7 @@ public function test_get_signup_settings() {
$CFG->defaultcity = 'Bcn';
$CFG->country = 'ES';
$CFG->sitepolicy = 'https://moodle.org';
$CFG->extendedusernamechars = true;

$result = auth_email_external::get_signup_settings();
$result = \core_external\external_api::clean_returnvalue(auth_email_external::get_signup_settings_returns(), $result);
Expand All @@ -84,6 +85,7 @@ public function test_get_signup_settings() {
$this->assertEquals($CFG->country, $result['country']);
$this->assertEquals($CFG->sitepolicy, $result['sitepolicy']);
$this->assertEquals(print_password_policy(), $result['passwordpolicy']);
$this->assertEquals($CFG->extendedusernamechars, $result['extendedusernamechars']);
$this->assertNotContains('recaptchachallengehash', $result);
$this->assertNotContains('recaptchachallengeimage', $result);

Expand Down
4 changes: 3 additions & 1 deletion auth/email/upgrade.txt
@@ -1,8 +1,10 @@
This files describes API changes in /auth/email/*,
information provided here is intended especially for developers.
=== 4.4 ===

* External function auth_email_external::get_signup_settings() now returns the field "extendedusernamechars".

=== 3.3 ===

* The config.html file was migrated to use the admin settings API.
The identifier for configuration data stored in config_plugins table was converted from 'auth/email' to 'auth_email'.

0 comments on commit a365498

Please sign in to comment.