diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-13 09:14:39 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-13 09:14:39 -0800 |
commit | def88149ccf8b542b376b96dd25c52f2ec6920e1 (patch) | |
tree | 310ec0dfc5ea65dbfa68d3434ef7598d04b00857 /modules/gallery/helpers/block_manager.php | |
parent | ab37d89bba88de676123069e4f9072e3706c4dc0 (diff) |
Undo using the md5 hash of the module name and block_id, so duplicate blocks are no allowed again
Diffstat (limited to 'modules/gallery/helpers/block_manager.php')
-rw-r--r-- | modules/gallery/helpers/block_manager.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php index 980d1db5..d513abd9 100644 --- a/modules/gallery/helpers/block_manager.php +++ b/modules/gallery/helpers/block_manager.php @@ -28,7 +28,7 @@ class block_manager_Core { static function add($location, $module_name, $block_id) { $blocks = self::get_active($location); - $blocks[md5("$module_name:$block_id")] = array($module_name, $block_id); + $blocks[rand()] = array($module_name, $block_id); self::set_active($location, $blocks); } @@ -49,21 +49,29 @@ class block_manager_Core { self::set_active($location, $blocks); } + static function remove_blocks_for_module($location, $module_name) { + $blocks = self::get_active($location); + foreach ($blocks as $key => $block) { + if ($block[0] == $module_name) { + unset($blocks[$key]); + } + } + self::set_active($location, $blocks); + } + 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", md5("$module_name:$block_id")); + self::remove_blocks_for_module("site.sidebar", $module_name); } } 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")); - } + self::remove_blocks_for_module($location, $module_name); } } } |