Skip to content

Commit

Permalink
MDL-48012 tool_recyclebin: used new hooks in core
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjnelson committed Mar 15, 2016
1 parent e78cd9b commit c27596c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 70 deletions.
65 changes: 0 additions & 65 deletions admin/tool/recyclebin/classes/observer.php

This file was deleted.

26 changes: 25 additions & 1 deletion admin/tool/recyclebin/lib.php
Expand Up @@ -131,4 +131,28 @@ function tool_recyclebin_extend_navigation_category_settings($navigation, $conte
}

$navigation->add_node($node);
}
}

/**
* Hook called before we delete a course module.
*
* @param \stdClass $cm The course module record.
*/
function tool_recyclebin_pre_course_module_delete($cm) {
if (\tool_recyclebin\course::is_enabled()) {
$recyclebin = new \tool_recyclebin\course($cm->course);
$recyclebin->store_item($cm);
}
}

/**
* Hook called before we delete a course.
*
* @param \stdClass $course The course record.
*/
function tool_recyclebin_pre_course_delete($course) {
if (\tool_recyclebin\category::is_enabled()) {
$recyclebin = new \tool_recyclebin\category($course->category);
$recyclebin->store_item($course);
}
}
4 changes: 2 additions & 2 deletions admin/tool/recyclebin/tests/category_test.php
Expand Up @@ -47,9 +47,9 @@ protected function setUp() {
}

/**
* Run a bunch of tests to make sure we capture courses.
* Check that our hook is called when a course is deleted.
*/
public function test_observer() {
public function test_hook() {
global $DB;

$this->assertEquals($this->before + 1, $DB->count_records('course'));
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/recyclebin/tests/course_test.php
Expand Up @@ -51,9 +51,9 @@ protected function setUp() {
}

/**
* Run a bunch of tests to make sure we capture mods.
* Check that our hook is called when an activity is deleted.
*/
public function test_observer() {
public function test_hook() {
global $DB;

$this->assertEquals($this->before + 1, $DB->count_records('course_modules'));
Expand Down

0 comments on commit c27596c

Please sign in to comment.