From 81eaf1e46cb1646bf6b5d5c2f86ea3b3c7a0bd06 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Wed, 30 Sep 2009 17:30:01 -0700 Subject: Add functionality to activate sidebar blocks when the module is activated and deactivate the sidebar blocks when the module is deactivated. --- modules/gallery/helpers/block_manager.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'modules/gallery/helpers/block_manager.php') diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php index 233e4f2e..906a251d 100644 --- a/modules/gallery/helpers/block_manager.php +++ b/modules/gallery/helpers/block_manager.php @@ -32,12 +32,35 @@ 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 $id) { + list ($unused, $block_id) = explode(":", $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 $id) { + list ($unused, $block_id) = explode(":", $id); + self::remove("site.sidebar", $module_name, $block_id); + } + } + } + static function get_available_admin_blocks() { return self::_get_blocks("get_admin_list"); } -- cgit v1.2.3