Skip to content

Commit

Permalink
MDL-32827 calendar: Fixining calender entries with no eventtype
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal committed Jul 27, 2012
1 parent 55a568f commit 3713514
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion lib/db/upgrade.php
Expand Up @@ -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

Expand Down Expand Up @@ -1069,5 +1069,25 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012072401.00);
}

if ($oldversion < 2012072600.01) {
$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, 2012072600.01);
}
return true;
}
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();


$version = 2012072600.00; // YYYYMMDD = weekly release date of this DEV branch
$version = 2012072600.01; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

Expand Down

0 comments on commit 3713514

Please sign in to comment.