Skip to content

Commit

Permalink
MDL-42767 notes: Delete notes on a course delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal committed Nov 18, 2013
1 parent 1157cc9 commit d39f1ca
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -2267,5 +2267,19 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2013051402.12); 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; return true;
} }
4 changes: 4 additions & 0 deletions lib/moodlelib.php
Expand Up @@ -4781,6 +4781,7 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
require_once($CFG->dirroot.'/tag/coursetagslib.php'); require_once($CFG->dirroot.'/tag/coursetagslib.php');
require_once($CFG->dirroot.'/comment/lib.php'); require_once($CFG->dirroot.'/comment/lib.php');
require_once($CFG->dirroot.'/rating/lib.php'); require_once($CFG->dirroot.'/rating/lib.php');
require_once($CFG->dirroot.'/notes/lib.php');


// Handle course badges. // Handle course badges.
badges_handle_course_deletion($courseid); badges_handle_course_deletion($courseid);
Expand Down Expand Up @@ -4943,6 +4944,9 @@ function remove_course_contents($courseid, $showfeedback = true, array $options
// filters be gone! // filters be gone!
filter_delete_all_for_context($coursecontext->id); filter_delete_all_for_context($coursecontext->id);


// Notes, you shall not pass!
note_delete_all($course->id);

// die comments! // die comments!
comment::delete_comments($coursecontext->id); comment::delete_comments($coursecontext->id);


Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -29,7 +29,7 @@


defined('MOODLE_INTERNAL') || die(); 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 // RR = release increments - 00 in DEV branches
// .XX = incremental changes // .XX = incremental changes


Expand Down

0 comments on commit d39f1ca

Please sign in to comment.