Commit 355c37b8 authored by Juan Leyva's avatar Juan Leyva
Browse files

MDL-64653 webservice: Return current theme in get_site_info WS

parent a62e2759
......@@ -206,6 +206,9 @@ class core_webservice_external extends external_api {
$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 @@ 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),
'theme' => new external_value(PARAM_THEME, 'Current theme for the user.', VALUE_OPTIONAL),
)
);
}
......
......@@ -39,7 +39,7 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
}
public function test_get_site_info() {
global $DB, $USER, $CFG;
global $DB, $USER, $CFG, $PAGE;
$this->resetAfterTest(true);
......@@ -49,10 +49,12 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
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 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
} 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 @@ 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->assertEquals(HOMEPAGE_SITE, $siteinfo['userhomepage']);
$this->assertEmpty($USER->theme);
$this->assertEquals($PAGE->theme->name, $siteinfo['theme']);
}
/**
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment