]> git.mjollnir.org Git - moodle.git/commitdiff
Added an install hook ... any function called modulename_install() will be run when...
authormoodler <moodler>
Mon, 18 Jun 2007 03:59:47 +0000 (03:59 +0000)
committermoodler <moodler>
Mon, 18 Jun 2007 03:59:47 +0000 (03:59 +0000)
MDL-10108

lib/adminlib.php

index b8d41fb423a8c23a449d7b871932ded475a1917c..eb349c3ce0ebd1628f9b758ec06bbd746d0eb82f 100644 (file)
@@ -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 '<hr />';
                 } 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();