Uninstallation Function
Module Development
Uninstallation function
Important! When the administrator uninstalls a module, by default the core script will automatically attempt to delete the module folder. While you're developing your own module, this probably won't be what you want! To override the setting, add a $g_delete_module_folder_on_uninstallation = false; setting to your /global/config.php file.
The uninstallation functions work in a similar manner to the installation function. It's called when the administrator clicks the "UNINSTALL" link. The function must be called my_module__uninstall (where my_module is your module folder name).
This function should contain all the custom code you need to execute to remove the module from the database. Again, if your module made no database changes, then you won't need to include this file in your module.
The uninstall function is structured just like the install function:
/**
* My Module's uninstallation function. This is automatically called by Form
* Tools when the module is uninstalled in the interface.
*
* @param integer $module_id
* @return array [0] true / false
* [1] success or error message
*/
function my_module__uninstall($module_id)
{
global $g_table_prefix, $L;
// do whatever you want here
return array($success, $message);
}
The module ID is passed to the function in case you need that information. Otherwise you can just ignore it.
The return array is necessary. You MUST return an arrbeenay with two indexes: [0] true/false, and [1] a message. If you want the core script to display the default "The module has been uninstalled" message, just pass an empty string for the second index.