Permalink
Browse files

MDL-42767 notes: Delete notes on a course delete

  • Loading branch information...
1 parent 1157cc9 commit d39f1ca2a5e8fa53f15b299a380eb8f44a6edb17 @ankitagarwal ankitagarwal committed Nov 8, 2013
Showing with 19 additions and 1 deletion.
  1. +14 −0 lib/db/upgrade.php
  2. +4 −0 lib/moodlelib.php
  3. +1 −1 version.php
View
@@ -2267,5 +2267,19 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013051402.12);
}
+ if ($oldversion < 2013051403.02) {
+
+ // Delete notes of deleted courses.
+ $sql = "DELETE FROM {post}
+ WHERE NOT EXISTS (SELECT {course}.id FROM {course}
+ WHERE {course}.id = {post}.courseid)
+ AND {post}.module = ?";
+ $DB->execute($sql, array('notes'));
+
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2013051403.02);
+ }
+
+
return true;
}
View
@@ -4781,6 +4781,7 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
require_once($CFG->dirroot.'/tag/coursetagslib.php');
require_once($CFG->dirroot.'/comment/lib.php');
require_once($CFG->dirroot.'/rating/lib.php');
+ require_once($CFG->dirroot.'/notes/lib.php');
// Handle course badges.
badges_handle_course_deletion($courseid);
@@ -4943,6 +4944,9 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
// filters be gone!
filter_delete_all_for_context($coursecontext->id);
+ // Notes, you shall not pass!
+ note_delete_all($course->id);
+
// die comments!
comment::delete_comments($coursecontext->id);
View
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2013051403.01; // 20130514 = branching date YYYYMMDD - do not modify!
+$version = 2013051403.02; // 20130514 = branching date YYYYMMDD - do not modify!
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

0 comments on commit d39f1ca

Please sign in to comment.