summaryrefslogtreecommitdiffstats
path: root/panels_mini/panels_mini.install
blob: 6b44cefa453ad6ef931fae048ed873d317faa760 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
// $Id$

/**
 * Implementation of hook_schema().
 */
function panels_mini_schema() {
  // This should always point to our 'current' schema. This makes it relatively easy
  // to keep a record of schema as we make changes to it.
  return panels_mini_schema_1();
}

/**
 * Schema version 1 for Panels in D6.
 */
function panels_mini_schema_1() {
  $schema = array();

  $schema['panels_mini'] = array(
    'fields' => array(
      'pid' => array(
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'name' => array(
        'type' => 'varchar',
        'length' => '255',
      ),
      'category' => array(
        'type' => 'varchar',
        'length' => '64',
      ),
      'did' => array(
        'type' => 'int',
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => '128',
      ),
      'requiredcontexts' => array(
        'type' => 'text',
        'size' => 'big',
      ),
      'contexts' => array(
        'type' => 'text',
        'size' => 'big',
      ),
      'relationships' => array(
        'type' => 'text',
        'size' => 'big',
      ),
    ),
    'primary key' => array('pid'),
    'unique keys' => array(
      'name' => array('name'),
    ),
  );

  return $schema;
}

/**
 * Implementation of hook_install().
 */
function panels_mini_install() {
  drupal_install_schema('panels_mini');
}

/**
 * Implementation of hook_uninstall().
 */
function panels_mini_uninstall() {
  $result = db_query("SELECT * FROM {panels_mini} ORDER BY title");
  $panels_exists = db_table_exists('panels_display');
  while ($panel_mini = db_fetch_object($result)) {
    // Delete all associated displays.
    if (!function_exists('panels_delete_display')) {
      require_once drupal_get_path('module', 'panels') .'/panels.module';
    }
    if ($panels_exists) {
      panels_delete_display($panel_mini->did);
    }

    // Delete all configured blocks.
    db_query("DELETE FROM {blocks} WHERE module = 'panels_mini' AND delta = %d", $panel_mini->pid);
  }

  // Finally, delete all mini panels.
  drupal_uninstall_schema('panels_mini');
}