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

This commit is contained in:
Eloy Lafuente (stronk7) 2019-03-11 23:03:02 +01:00
commit 99daf06a4f
3 changed files with 15 additions and 4 deletions

View file

@ -206,6 +206,9 @@ class core_webservice_external extends external_api {
$siteinfo['usercalendartype'] = $USER->calendartype; $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; return $siteinfo;
} }
@ -271,6 +274,7 @@ class core_webservice_external extends external_api {
'siteid' => new external_value(PARAM_INT, 'Site course ID', VALUE_OPTIONAL), '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), '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), '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),
) )
); );
} }

View file

@ -39,7 +39,7 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
} }
public function test_get_site_info() { public function test_get_site_info() {
global $DB, $USER, $CFG; global $DB, $USER, $CFG, $PAGE;
$this->resetAfterTest(true); $this->resetAfterTest(true);
@ -49,10 +49,12 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
set_config('userquota', $userquota); set_config('userquota', $userquota);
// Set current user // Set current user
set_config('allowuserthemes', 1);
$user = array(); $user = array();
$user['username'] = 'johnd'; $user['username'] = 'johnd';
$user['firstname'] = 'John'; $user['firstname'] = 'John';
$user['lastname'] = 'Doe'; $user['lastname'] = 'Doe';
$user['theme'] = 'more';
self::setUser(self::getDataGenerator()->create_user($user)); self::setUser(self::getDataGenerator()->create_user($user));
// Add a web service and token. // Add a web service and token.
@ -128,6 +130,8 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
} else { } else {
$this->assertEquals($CFG->calendartype, $siteinfo['usercalendartype']); $this->assertEquals($CFG->calendartype, $siteinfo['usercalendartype']);
} }
$this->assertEquals($CFG->calendartype, $siteinfo['sitecalendartype']);
$this->assertEquals($user['theme'], $siteinfo['theme']);
// Now as admin. // Now as admin.
$this->setAdminUser(); $this->setAdminUser();
@ -156,9 +160,8 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
$this->assertEquals(0, $siteinfo['userquota']); $this->assertEquals(0, $siteinfo['userquota']);
$this->assertEquals(USER_CAN_IGNORE_FILE_SIZE_LIMITS, $siteinfo['usermaxuploadfilesize']); $this->assertEquals(USER_CAN_IGNORE_FILE_SIZE_LIMITS, $siteinfo['usermaxuploadfilesize']);
$this->assertEquals(true, $siteinfo['usercanmanageownfiles']); $this->assertEquals(true, $siteinfo['usercanmanageownfiles']);
$this->assertEmpty($USER->theme);
$this->assertEquals(HOMEPAGE_SITE, $siteinfo['userhomepage']); $this->assertEquals($PAGE->theme->name, $siteinfo['theme']);
} }
/** /**

View file

@ -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. 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 === === 3.4 ===
* External function core_webservice_external::get_site_info() now returns the calendar type used in the site and * External function core_webservice_external::get_site_info() now returns the calendar type used in the site and