Example #1
0
 /**
  * Install a module.  This will call <module>_installer::install(), which is responsible for
  * creating database tables, setting module variables and calling module::set_version().
  * Note that after installing, the module must be activated before it is available for use.
  * @param string $module_name
  */
 static function install($module_name)
 {
     module::_add_to_path($module_name);
     $installer_class = "{$module_name}_installer";
     if (class_exists($installer_class) && method_exists($installer_class, "install")) {
         call_user_func_array(array($installer_class, "install"), array());
     }
     module::set_version($module_name, module::available()->{$module_name}->code_version);
     // Set the weight of the new module, which controls the order in which the modules are
     // loaded. By default, new modules are installed at the end of the priority list.  Since the
     // id field is monotonically increasing, the easiest way to guarantee that is to set the weight
     // the same as the id.  We don't know that until we save it for the first time
     $module = ORM::factory("module")->where("name", "=", $module_name)->find();
     if ($module->loaded()) {
         $module->weight = $module->id;
         $module->save();
     }
     module::load_modules();
     // Now the module is installed but inactive, so don't leave it in the active path
     module::_remove_from_path($module_name);
     log::success("module", t("Installed module %module_name", array("module_name" => $module_name)));
 }
Example #2
0
 /**
  * Install a module.  This will call <module>_installer::install(), which is responsible for
  * creating database tables, setting module variables and calling module::set_version().
  * Note that after installing, the module must be activated before it is available for use.
  * @param string $module_name
  */
 static function install($module_name)
 {
     module::_add_to_path($module_name);
     $installer_class = "{$module_name}_installer";
     if (method_exists($installer_class, "install")) {
         call_user_func_array(array($installer_class, "install"), array());
     } else {
         module::set_version($module_name, 1);
     }
     module::load_modules();
     // Now the module is installed but inactive, so don't leave it in the active path
     module::_remove_from_path($module_name);
     log::success("module", t("Installed module %module_name", array("module_name" => $module_name)));
 }