How to : run additional script module level defined when uninstalling a module or a block ?

How to : run additional script module level defined when uninstalling a module or a block ?

by Valery Fremaux -
Number of replies: 3

What about additional records such as mnet services and RPC entries ? Would they be removed at uninstall time ?

Someone knows a code path to plugin some kind of "finalize()" feature in a module ?

Thanks.

Average of ratings: -
In reply to Valery Fremaux

Re: How to : run additional script module level defined when uninstalling a module or a block ?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Well, there is nothing on Development:Modules.

However, uninstalling modules is done by the delete link in admin/modules.php. If you look at the code there you will see:
 // Perform any custom uninstall tasks
 if (file_exists($CFG->dirroot . '/mod/' . $module->name . '/lib.php')) {
 require_once($CFG->dirroot . '/mod/' . $module->name . '/lib.php');
 $uninstallfunction = $module->name . '_uninstall';
 if (function_exists($uninstallfunction)) {
 if (! $uninstallfunction() ) {
 notify('Encountered a problem running uninstall function for '. $module->name.'!');
 }
 }
 }

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: How to : run additional script module level defined when uninstalling a module or a block ?

by Valery Fremaux -

Great !

just what I needed.

Thanks Tim.

In reply to Valery Fremaux

Re: How to : run additional script module level defined when uninstalling a module or a block ?

by Ger Tielemans -

Tim, I do not kown why (well, it is me smile), but when we restore an old course, we sometimes see Phantom modules in the course: you see modules but when you click on them they do not exist.

(By deleting the module with instance 0 in the table course_modules, I can clean the interface, but is that enough?)