56430212ce180501eba8858ca844c8148cbea883
[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 'export' => array(
21 'identifier' => 'mini',
22 'load callback' => 'panels_mini_load',
23 'load all callback' => 'panels_mini_load_all',
24 'save callback' => 'panels_mini_save',
25 'delete callback' => 'panels_mini_delete',
26 'export callback' => 'panels_mini_export',
27 'api' => array(
28 'owner' => 'panels_mini',
29 'api' => 'panels_default',
30 'minimum_version' => 1,
31 'current_version' => 1,
32 ),
33 ),
34 'fields' => array(
35 'pid' => array(
36 'type' => 'serial',
37 'not null' => TRUE,
38 'no export' => TRUE,
39 'description' => 'The primary key for uniqueness.',
40 ),
41 'name' => array(
42 'type' => 'varchar',
43 'length' => '255',
44 'description' => 'The unique name of the mini panel.',
45 ),
46 'category' => array(
47 'type' => 'varchar',
48 'length' => '64',
49 'description' => 'The category this mini panel appears in on the add content pane.',
50 ),
51 'did' => array(
52 'type' => 'int',
53 'no export' => TRUE,
54 'description' => 'The display ID of the panel.',
55 ),
56 'admin_title' => array(
57 'type' => 'varchar',
58 'length' => '128',
59 'description' => 'The administrative title of the mini panel.',
60 ),
61 'admin_description' => array(
62 'type' => 'text',
63 'size' => 'big',
64 'description' => 'Administrative title of this mini panel.',
65 'object default' => '',
66 ),
67 'requiredcontexts' => array(
68 'type' => 'text',
69 'size' => 'big',
70 'serialize' => TRUE,
71 'object default' => array(),
72 'description' => 'An array of required contexts.',
73 ),
74 'contexts' => array(
75 'type' => 'text',
76 'size' => 'big',
77 'serialize' => TRUE,
78 'object default' => array(),
79 'description' => 'An array of contexts embedded into the panel.',
80 ),
81 'relationships' => array(
82 'type' => 'text',
83 'size' => 'big',
84 'serialize' => TRUE,
85 'object default' => array(),
86 'description' => 'An array of relationships embedded into the panel.',
87 ),
88 ),
89 'primary key' => array('pid'),
90 'unique keys' => array(
91 'name' => array('name'),
92 ),
93 );
94
95 return $schema;
96 }
97
98 /**
99 * Implementation of hook_uninstall().
100 */
101 function panels_mini_uninstall() {
102 $panels_exists = db_table_exists('panels_display');
103
104 $result = db_query("SELECT * FROM {panels_mini}");
105 $deltas = array();
106 foreach ($result as $panel_mini) {
107 // Delete all associated displays.
108 if (!function_exists('panels_delete_display')) {
109 require_once drupal_get_path('module', 'panels') .'/panels.module';
110 }
111 if ($panels_exists) {
112 panels_delete_display($panel_mini->did);
113 }
114
115 $deltas[] = $panel_mini->pid;
116 }
117
118 if ($deltas) {
119 // Delete all configured blocks.
120 db_delete('block')
121 ->condition('module', 'panels_mini')
122 ->condition('delta', $deltas)
123 ->execute();
124 }
125 }