diff --git a/webservice/externallib.php b/webservice/externallib.php index e8e11de1649..4daf43473ed 100644 --- a/webservice/externallib.php +++ b/webservice/externallib.php @@ -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), ) ); diff --git a/webservice/tests/externallib_test.php b/webservice/tests/externallib_test.php index 92fe1e48faa..fe56e750563 100644 --- a/webservice/tests/externallib_test.php +++ b/webservice/tests/externallib_test.php @@ -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']); } diff --git a/webservice/upgrade.txt b/webservice/upgrade.txt index 14ce75e2423..6f92dd39f76 100644 --- a/webservice/upgrade.txt +++ b/webservice/upgrade.txt @@ -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 ===