summaryrefslogtreecommitdiff
path: root/modules/gallery
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-11-13 09:14:39 -0800
committerTim Almdal <tnalmdal@shaw.ca>2009-11-13 09:14:39 -0800
commitdef88149ccf8b542b376b96dd25c52f2ec6920e1 (patch)
tree310ec0dfc5ea65dbfa68d3434ef7598d04b00857 /modules/gallery
parentab37d89bba88de676123069e4f9072e3706c4dc0 (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')
-rw-r--r--modules/gallery/controllers/packager.php11
-rw-r--r--modules/gallery/helpers/block_manager.php18
-rw-r--r--modules/gallery/helpers/gallery_installer.php15
-rw-r--r--modules/gallery/module.info2
4 files changed, 39 insertions, 7 deletions
diff --git a/modules/gallery/controllers/packager.php b/modules/gallery/controllers/packager.php
index f0e35b2d..b2550603 100644
--- a/modules/gallery/controllers/packager.php
+++ b/modules/gallery/controllers/packager.php
@@ -73,6 +73,17 @@ class Packager_Controller extends Controller {
}
private function _dump_database() {
+ // We now have a clean install with just the packages that we want. Make sure that the
+ // database is clean too.
+ $i = 1;
+ foreach (array("dashboard_sidebar", "dashboard_center", "site.sidebar") as $key) {
+ $blocks = array();
+ foreach (unserialize(module::get_var("gallery", "blocks_{$key}")) as $rnd => $value) {
+ $blocks[++$i] = $value;
+ }
+ module::set_var("gallery", "blocks_{$key}", serialize($blocks));
+ }
+
$db = Database::instance();
$db->query("TRUNCATE {sessions}");
$db->query("TRUNCATE {logs}");
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);
}
}
}
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php
index 26cd14f5..2d4a1e04 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", 17);
+ module::set_version("gallery", 18);
}
static function upgrade($version) {
@@ -410,6 +410,19 @@ class gallery_installer {
}
module::set_version("gallery", $version = 17);
}
+
+ if ($version == 17) {
+ // Once published we can't go back so reset the keys to a random to allow duplicates
+ 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[rand()] = $block;
+ }
+ block_manager::set_active($location, $new_blocks);
+ }
+ module::set_version("gallery", $version = 18);
+ }
}
static function uninstall() {
diff --git a/modules/gallery/module.info b/modules/gallery/module.info
index 2a35b809..3a5d68b2 100644
--- a/modules/gallery/module.info
+++ b/modules/gallery/module.info
@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
-version = 17
+version = 18