Skip to content

Commit df5d27d

Browse files
committed
MDL-18375 calendar: only display the choice of calendar types if there is more than one
1 parent df01e4c commit df5d27d

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

course/edit_form.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,15 @@ function definition() {
199199
$mform->addElement('select', 'lang', get_string('forcelanguage'), $languages);
200200
$mform->setDefault('lang', $courseconfig->lang);
201201

202-
$calendartypes = array();
203-
$calendartypes[''] = get_string('forceno');
204-
$calendartypes += \core_calendar\type_factory::get_list_of_calendar_types();
205-
$mform->addElement('select', 'calendartype', get_string('forcecalendartype', 'calendar'), $calendartypes);
202+
// Multi-Calendar Support - see MDL-18375.
203+
$calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
204+
// We do not want to show this option unless there is more than one calendar type to display.
205+
if (count($calendartypes) > 1) {
206+
$calendars = array();
207+
$calendars[''] = get_string('forceno');
208+
$calendars += $calendartypes;
209+
$mform->addElement('select', 'calendartype', get_string('forcecalendartype', 'calendar'), $calendars);
210+
}
206211

207212
$options = range(0, 10);
208213
$mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options);

user/editlib.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,11 @@ function useredit_shared_definition(&$mform, $editoroptions = null, $filemanager
263263
$mform->setDefault('lang', $CFG->lang);
264264

265265
// Multi-Calendar Support - see MDL-18375.
266-
$mform->addElement('select', 'calendartype', get_string('preferredcalendar', 'calendar'), \core_calendar\type_factory::get_list_of_calendar_types());
266+
$calendartypes = \core_calendar\type_factory::get_list_of_calendar_types();
267+
// We do not want to show this option unless there is more than one calendar type to display.
268+
if (count($calendartypes) > 1) {
269+
$mform->addElement('select', 'calendartype', get_string('preferredcalendar', 'calendar'), $calendartypes);
270+
}
267271

268272
if (!empty($CFG->allowuserthemes)) {
269273
$choices = array();

0 commit comments

Comments
 (0)