Skip to content

Commit

Permalink
Merge branch 'MDL-59921-master' of git://github.com/lameze/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Oct 11, 2017
2 parents 5443212 + 0108fdf commit 8c0f6e5
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions calendar/classes/local/event/mappers/create_update_form_mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,7 @@ public function from_legacy_event_to_data(\calendar_event $legacyevent) {
public function from_data_to_event_properties(\stdClass $data) {
$properties = clone($data);

// Undo the form definition work around to allow us to have two different
// course selectors present depending on which event type the user selects.
if ($data->eventtype == 'course') {
// Default course id if none is set.
if (!isset($properties->courseid)) {
if ($properties->eventtype === 'site') {
$properties->courseid = SITEID;
} else {
$properties->courseid = 0;
}
} else {
$properties->courseid = $data->courseid;
}
} else if ($data->eventtype == 'group') {
if ($data->eventtype == 'group') {
if (isset($data->groupcourseid)) {
$properties->courseid = $data->groupcourseid;
unset($properties->groupcourseid);
Expand All @@ -113,6 +100,17 @@ public function from_data_to_event_properties(\stdClass $data) {
list($courseid, $groupid) = explode('-', $data->groupid);
$properties->groupid = $groupid;
}
} else {
// Default course id if none is set.
if (empty($properties->courseid)) {
if ($properties->eventtype == 'site') {
$properties->courseid = SITEID;
} else {
$properties->courseid = 0;
}
} else {
$properties->courseid = $data->courseid;
}
}

// Decode the form fields back into valid event property.
Expand Down

0 comments on commit 8c0f6e5

Please sign in to comment.