Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-32827 calendar: Fixining calender entries with no eventtype

  • Loading branch information...
commit fcda7dbb893af11093422abde70439cab232ecbc 1 parent 6975216
Ankit Agarwal ankitagarwal authored
Showing with 22 additions and 1 deletion.
  1. +22 −1 lib/db/upgrade.php
23 lib/db/upgrade.php
View
@@ -85,7 +85,7 @@
* @return bool always true
*/
function xmldb_main_upgrade($oldversion) {
- global $CFG, $USER, $DB, $OUTPUT;
+ global $CFG, $USER, $DB, $OUTPUT, $SITE;
require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions
@@ -923,5 +923,26 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012062501.04);
}
+ if ($oldversion < 2012062501.06) {
+ $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, 2012062501.06);
+ }
+
return true;
}
Please sign in to comment.
Something went wrong with that request. Please try again.