diff --git a/webservice/externallib.php b/webservice/externallib.php index 94e3858c0a057..8391df7b68f19 100644 --- a/webservice/externallib.php +++ b/webservice/externallib.php @@ -206,6 +206,9 @@ public static function get_site_info($serviceshortnames = array()) { $siteinfo['usercalendartype'] = $USER->calendartype; } + // Current theme. + $siteinfo['theme'] = clean_param($PAGE->theme->name, PARAM_THEME); // We always clean to avoid problem with old sites. + return $siteinfo; } @@ -271,6 +274,7 @@ public static function get_site_info_returns() { '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), + '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 f9122c67bebc7..91ffdfa4a7731 100644 --- a/webservice/tests/externallib_test.php +++ b/webservice/tests/externallib_test.php @@ -39,7 +39,7 @@ public function setUp() { } public function test_get_site_info() { - global $DB, $USER, $CFG; + global $DB, $USER, $CFG, $PAGE; $this->resetAfterTest(true); @@ -49,10 +49,12 @@ public function test_get_site_info() { set_config('userquota', $userquota); // Set current user + set_config('allowuserthemes', 1); $user = array(); $user['username'] = 'johnd'; $user['firstname'] = 'John'; $user['lastname'] = 'Doe'; + $user['theme'] = 'more'; self::setUser(self::getDataGenerator()->create_user($user)); // Add a web service and token. @@ -128,6 +130,8 @@ public function test_get_site_info() { } else { $this->assertEquals($CFG->calendartype, $siteinfo['usercalendartype']); } + $this->assertEquals($CFG->calendartype, $siteinfo['sitecalendartype']); + $this->assertEquals($user['theme'], $siteinfo['theme']); // Now as admin. $this->setAdminUser(); @@ -156,9 +160,8 @@ public function test_get_site_info() { $this->assertEquals(0, $siteinfo['userquota']); $this->assertEquals(USER_CAN_IGNORE_FILE_SIZE_LIMITS, $siteinfo['usermaxuploadfilesize']); $this->assertEquals(true, $siteinfo['usercanmanageownfiles']); - - $this->assertEquals(HOMEPAGE_SITE, $siteinfo['userhomepage']); - + $this->assertEmpty($USER->theme); + $this->assertEquals($PAGE->theme->name, $siteinfo['theme']); } /** diff --git a/webservice/upgrade.txt b/webservice/upgrade.txt index 8867faead4a79..d5b959d5c5ae5 100644 --- a/webservice/upgrade.txt +++ b/webservice/upgrade.txt @@ -3,6 +3,10 @@ information provided here is intended especially for developers. This information is intended for authors of webservices, not people writing webservice clients. +=== 3.7 === + +* External function core_webservice_external::get_site_info() now returns the current site theme (for the user). + === 3.4 === * External function core_webservice_external::get_site_info() now returns the calendar type used in the site and