Skip to content

Commit

Permalink
Merge branch 'MDL-64653-master' of git://github.com/jleyva/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Mar 11, 2019
2 parents a713ed3 + 355c37b commit 99daf06
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions webservice/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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),
)
);
}
Expand Down
11 changes: 7 additions & 4 deletions webservice/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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']);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions webservice/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 99daf06

Please sign in to comment.