From d4b10cce5aa0ef7e0ec32d181c94bc07c98d91e2 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Mon, 1 Nov 2010 00:44:31 +0000 Subject: #950878 follow-up: Commit the dang install file. --- modules/dashboard/dashboard.install | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 modules/dashboard/dashboard.install diff --git a/modules/dashboard/dashboard.install b/modules/dashboard/dashboard.install new file mode 100644 index 000000000..1a80993c4 --- /dev/null +++ b/modules/dashboard/dashboard.install @@ -0,0 +1,79 @@ +fields('b', array('module', 'delta', 'region')) + ->condition('b.region', dashboard_regions(), 'IN') + ->execute(); + + foreach ($result as $block) { + $stashed_blocks[] = array( + 'module' => $block->module, + 'delta' => $block->delta, + 'region' => $block->region, + ); + } + variable_set('dashboard_stashed_blocks', $stashed_blocks); + + // Disable the dashboard blocks. + db_update('block') + ->fields(array( + 'status' => 0, + 'region' => BLOCK_REGION_NONE, + )) + ->condition('region', dashboard_regions(), 'IN') + ->execute(); +} + +/** + * Implements hook_enable(). + * + * Restores blocks to the dashboard that were there when the dashboard module + * was disabled. + */ +function dashboard_enable() { + global $theme_key; + if (!$stashed_blocks = variable_get('dashboard_stashed_blocks')) { + return; + } + if (!$admin_theme = variable_get('admin_theme')) { + drupal_theme_initialize(); + $admin_theme = $theme_key; + } + foreach ($stashed_blocks as $block) { + db_update('block') + ->fields(array( + 'status' => 1, + 'region' => $block['region'] + )) + ->condition('module', $block['module']) + ->condition('delta', $block['delta']) + ->condition('theme', $admin_theme) + ->condition('status', 0) + ->execute(); + } + variable_del('dashboard_stashed_blocks'); +} + +/** + * Implements hook_uninstall(). + */ +function dashboard_uninstall() { + variable_del('dashboard_stashed_blocks'); +} -- cgit v1.2.3