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