918ee5d98ad31d559d2c0b679ddf33e0e42e46bf
[project/panels.git] / panels_mini / panels_mini.install
1 <?php
2 // $Id$
3
4 /**
5 * Implementation of hook_schema().
6 */
7 function panels_mini_schema() {
8 // This should always point to our 'current' schema. This makes it relatively easy
9 // to keep a record of schema as we make changes to it.
10 return panels_mini_schema_1();
11 }
12
13 /**
14 * Schema version 1 for Panels in D6.
15 */
16 function panels_mini_schema_1() {
17 $schema = array();
18
19 $schema['panels_mini'] = array(
20 'fields' => array(
21 'pid' => array(
22 'type' => 'serial',
23 'not null' => TRUE,
24 ),
25 'name' => array(
26 'type' => 'varchar',
27 'length' => '255',
28 ),
29 'category' => array(
30 'type' => 'varchar',
31 'length' => '64',
32 ),
33 'did' => array(
34 'type' => 'int',
35 ),
36 'title' => array(
37 'type' => 'varchar',
38 'length' => '128',
39 ),
40 'requiredcontexts' => array(
41 'type' => 'text',
42 'size' => 'big',
43 ),
44 'contexts' => array(
45 'type' => 'text',
46 'size' => 'big',
47 ),
48 'relationships' => array(
49 'type' => 'text',
50 'size' => 'big',
51 ),
52 ),
53 'primary key' => array('pid'),
54 'unique keys' => array(
55 'name' => array('name'),
56 ),
57 );
58
59 return $schema;
60 }
61
62 /**
63 * Implementation of hook_uninstall().
64 */
65 function panels_mini_install() {
66 drupal_install_schema('panels_mini');
67 }
68
69 /**
70 * Implementation of hook_uninstall().
71 */
72 function panels_mini_uninstall() {
73 $result = db_query("SELECT * FROM {panels_mini} ORDER BY title");
74 $panels_exists = db_table_exists('panels_display');
75 while ($panel_mini = db_fetch_object($result)) {
76 // Delete all associated displays.
77 if (!function_exists('panels_delete_display')) {
78 require_once drupal_get_path('module', 'panels') .'/panels.module';
79 }
80 if ($panels_exists) {
81 panels_delete_display($panel_mini->did);
82 }
83
84 // Delete all configured blocks.
85 db_query("DELETE FROM {blocks} WHERE module = 'panels_mini' AND delta = %d", $panel_mini->pid);
86 }
87
88 // Finally, delete all mini panels.
89 drupal_install_schema('panels_mini');
90 }
91