mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-63196 calendar: add missing option to export category events
This commit is contained in:
parent
3271c39c74
commit
f19f6cceaf
@ -49,6 +49,7 @@ class core_calendar_export_form extends moodleform {
|
||||
|
||||
$export = array();
|
||||
$export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventsall', 'calendar'), 'all');
|
||||
$export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventsrelatedtocategories', 'calendar'), 'categories');
|
||||
$export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventsrelatedtocourses', 'calendar'), 'courses');
|
||||
$export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventsrelatedtogroups', 'calendar'), 'groups');
|
||||
$export[] = $mform->createElement('radio', 'exportevents', '', get_string('eventspersonal', 'calendar'), 'user');
|
||||
|
@ -40,8 +40,8 @@ $time = optional_param('preset_time', 'weeknow', PARAM_ALPHA);
|
||||
$now = $calendartype->timestamp_to_date_array(time());
|
||||
|
||||
// Let's see if we have sufficient and correct data
|
||||
$allowed_what = array('all', 'user', 'groups', 'courses');
|
||||
$allowed_time = array('weeknow', 'weeknext', 'monthnow', 'monthnext', 'recentupcoming', 'custom');
|
||||
$allowedwhat = ['all', 'user', 'groups', 'courses', 'categories'];
|
||||
$allowedtime = ['weeknow', 'weeknext', 'monthnow', 'monthnext', 'recentupcoming', 'custom'];
|
||||
|
||||
if (!empty($generateurl)) {
|
||||
$authtoken = sha1($user->id . $user->password . $CFG->calendar_exportsalt);
|
||||
@ -56,9 +56,9 @@ if (!empty($generateurl)) {
|
||||
redirect($link->out());
|
||||
die;
|
||||
}
|
||||
|
||||
$paramcategory = false;
|
||||
if(!empty($what) && !empty($time)) {
|
||||
if(in_array($what, $allowed_what) && in_array($time, $allowed_time)) {
|
||||
if(in_array($what, $allowedwhat) && in_array($time, $allowedtime)) {
|
||||
$courses = enrol_get_users_courses($user->id, true, 'id, visible, shortname');
|
||||
// Array of courses that we will pass to calendar_get_legacy_events() which
|
||||
// is initially set to the list of the user's courses.
|
||||
@ -78,6 +78,7 @@ if(!empty($what) && !empty($time)) {
|
||||
$courses[SITEID] = new stdClass;
|
||||
$courses[SITEID]->shortname = get_string('globalevents', 'calendar');
|
||||
$paramcourses[SITEID] = $courses[SITEID];
|
||||
$paramcategory = true;
|
||||
} else if ($what == 'groups') {
|
||||
$users = false;
|
||||
$paramcourses = array();
|
||||
@ -85,6 +86,11 @@ if(!empty($what) && !empty($time)) {
|
||||
$users = $user->id;
|
||||
$groups = false;
|
||||
$paramcourses = array();
|
||||
} else if ($what == 'categories') {
|
||||
$users = $user->id;
|
||||
$groups = false;
|
||||
$paramcourses = array();
|
||||
$paramcategory = true;
|
||||
} else {
|
||||
$users = false;
|
||||
$groups = false;
|
||||
@ -180,7 +186,9 @@ if(!empty($what) && !empty($time)) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
$events = calendar_get_legacy_events($timestart, $timeend, $users, $groups, array_keys($paramcourses), false);
|
||||
|
||||
$events = calendar_get_legacy_events($timestart, $timeend, $users, $groups, array_keys($paramcourses), false, true,
|
||||
$paramcategory);
|
||||
|
||||
$ical = new iCalendar;
|
||||
$ical->add_property('method', 'PUBLISH');
|
||||
|
@ -114,6 +114,7 @@ $string['eventsupdated'] = 'Events updated: {$a}';
|
||||
$string['eventsfor'] = '{$a} events';
|
||||
$string['eventskey'] = 'Events key';
|
||||
$string['eventspersonal'] = 'My personal events';
|
||||
$string['eventsrelatedtocategories'] = 'Events related to categories';
|
||||
$string['eventsrelatedtocourses'] = 'Events related to courses';
|
||||
$string['eventsrelatedtogroups'] = 'Events related to groups';
|
||||
$string['eventstarttime'] = 'Start time';
|
||||
|
Loading…
x
Reference in New Issue
Block a user