Merge branch 'MDL-79296-main' of https://github.com/rmady/moodle

This commit is contained in:
Huong Nguyen 2024-01-11 09:42:52 +07:00
commit a3654984c1
3 changed files with 15 additions and 5 deletions

View File

@ -108,6 +108,9 @@ class auth_email_external extends external_api {
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();
@ -140,7 +143,7 @@ class auth_email_external extends external_api {
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')
),
@ -149,9 +152,12 @@ class auth_email_external extends external_api {
'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),
@ -173,7 +179,7 @@ class auth_email_external extends external_api {
'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),
@ -181,7 +187,7 @@ class auth_email_external extends external_api {
'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(),
)
]
);
}

View File

@ -74,6 +74,7 @@ class external_test extends externallib_advanced_testcase {
$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);
@ -84,6 +85,7 @@ class external_test extends externallib_advanced_testcase {
$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);

View File

@ -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'.