diff options
| author | Romain LE DISEZ <romain.git@ledisez.net> | 2009-06-24 23:02:57 +0200 | 
|---|---|---|
| committer | Romain LE DISEZ <romain.git@ledisez.net> | 2009-06-24 23:02:57 +0200 | 
| commit | 6111272568a732465c330597a068a048f6705ef9 (patch) | |
| tree | f8829dfb4c4ee566a69f91d397e74e74aec56dbd /modules/gallery/helpers/module.php | |
| parent | de28b0350e5d5bf6c3e1eb5a9531298b08fd7cba (diff) | |
| parent | f56d372629df5b08a30d0182d4e1e7c97a44d79f (diff) | |
Merge commit 'upstream/master'
Conflicts:
	modules/comment/helpers/comment_installer.php
	modules/gallery/models/item.php
Diffstat (limited to 'modules/gallery/helpers/module.php')
| -rw-r--r-- | modules/gallery/helpers/module.php | 34 | 
1 files changed, 33 insertions, 1 deletions
| diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index dea8e22c..0d483206 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -107,7 +107,7 @@ class module_Core {    /**     * Install a module.  This will call <module>_installer::install(), which is responsible for -   * creating database tables, setting module variables and and calling module::set_version(). +   * 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     */ @@ -131,6 +131,38 @@ class module_Core {    }    /** +   * Upgrade a module.  This will call <module>_installer::upgrade(), which is responsible for +   * modifying database tables, changing module variables and calling module::set_version(). +   * Note that after upgrading, the module must be activated before it is available for use. +   * @param string $module_name +   */ +  static function upgrade($module_name) { +    $kohana_modules = Kohana::config("core.modules"); +    array_unshift($kohana_modules, MODPATH . $module_name); +    Kohana::config_set("core.modules",  $kohana_modules); + +    $version_before = module::get_version($module_name); +    $installer_class = "{$module_name}_installer"; +    if (method_exists($installer_class, "upgrade")) { +      call_user_func_array(array($installer_class, "upgrade"), array($version_before)); +    } +    module::load_modules(); + +    // Now the module is upgraded but inactive, so don't leave it in the active path +    array_shift($kohana_modules); +    Kohana::config_set("core.modules",  $kohana_modules); + +    $version_after = module::get_version($module_name); +    if ($version_before != $version_after) { +      log::success( +        "module", t("Upgraded module %module_name from %version_before to %version_after", +                    array("module_name" => $module_name, +                          "version_before" => $version_before, +                          "version_after" => $version_after))); +    } +  } + +  /**     * Activate an installed module.  This will call <module>_installer::activate() which should take     * any steps to make sure that the module is ready for use.  This will also activate any     * existing graphics rules for this module. | 
