summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/block_manager.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-11-14 11:51:20 -0800
committerBharat Mediratta <bharat@menalto.com>2009-11-14 11:51:20 -0800
commit594742b7d1c9960f08253411f3d7c08532bddd7f (patch)
treeaee12e2775ec7cd5b9e2b8e6e841793050e36b26 /modules/gallery/helpers/block_manager.php
parentd12e3698e3e6a259f34ced2050e4343f54e130aa (diff)
parent670629fe10322ca3b996d2ec4206a1aa71ae449d (diff)
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules/gallery/helpers/block_manager.php')
-rw-r--r--modules/gallery/helpers/block_manager.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/modules/gallery/helpers/block_manager.php b/modules/gallery/helpers/block_manager.php
index 980d1db5..b003f1d8 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);
}
@@ -38,7 +38,7 @@ class block_manager_Core {
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::add("site.sidebar", $module_name, $block_id);
+ self::add("site_sidebar", $module_name, $block_id);
}
}
}
@@ -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);
}
}
}