MDL-18375 calendar: only display the choice of calendar types if there is more than one

This commit is contained in:
Mark Nelson
2013-09-05 18:32:16 +08:00
parent df01e4c748
commit df5d27d892
2 changed files with 14 additions and 5 deletions
+9 -4
View File
@@ -199,10 +199,15 @@ class course_edit_form extends moodleform {
$mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
$mform->setDefault('lang', $courseconfig->lang);
$calendartypes = array();
$calendartypes[''] = get_string('forceno');
$calendartypes += \core_calendar\type_factory::get_list_of_calendar_types();
$mform->addElement('select', 'calendartype', get_string('forcecalendartype', 'calendar'), $calendartypes);
// Multi-Calendar Support - see MDL-18375.
$calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
// We do not want to show this option unless there is more than one calendar type to display.
if (count($calendartypes) > 1) {
$calendars = array();
$calendars[''] = get_string('forceno');
$calendars += $calendartypes;
$mform->addElement('select', 'calendartype', get_string('forcecalendartype', 'calendar'), $calendars);
}
$options = range(0, 10);
$mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);
+5 -1
View File
@@ -263,7 +263,11 @@ function useredit_shared_definition(&$mform, $editoroptions = null, $filemanager
$mform->setDefault('lang', $CFG->lang);
// Multi-Calendar Support - see MDL-18375.
$mform->addElement('select', 'calendartype', get_string('preferredcalendar', 'calendar'), \core_calendar\type_factory::get_list_of_calendar_types());
$calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
// We do not want to show this option unless there is more than one calendar type to display.
if (count($calendartypes) > 1) {
$mform->addElement('select', 'calendartype', get_string('preferredcalendar', 'calendar'), $calendartypes);
}
if (!empty($CFG->allowuserthemes)) {
$choices = array();