Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-32827 calendar: Fixining calender entries with no eventtype

  • Loading branch information...
commit 7a5bbcf7f2e68c274013a88a68f4fea9a87b749f 1 parent dd9274c
@ankitagarwal ankitagarwal authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 lib/db/upgrade.php
View
21 lib/db/upgrade.php
@@ -7121,5 +7121,26 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2011120504.03);
}
+ if ($oldversion < 2011120504.05) {
+ $rs = $DB->get_recordset('event', array( 'eventtype' => ''), '', 'id, courseid, groupid, userid, modulename');
+ foreach ($rs as $event) {
+ if ($event->courseid == $SITE->id) { // Site event
+ $DB->set_field('event', 'eventtype', 'site', array('id' => $event->id));
+ } else if ($event->courseid != 0 && $event->groupid == 0 && ($event->modulename == 'assignment' || $event->modulename == 'assign')) {
+ // Course assingment event
+ $DB->set_field('event', 'eventtype', 'due', array('id' => $event->id));
+ } else if ($event->courseid != 0 && $event->groupid == 0) { // Course event
+ $DB->set_field('event', 'eventtype', 'course', array('id' => $event->id));
+ } else if ($event->groupid) { // Group event
+ $DB->set_field('event', 'eventtype', 'group', array('id' => $event->id));
+ } else if ($event->userid) { // User event
+ $DB->set_field('event', 'eventtype', 'user', array('id' => $event->id));
+ }
+ }
+ $rs->close();
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2011120504.05);
+ }
+
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.