diff options
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/block_manager.php | 21 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 13 | ||||
-rw-r--r-- | modules/gallery/helpers/module.php | 6 |
3 files changed, 39 insertions, 1 deletions
diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php index 233e4f2e..f26c3660 100644 --- a/modules/gallery/helpers/block_manager.php +++ b/modules/gallery/helpers/block_manager.php @@ -32,12 +32,33 @@ class block_manager_Core { self::set_active($location, $blocks); } + static function activate_sidebar_blocks($module_name) { + $block_class = "{$module_name}_block"; + if (method_exists($block_class, "get_site_list")) { + $blocks = call_user_func(array($block_class, "get_site_list")); + Kohana::log("error", Kohana::debug($blocks)); + foreach (array_keys($blocks) as $block_id) { + self::add("site.sidebar", $module_name, $block_id); + } + } + } + static function remove($location, $block_id) { $blocks = self::get_active($location); unset($blocks[$block_id]); self::set_active($location, $blocks); } + static function deactivate_sidebar_blocks($module_name) { + $block_class = "{$module_name}_block"; + if (method_exists($block_class, "get_site_list")) { + $blocks = call_user_func(array($block_class, "get_site_list")); + foreach (array_keys($blocks) as $block_id) { + self::remove("site.sidebar", $module_name, $block_id); + } + } + } + static function get_available_admin_blocks() { return self::_get_blocks("get_admin_list"); } diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 9e4e3c35..b1ea1f19 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -268,7 +268,7 @@ class gallery_installer { module::set_var("gallery", "show_credits", 1); // @todo this string needs to be picked up by l10n_scanner module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>"); - module::set_version("gallery", 14); + module::set_version("gallery", 15); } static function upgrade($version) { @@ -382,6 +382,17 @@ class gallery_installer { module::set_version("gallery", $version = 14); } + if ($version == 14) { + $sidebar_blocks = block_manager::get_active("site.sidebar"); + if (empty($sidebar_blocks)) { + $available_blocks = block_manager::get_available_site_blocks(); + foreach (array_keys(block_manager::get_available_site_blocks()) as $id) { + $sidebar_blocks[] = explode(":", $id); + } + block_manager::set_active("site.sidebar", $sidebar_blocks); + } + module::set_version("gallery", $version = 15); + } } static function uninstall() { diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index a27fdbc5..fe37f4f9 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -195,6 +195,9 @@ class module_Core { module::load_modules(); graphics::activate_rules($module_name); + + block_manager::activate_sidebar_blocks($module_name); + log::success( "module", t("Activated module %module_name", array("module_name" => $module_name))); } @@ -219,6 +222,9 @@ class module_Core { module::load_modules(); graphics::deactivate_rules($module_name); + + block_manager::deactivate_sidebar_blocks($module_name); + log::success( "module", t("Deactivated module %module_name", array("module_name" => $module_name))); } |