Skip to content

Commit

Permalink
MDL-60468 calendar: fix event type defaults logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Oct 18, 2017
1 parent 9a316f3 commit 05187c5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions calendar/lib.php
Expand Up @@ -3225,11 +3225,16 @@ function calendar_output_fragment_event_form($args) {
true,
$data
);
if ($courseid != SITEID) {

// Let's check first which event types user can add.
calendar_get_allowed_types($allowed, $courseid);

// If the user is on course context and is allowed to add course events set the event type default to course.
if ($courseid != SITEID && !empty($allowed->courses)) {
$data['eventtype'] = 'course';
$data['courseid'] = $courseid;
$data['groupcourseid'] = $courseid;
} else if (!empty($categoryid)) {
} else if (!empty($categoryid) && !empty($allowed->category)) {
$data['eventtype'] = 'category';
$data['categoryid'] = $categoryid;
}
Expand Down

0 comments on commit 05187c5

Please sign in to comment.