Skip to content

Commit

Permalink
Merge branch 'MDL-52586-master' of git://github.com/jleyva/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 13, 2016
2 parents 64858d4 + 333e777 commit 38c6a30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion webservice/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ public static function get_site_info($serviceshortnames = array()) {
// User max upload file size. -1 means the user can ignore the upload file size.
$siteinfo['usermaxuploadfilesize'] = get_user_max_upload_file_size($context, $CFG->maxbytes);

// User home page.
$siteinfo['userhomepage'] = get_home_page();

return $siteinfo;
}

Expand Down Expand Up @@ -251,7 +254,10 @@ public static function get_site_info_returns() {
'user quota (bytes). 0 means user can ignore the quota', VALUE_OPTIONAL),
'usermaxuploadfilesize' => new external_value(PARAM_INT,
'user max upload file size (bytes). -1 means the user can ignore the upload file size',
VALUE_OPTIONAL)
VALUE_OPTIONAL),
'userhomepage' => new external_value(PARAM_INT,
'the default home page for the user: 0 for the site home, 1 for dashboard',
VALUE_OPTIONAL)
)
);
}
Expand Down
9 changes: 9 additions & 0 deletions webservice/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public function test_get_site_info() {
$this->assertEquals(get_max_upload_file_size($maxbytes), $siteinfo['usermaxuploadfilesize']);
$this->assertEquals(true, $siteinfo['usercanmanageownfiles']);

$this->assertEquals(HOMEPAGE_MY, $siteinfo['userhomepage']);

// Now as admin.
$this->setAdminUser();

Expand All @@ -138,6 +140,11 @@ public function test_get_site_info() {
$externaltoken->creatorid = $USER->id;
$externaltoken->timecreated = time();
$DB->insert_record('external_tokens', $externaltoken);

// Set a home page by user preferences.
$CFG->defaulthomepage = HOMEPAGE_USER;
set_user_preference('user_home_page_preference', HOMEPAGE_SITE);

$siteinfo = core_webservice_external::get_site_info();

// We need to execute the return values cleaning process to simulate the web service server.
Expand All @@ -147,6 +154,8 @@ public function test_get_site_info() {
$this->assertEquals(USER_CAN_IGNORE_FILE_SIZE_LIMITS, $siteinfo['usermaxuploadfilesize']);
$this->assertEquals(true, $siteinfo['usercanmanageownfiles']);

$this->assertEquals(HOMEPAGE_SITE, $siteinfo['userhomepage']);

}

}

0 comments on commit 38c6a30

Please sign in to comment.