MDL-52586 webservices: Return the default user home page

This commit is contained in:
Juan Leyva 2015-12-22 16:50:58 +01:00
parent ea3ebbf20e
commit 333e77703d
2 changed files with 16 additions and 1 deletions

View File

@ -193,6 +193,9 @@ class core_webservice_external extends external_api {
// 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;
}
@ -251,7 +254,10 @@ class core_webservice_external extends external_api {
'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)
)
);
}

View File

@ -124,6 +124,8 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
$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();
@ -138,6 +140,11 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
$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.
@ -147,6 +154,8 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
$this->assertEquals(USER_CAN_IGNORE_FILE_SIZE_LIMITS, $siteinfo['usermaxuploadfilesize']);
$this->assertEquals(true, $siteinfo['usercanmanageownfiles']);
$this->assertEquals(HOMEPAGE_SITE, $siteinfo['userhomepage']);
}
}