Note: You are currently viewing documentation for Moodle 3.9. Up-to-date documentation for the latest stable version of Moodle may be available here: local/Recycle bin.

local/Recycle bin: Difference between revisions

From MoodleDocs
mNo edit summary
(Added Moodle versions and translations available)
Line 11: Line 11:
This plugin adds a "recycle bin" for course modules to Moodle. The recycle bin stores course modules when they're deleted and provides an interface for users to restore them should they need to. It can be configured to automatically purge items after a configurable length of time.
This plugin adds a "recycle bin" for course modules to Moodle. The recycle bin stores course modules when they're deleted and provides an interface for users to restore them should they need to. It can be configured to automatically purge items after a configurable length of time.


==Moodle versions available==
This plugin works with Moodle 2.8 and 2.9
==Translations available==
This plugin has been [https://lang.moodle.org/ translated] to the following languages (as of August 26th 2015):
* es_mx Mexican Spanish
==Installation==
It requires a core hack as there is no pre-cm-deleted event, you will need to add a line to '/course/lib.php' (function course_delete_module), right after the first "if()".
It requires a core hack as there is no pre-cm-deleted event, you will need to add a line to '/course/lib.php' (function course_delete_module), right after the first "if()".


== Automatic Patching ==
=== Automatic Patching ===


Simply apply this diff using `patch`:
Simply apply this diff using `patch`:
Line 32: Line 40:
</code>
</code>


== Manual Patching ==
=== Manual Patching ===


* First, open /course/lib.php in a text editor.
* First, open /course/lib.php in a text editor.

Revision as of 12:51, 26 August 2015

This is a contributed (third party) plugin for Moodle written by Skylar Kelty and shared on Moodle.org

This plugin adds a "recycle bin" for course modules to Moodle. The recycle bin stores course modules when they're deleted and provides an interface for users to restore them should they need to. It can be configured to automatically purge items after a configurable length of time.

Moodle versions available

This plugin works with Moodle 2.8 and 2.9

Translations available

This plugin has been translated to the following languages (as of August 26th 2015):

  • es_mx Mexican Spanish

Installation

It requires a core hack as there is no pre-cm-deleted event, you will need to add a line to '/course/lib.php' (function course_delete_module), right after the first "if()".

Automatic Patching

Simply apply this diff using `patch`: diff --git a/course/lib.php b/course/lib.php index e49bdf1..5f8d6e6 100644 --- a/course/lib.php +++ b/course/lib.php @@ -1654,6 +1654,9 @@ function course_delete_module($cmid) {

        return true;
    }

+ // Notify the recycle bin plugin. + \local_recyclebin\Observer::pre_cm_delete($cm); +

    // Get the module context.
    $modcontext = context_module::instance($cm->id);

Manual Patching

  • First, open /course/lib.php in a text editor.

recyclebin courselibphpineditor.png

  • You need to find these lines within the course_delete_module function:

// Get the course module. if (!$cm = $DB->get_record('course_modules', array('id' => $cmid))) {

   return true;

}

  • After those two lines, add the following:

// Notify the recycle bin plugin. \local_recyclebin\Observer::pre_cm_delete($cm);

Your modified file must look exactly like this (around lines 1658 and 1659):

recyclebin courselibphpedited.png

  • You will then have a Recycle bin available inside the Administration block:

Recycle bin is available.png