MDL-59214 webservice: Return calendar type in get_site_info

This commit is contained in:
Juan Leyva 2017-06-12 11:48:53 +01:00
parent 6bb80a1917
commit bef5777fc4
4 changed files with 23 additions and 2 deletions

View file

@ -461,7 +461,7 @@ class core_user {
'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_countries(true, true))); 'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_countries(true, true)));
$fields['lang'] = array('type' => PARAM_LANG, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->lang, $fields['lang'] = array('type' => PARAM_LANG, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->lang,
'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_translations(false))); 'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_translations(false)));
$fields['calendartype'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->calendartype, $fields['calendartype'] = array('type' => PARAM_PLUGIN, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->calendartype,
'choices' => array_merge(array('' => ''), \core_calendar\type_factory::get_list_of_calendar_types())); 'choices' => array_merge(array('' => ''), \core_calendar\type_factory::get_list_of_calendar_types()));
$fields['theme'] = array('type' => PARAM_THEME, 'null' => NULL_NOT_ALLOWED, $fields['theme'] = array('type' => PARAM_THEME, 'null' => NULL_NOT_ALLOWED,
'default' => theme_config::DEFAULT_THEME, 'choices' => array_merge(array('' => ''), get_list_of_themes())); 'default' => theme_config::DEFAULT_THEME, 'choices' => array_merge(array('' => ''), get_list_of_themes()));

View file

@ -197,6 +197,14 @@ class core_webservice_external extends external_api {
// User home page. // User home page.
$siteinfo['userhomepage'] = get_home_page(); $siteinfo['userhomepage'] = get_home_page();
// Calendar.
$siteinfo['sitecalendartype'] = $CFG->calendartype;
if (empty($USER->calendartype)) {
$siteinfo['usercalendartype'] = $CFG->calendartype;
} else {
$siteinfo['usercalendartype'] = $USER->calendartype;
}
return $siteinfo; return $siteinfo;
} }
@ -259,7 +267,9 @@ class core_webservice_external extends external_api {
'userhomepage' => new external_value(PARAM_INT, 'userhomepage' => new external_value(PARAM_INT,
'the default home page for the user: 0 for the site home, 1 for dashboard', 'the default home page for the user: 0 for the site home, 1 for dashboard',
VALUE_OPTIONAL), VALUE_OPTIONAL),
'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),
'usercalendartype' => new external_value(PARAM_PLUGIN, 'Calendar typed used by the user.', VALUE_OPTIONAL),
) )
); );
} }

View file

@ -122,6 +122,12 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
$this->assertEquals(true, $siteinfo['usercanmanageownfiles']); $this->assertEquals(true, $siteinfo['usercanmanageownfiles']);
$this->assertEquals(HOMEPAGE_MY, $siteinfo['userhomepage']); $this->assertEquals(HOMEPAGE_MY, $siteinfo['userhomepage']);
$this->assertEquals($CFG->calendartype, $siteinfo['sitecalendartype']);
if (!empty($USER->calendartype)) {
$this->assertEquals($USER->calendartype, $siteinfo['usercalendartype']);
} else {
$this->assertEquals($CFG->calendartype, $siteinfo['usercalendartype']);
}
// Now as admin. // Now as admin.
$this->setAdminUser(); $this->setAdminUser();

View file

@ -3,6 +3,11 @@ 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.4 ===
* External function core_webservice_external::get_site_info() now returns the calendar type used in the site and
by the user in the sitecalendartype and usercalendartype fields.
=== 3.2 === === 3.2 ===
* webservice->get_external_functions now returns the external function list ordered by name ASC. * webservice->get_external_functions now returns the external function list ordered by name ASC.