MDL-73008 ws: Return current policy acceptance status

This commit is contained in:
Juan Leyva 2023-11-29 11:55:49 +01:00
parent abba174fe1
commit f40c196e51
2 changed files with 4 additions and 0 deletions

View File

@ -210,6 +210,8 @@ class core_webservice_external extends \core_external\external_api {
$siteinfo['usersessionscount'] = $DB->count_records('sessions', ['userid' => $USER->id]);
}
$siteinfo['policyagreed'] = $USER->policyagreed;
return $siteinfo;
}
@ -282,6 +284,7 @@ class core_webservice_external extends \core_external\external_api {
'limitconcurrentlogins' => new external_value(PARAM_INT, 'Number of concurrent sessions allowed', VALUE_OPTIONAL),
'usersessionscount' => new external_value(PARAM_INT, 'Number of active sessions for current user.
Only returned when limitconcurrentlogins is used.', VALUE_OPTIONAL),
'policyagreed' => new external_value(PARAM_INT, 'Whether user accepted all the policies.', VALUE_OPTIONAL),
)
);
}

View File

@ -141,6 +141,7 @@ class externallib_test extends externallib_advanced_testcase {
$this->assertFalse($siteinfo['userissiteadmin']);
$this->assertEquals($CFG->calendartype, $siteinfo['sitecalendartype']);
$this->assertEquals($user['theme'], $siteinfo['theme']);
$this->assertEquals($USER->policyagreed, $siteinfo['policyagreed']);
// Now as admin.
$this->setAdminUser();