diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/helpers/block_manager.php | 18 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 14 | ||||
-rw-r--r-- | modules/gallery/helpers/module.php | 4 | ||||
-rw-r--r-- | modules/gallery/module.info | 2 |
4 files changed, 30 insertions, 8 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")); + } } } } diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 2eb02546..26cd14f5 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", 16); + module::set_version("gallery", 17); } static function upgrade($version) { @@ -398,6 +398,18 @@ class gallery_installer { module::set_var("gallery", "identity_provider", "user"); module::set_version("gallery", $version = 16); } + + if ($version == 16) { + foreach (array("dashboard_sidebar", "dashboard_center", "site.sidebar") as $location) { + $blocks = block_manager::get_active($location); + $new_blocks = array(); + foreach ($blocks as $block) { + $new_blocks[md5("{$block[0]}:{$block[1]}")] = $block; + } + block_manager::set_active($location, $new_blocks); + } + module::set_version("gallery", $version = 17); + } } static function uninstall() { diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index da334370..e6c196ce 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -211,7 +211,7 @@ class module_Core { graphics::activate_rules($module_name); - block_manager::activate_sidebar_blocks($module_name); + block_manager::activate_blocks($module_name); log::success( "module", t("Activated module %module_name", array("module_name" => $module_name))); @@ -238,7 +238,7 @@ class module_Core { graphics::deactivate_rules($module_name); - block_manager::deactivate_sidebar_blocks($module_name); + block_manager::deactivate_blocks($module_name); log::success( "module", t("Deactivated module %module_name", array("module_name" => $module_name))); diff --git a/modules/gallery/module.info b/modules/gallery/module.info index e21431a7..2a35b809 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 16 +version = 17 |