Merge branch 'MDL-61622-master' of git://github.com/jleyva/moodle
This commit is contained in:
@@ -149,6 +149,8 @@ class api {
|
||||
'maintenancemessage' => $maintenancemessage,
|
||||
'mobilecssurl' => !empty($CFG->mobilecssurl) ? $CFG->mobilecssurl : '',
|
||||
'tool_mobile_disabledfeatures' => get_config('tool_mobile', 'disabledfeatures'),
|
||||
'country' => clean_param($CFG->country, PARAM_NOTAGS),
|
||||
'agedigitalconsentverification' => \core_auth\digital_consent::is_age_digital_consent_verification_enabled(),
|
||||
);
|
||||
|
||||
$typeoflogin = get_config('tool_mobile', 'typeoflogin');
|
||||
@@ -180,6 +182,12 @@ class api {
|
||||
$settings['identityproviders'] = $identityprovidersdata;
|
||||
}
|
||||
|
||||
// If age is verified, return also the admin contact details.
|
||||
if ($settings['agedigitalconsentverification']) {
|
||||
$settings['supportname'] = clean_param($CFG->supportname, PARAM_NOTAGS);
|
||||
$settings['supportemail'] = clean_param($CFG->supportemail, PARAM_EMAIL);
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,6 +161,13 @@ class external extends external_api {
|
||||
),
|
||||
'Identity providers', VALUE_OPTIONAL
|
||||
),
|
||||
'country' => new external_value(PARAM_NOTAGS, 'Default site country', VALUE_OPTIONAL),
|
||||
'agedigitalconsentverification' => new external_value(PARAM_BOOL, 'Whether age digital consent verification
|
||||
is enabled.', VALUE_OPTIONAL),
|
||||
'supportname' => new external_value(PARAM_NOTAGS, 'Site support contact name
|
||||
(only if age verification is enabled).', VALUE_OPTIONAL),
|
||||
'supportemail' => new external_value(PARAM_EMAIL, 'Site support contact email
|
||||
(only if age verification is enabled).', VALUE_OPTIONAL),
|
||||
'warnings' => new external_warnings(),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -86,6 +86,8 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
|
||||
'mobilecssurl' => '',
|
||||
'tool_mobile_disabledfeatures' => '',
|
||||
'launchurl' => "$CFG->wwwroot/$CFG->admin/tool/mobile/launch.php",
|
||||
'country' => $CFG->country,
|
||||
'agedigitalconsentverification' => \core_auth\digital_consent::is_age_digital_consent_verification_enabled(),
|
||||
'warnings' => array()
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
@@ -98,12 +100,16 @@ class tool_mobile_external_testcase extends externallib_advanced_testcase {
|
||||
set_config('logo', 'mock.png', 'core_admin');
|
||||
set_config('logocompact', 'mock.png', 'core_admin');
|
||||
set_config('forgottenpasswordurl', 'mailto:[email protected]'); // Test old hack.
|
||||
set_config('agedigitalconsentverification', 1);
|
||||
|
||||
list($authinstructions, $notusedformat) = external_format_text($authinstructions, FORMAT_MOODLE, $context->id);
|
||||
$expected['registerauth'] = 'email';
|
||||
$expected['authinstructions'] = $authinstructions;
|
||||
$expected['typeoflogin'] = api::LOGIN_VIA_BROWSER;
|
||||
$expected['forgottenpasswordurl'] = ''; // Expect empty when it's not an URL.
|
||||
$expected['agedigitalconsentverification'] = true;
|
||||
$expected['supportname'] = $CFG->supportname;
|
||||
$expected['supportemail'] = $CFG->supportemail;
|
||||
|
||||
if ($logourl = $OUTPUT->get_logo_url()) {
|
||||
$expected['logourl'] = $logourl->out(false);
|
||||
|
||||
@@ -287,4 +287,53 @@ class core_auth_external extends external_api {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the parameters for is_age_digital_consent_verification_enabled.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public static function is_age_digital_consent_verification_enabled_parameters() {
|
||||
return new external_function_parameters(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if age digital consent verification is enabled.
|
||||
*
|
||||
* @return array status (true if digital consent verification is enabled, false otherwise.)
|
||||
* @since Moodle 3.3
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function is_age_digital_consent_verification_enabled() {
|
||||
global $PAGE;
|
||||
|
||||
$context = context_system::instance();
|
||||
$PAGE->set_context($context);
|
||||
|
||||
$status = false;
|
||||
// Check if verification is enabled.
|
||||
if (\core_auth\digital_consent::is_age_digital_consent_verification_enabled()) {
|
||||
$status = true;
|
||||
}
|
||||
|
||||
return array(
|
||||
'status' => $status
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the is_age_digital_consent_verification_enabled return value.
|
||||
*
|
||||
* @return external_single_structure
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
public static function is_age_digital_consent_verification_enabled_returns() {
|
||||
return new external_single_structure(
|
||||
array(
|
||||
'status' => new external_value(PARAM_BOOL, 'True if digital consent verification is enabled,
|
||||
false otherwise.')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +89,30 @@ class core_auth_external_testcase extends externallib_advanced_testcase {
|
||||
$this->expectExceptionMessage(get_string('invalidconfirmdata', 'error'));
|
||||
$result = core_auth_external::confirm_user($username, 'zzZZzz');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test age digital consent not enabled.
|
||||
*/
|
||||
public function test_age_digital_consent_verification_is_not_enabled() {
|
||||
global $CFG;
|
||||
|
||||
$CFG->agedigitalconsentverification = 0;
|
||||
$result = core_auth_external::is_age_digital_consent_verification_enabled();
|
||||
$result = external_api::clean_returnvalue(
|
||||
core_auth_external::is_age_digital_consent_verification_enabled_returns(), $result);
|
||||
$this->assertFalse($result['status']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test age digital consent is enabled.
|
||||
*/
|
||||
public function test_age_digital_consent_verification_is_enabled() {
|
||||
global $CFG;
|
||||
|
||||
$CFG->agedigitalconsentverification = 1;
|
||||
$result = core_auth_external::is_age_digital_consent_verification_enabled();
|
||||
$result = external_api::clean_returnvalue(
|
||||
core_auth_external::is_age_digital_consent_verification_enabled_returns(), $result);
|
||||
$this->assertTrue($result['status']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,15 @@ $functions = array(
|
||||
'methodname' => 'is_minor',
|
||||
'description' => 'Requests a check if a user is a digital minor.',
|
||||
'type' => 'read',
|
||||
'ajax' => true,
|
||||
'loginrequired' => false,
|
||||
),
|
||||
'core_auth_is_age_digital_consent_verification_enabled' => array(
|
||||
'classname' => 'core_auth_external',
|
||||
'methodname' => 'is_age_digital_consent_verification_enabled',
|
||||
'description' => 'Checks if age digital consent verification is enabled.',
|
||||
'type' => 'read',
|
||||
'ajax' => true,
|
||||
'loginrequired' => false,
|
||||
),
|
||||
'core_badges_get_user_badges' => array(
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2018030800.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2018030800.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user