Commit ac881779 authored by Sam Hemelryk's avatar Sam Hemelryk
Browse files

Merge branch 'MDL-32827-master' of git://github.com/ankitagarwal/moodle

parents 1b77cda0 f14f9842
......@@ -1769,6 +1769,23 @@ class restore_calendarevents_structure_step extends restore_structure_step {
return;
}
}
// Handle events with empty eventtype //MDL-32827
if(empty($data->eventtype)) {
if ($data->courseid == $SITE->id) { // Site event
$data->eventtype = "site";
} else if ($data->courseid != 0 && $data->groupid == 0 && ($data->modulename == 'assignment' || $data->modulename == 'assign')) {
// Course assingment event
$data->eventtype = "due";
} else if ($data->courseid != 0 && $data->groupid == 0) { // Course event
$data->eventtype = "course";
} else if ($data->groupid) { // Group event
$data->eventtype = "group";
} else if ($data->userid) { // User event
$data->eventtype = "user";
} else {
return;
}
}
$params = array(
'name' => $data->name,
......
......@@ -85,7 +85,7 @@ defined('MOODLE_INTERNAL') || die();
* @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
......@@ -1069,5 +1069,17 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012072401.00);
}
if ($oldversion < 2012072600.01) {
// Handle events with empty eventtype //MDL-32827
$DB->set_field('event', 'eventtype', 'site', array('eventtype' => '', 'courseid' => $SITE->id));
$DB->set_field_select('event', 'eventtype', 'due', "eventtype = '' AND courseid != 0 AND groupid = 0 AND (modulename = 'assignment' OR modulename = 'assign')");
$DB->set_field_select('event', 'eventtype', 'course', "eventtype = '' AND courseid != 0 AND groupid = 0");
$DB->set_field_select('event', 'eventtype', 'group', "eventtype = '' AND groupid != 0");
$DB->set_field_select('event', 'eventtype', 'user', "eventtype = '' AND userid != 0");
// Main savepoint reached
upgrade_main_savepoint(true, 2012072600.01);
}
return true;
}
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment