Merge branch 'MDL-65550-master' of git://github.com/jleyva/moodle

This commit is contained in:
Andrew Nicols 2019-09-05 11:38:36 +08:00
commit 413172521a
3 changed files with 6 additions and 0 deletions

View File

@ -206,6 +206,7 @@ class core_webservice_external extends external_api {
} else {
$siteinfo['usercalendartype'] = $USER->calendartype;
}
$siteinfo['userissiteadmin'] = is_siteadmin();
// User key, to avoid using the WS token for fetching assets.
$siteinfo['userprivateaccesskey'] = get_user_key('core_files', $USER->id);
@ -280,6 +281,7 @@ class core_webservice_external extends external_api {
'siteid' => new external_value(PARAM_INT, 'Site course ID', VALUE_OPTIONAL),
'sitecalendartype' => new external_value(PARAM_PLUGIN, 'Calendar type set in the site.', VALUE_OPTIONAL),
'usercalendartype' => new external_value(PARAM_PLUGIN, 'Calendar typed used by the user.', VALUE_OPTIONAL),
'userissiteadmin' => new external_value(PARAM_BOOL, 'Whether the user is a site admin or not.', VALUE_OPTIONAL),
'theme' => new external_value(PARAM_THEME, 'Current theme for the user.', VALUE_OPTIONAL),
)
);

View File

@ -132,6 +132,7 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
} else {
$this->assertEquals($CFG->calendartype, $siteinfo['usercalendartype']);
}
$this->assertFalse($siteinfo['userissiteadmin']);
$this->assertEquals($CFG->calendartype, $siteinfo['sitecalendartype']);
$this->assertEquals($user['theme'], $siteinfo['theme']);
@ -162,6 +163,7 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
$this->assertEquals(0, $siteinfo['userquota']);
$this->assertEquals(USER_CAN_IGNORE_FILE_SIZE_LIMITS, $siteinfo['usermaxuploadfilesize']);
$this->assertEquals(true, $siteinfo['usercanmanageownfiles']);
$this->assertTrue($siteinfo['userissiteadmin']);
$this->assertEmpty($USER->theme);
$this->assertEquals($PAGE->theme->name, $siteinfo['theme']);
}

View File

@ -12,6 +12,8 @@ This information is intended for authors of webservices, not people writing webs
* External function core_webservice_external::get_site_info() now returns the user private access key "userprivateaccesskey".
This key could be used for fetching files via the tokenpluginfile.php script instead webservice/pluginfile.php to avoid
multiple GET requests that include the WS token as a visible parameter.
* External function core_webservice_external::get_site_info() now returns a new field "userissiteadmin" indicating if
the current user is a site administrator.
=== 3.7 ===