mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-61622 auth: New WS is_age_digital_consent_verification_enabled
This commit is contained in:
parent
1287039e62
commit
1f7565c121
@ -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(
|
||||
|
@ -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.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user