From: moodler Date: Mon, 18 Jun 2007 03:59:47 +0000 (+0000) Subject: Added an install hook ... any function called modulename_install() will be run when... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=11e4a24ba90a43f66084e60a5cd66fc4a6157bc0;p=moodle.git Added an install hook ... any function called modulename_install() will be run when the module is installed MDL-10108 --- diff --git a/lib/adminlib.php b/lib/adminlib.php index b8d41fb423..eb349c3ce0 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -246,6 +246,8 @@ function upgrade_activity_modules($return) { $module->name = $mod; // The name MUST match the directory + include_once($fullmod.'/lib.php'); // defines upgrading and/or installing functions + if ($currmodule = get_record('modules', 'name', $module->name)) { if ($currmodule->version == $module->version) { // do nothing @@ -335,14 +337,27 @@ function upgrade_activity_modules($return) { } $db->debug = false; - /// Continue with the instalation, roles and other stuff + + /// Continue with the installation, roles and other stuff if ($status) { if ($module->id = insert_record('modules', $module)) { + + /// Capabilities if (!update_capabilities('mod/'.$module->name)) { error('Could not set up the capabilities for '.$module->name.'!'); } + /// Events events_update_definition('mod/'.$module->name); + + /// Run local install function if there is one + $installfunction = $module->name.'_install'; + if (function_exists($installfunction)) { + if (! $installfunction() ) { + notify('Encountered a problem running install function for '.$module->name.'!'); + } + } + notify(get_string('modulesuccess', '', $module->name), 'notifysuccess'); echo '
'; } else { @@ -355,8 +370,6 @@ function upgrade_activity_modules($return) { /// Check submodules of this module if necessary - include_once($fullmod.'/lib.php'); // defines upgrading function - $submoduleupgrade = $module->name.'_upgrade_submodules'; if (function_exists($submoduleupgrade)) { $submoduleupgrade();