diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-12 09:29:17 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-12 13:13:34 -0800 |
commit | 79f700ef9f79926d5e806bd48e5a6f99b6ecc5bb (patch) | |
tree | 53c7100e69da76a31e9ac8519f5ea5bc55488921 /modules/gallery/helpers/block_manager.php | |
parent | 3d8d2f71be68ce5bb267a54a36d6ab495c22e6b1 (diff) |
Change the keys of the block arrays in block manager to be a md5 hash of module_name:block_id. This allows easier lookup of blocks to remove when modules
are being deactivated. Change the module activation/deactivation to call (activate|deactivate)_blocks instead of just the sidebar blocks. This insures
that when a module is deactivated any admin dashboard blocks are removed as well the site sideboard blocks. Fix for ticket #876.
Diffstat (limited to 'modules/gallery/helpers/block_manager.php')
-rw-r--r-- | modules/gallery/helpers/block_manager.php | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php index 0e78661a..980d1db5 100644 --- a/modules/gallery/helpers/block_manager.php +++ b/modules/gallery/helpers/block_manager.php @@ -28,11 +28,12 @@ class block_manager_Core { static function add($location, $module_name, $block_id) { $blocks = self::get_active($location); - $blocks[rand()] = array($module_name, $block_id); + $blocks[md5("$module_name:$block_id")] = array($module_name, $block_id); + self::set_active($location, $blocks); } - static function activate_sidebar_blocks($module_name) { + static function activate_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")); @@ -48,12 +49,21 @@ class block_manager_Core { self::set_active($location, $blocks); } - static function deactivate_sidebar_blocks($module_name) { + static function deactivate_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); + self::remove("site.sidebar", md5("$module_name:$block_id")); + } + } + + if (method_exists($block_class, "get_admin_list")) { + $blocks = call_user_func(array($block_class, "get_admin_list")); + foreach (array("dashboard_sidebar", "dashboard_center") as $location) { + foreach (array_keys($blocks) as $block_id) { + self::remove($location, md5("$module_name:$block_id")); + } } } } |