Install, update and uninstall functions for the dashboard module.

File

modules/dashboard/dashboard.install
View source
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the dashboard module.
  5. */
  6. /**
  7. * Implements hook_disable().
  8. *
  9. * Stash a list of blocks enabled on the dashboard, so they can be re-enabled
  10. * if the dashboard is re-enabled. Then disable those blocks, since the
  11. * dashboard regions will no longer be defined.
  12. */
  13. function dashboard_disable() {
  14. // Stash a list of currently enabled blocks.
  15. $stashed_blocks = array();
  16. $result = db_select('block', 'b')
  17. ->fields('b', array('module', 'delta', 'region'))
  18. ->condition('b.region', dashboard_regions(), 'IN')
  19. ->execute();
  20. foreach ($result as $block) {
  21. $stashed_blocks[] = array(
  22. 'module' => $block->module,
  23. 'delta' => $block->delta,
  24. 'region' => $block->region,
  25. );
  26. }
  27. variable_set('dashboard_stashed_blocks', $stashed_blocks);
  28. // Disable the dashboard blocks.
  29. db_update('block')
  30. ->fields(array(
  31. 'status' => 0,
  32. 'region' => BLOCK_REGION_NONE,
  33. ))
  34. ->condition('region', dashboard_regions(), 'IN')
  35. ->execute();
  36. }
  37. /**
  38. * Implements hook_enable().
  39. *
  40. * Restores blocks to the dashboard that were there when the dashboard module
  41. * was disabled.
  42. */
  43. function dashboard_enable() {
  44. global $theme_key;
  45. if (!$stashed_blocks = variable_get('dashboard_stashed_blocks')) {
  46. return;
  47. }
  48. if (!$admin_theme = variable_get('admin_theme')) {
  49. drupal_theme_initialize();
  50. $admin_theme = $theme_key;
  51. }
  52. foreach ($stashed_blocks as $block) {
  53. db_update('block')
  54. ->fields(array(
  55. 'status' => 1,
  56. 'region' => $block['region']
  57. ))
  58. ->condition('module', $block['module'])
  59. ->condition('delta', $block['delta'])
  60. ->condition('theme', $admin_theme)
  61. ->condition('status', 0)
  62. ->execute();
  63. }
  64. variable_del('dashboard_stashed_blocks');
  65. }
  66. /**
  67. * Implements hook_uninstall().
  68. */
  69. function dashboard_uninstall() {
  70. variable_del('dashboard_stashed_blocks');
  71. }

Functions

Namesort descending Description
dashboard_disable Implements hook_disable().
dashboard_enable Implements hook_enable().
dashboard_uninstall Implements hook_uninstall().