Difference between revisions of "local/Recycle bin"

Jump to: navigation, search
m
m (added link to spanish translation)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Infobox plugin
+
#redirect [[Recycle bin]]
|type = General (local)
 
|entry = https://moodle.org/plugins/view/local_recyclebin
 
|tracker = https://github.com/unikent/moodle-local_recyclebin/issues
 
|discussion = https://moodle.org/plugins/view/local_recyclebin
 
|maintainer = [[User:Skylar Kelty|Skylar Kelty]]
 
|float = right
 
}}
 
This is a [[:Category:Contributed_code|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.
 
 
 
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`:
 
<code diff>
 
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);
 
</code>
 
 
 
== Manual Patching ==
 
 
 
* First, open /course/lib.php in a text editor.
 
 
 
[[File:recyclebin_courselibphpineditor.png|400px]]
 
 
 
* You need to find these lines within the course_delete_module function:
 
<code php>
 
// Get the course module.
 
if (!$cm = $DB->get_record('course_modules', array('id' => $cmid))) {
 
    return true;
 
}
 
</code>
 
* After those two lines, add the following:
 
<code php>
 
// Notify the recycle bin plugin.
 
\local_recyclebin\Observer::pre_cm_delete($cm);
 
</code>
 
 
 
Your modified file must look exactly like this (around lines 1658 and 1659):
 
 
 
[[File:recyclebin_courselibphpedited.png|400px]]
 
 
 
* You will then have a Recycle bin available inside the Administration block:
 
 
 
[[File:Recycle bin is available.png|300px]]
 
  
 
[[es:local/Recycle bin]]
 
[[es:local/Recycle bin]]

Latest revision as of 15:40, 12 June 2016

Redirect to: