MDL-65550 webservice: Return in get_site_info WS if user is admin

This commit is contained in:
Juan Leyva
2019-08-21 12:31:49 +01:00
parent 7e16c70b52
commit 20570e5d9f
3 changed files with 6 additions and 0 deletions
+2
View File
@@ -206,6 +206,7 @@ class core_webservice_external extends external_api {
} else {
$siteinfo['usercalendartype'] = $USER->calendartype;
}
$siteinfo['userissiteadmin'] = is_siteadmin();
// Current theme.
$siteinfo['theme'] = clean_param($PAGE->theme->name, PARAM_THEME); // We always clean to avoid problem with old sites.
@@ -275,6 +276,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),
)
);
+2
View File
@@ -130,6 +130,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']);
@@ -160,6 +161,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']);
}
+2
View File
@@ -9,6 +9,8 @@ This information is intended for authors of webservices, not people writing webs
is passed and the web service call does not require the user to be logged in we will attempt to use GET for the
request. This allows for things like proxy caching on URLs. The cache key must be changed if we do not want to
retrieve what has been cached and want to perform the request again.
* 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 ===