| 1 |
<?php
|
| 2 |
// $Id: gmap_taxonomy.install,v 1.3 2008/07/15 21:16:54 bdragon Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* gmap_taxonomy install routines.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*/
|
| 12 |
function gmap_taxonomy_install() {
|
| 13 |
drupal_install_schema('gmap_taxonomy');
|
| 14 |
}
|
| 15 |
|
| 16 |
/**
|
| 17 |
* Implementation of hook_uninstall().
|
| 18 |
*/
|
| 19 |
function gmap_taxonomy_uninstall() {
|
| 20 |
drupal_uninstall_schema('gmap_taxonomy');
|
| 21 |
}
|
| 22 |
|
| 23 |
/**
|
| 24 |
* Implementation of hook_schema().
|
| 25 |
*/
|
| 26 |
function gmap_taxonomy_schema() {
|
| 27 |
$schema['gmap_taxonomy_term'] = array(
|
| 28 |
'fields' => array(
|
| 29 |
'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 30 |
'marker' => array('type' => 'varchar', 'length' => 32),
|
| 31 |
),
|
| 32 |
'primary key' => array('tid'),
|
| 33 |
);
|
| 34 |
|
| 35 |
$schema['gmap_taxonomy_node'] = array(
|
| 36 |
'fields' => array(
|
| 37 |
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 38 |
'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 39 |
'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 40 |
'marker' => array('type' => 'varchar', 'length' => 32),
|
| 41 |
),
|
| 42 |
'primary key' => array('vid'),
|
| 43 |
'indexes' => array(
|
| 44 |
'nid' => array('nid'),
|
| 45 |
),
|
| 46 |
);
|
| 47 |
|
| 48 |
return $schema;
|
| 49 |
}
|
| 50 |
|
| 51 |
/**
|
| 52 |
* Track the tid that caused the association, so we can
|
| 53 |
* do fixups faster.
|
| 54 |
*/
|
| 55 |
function gmap_taxonomy_update_5001() {
|
| 56 |
$ret = array();
|
| 57 |
// Removed because we just kill the table and recreate it in update 5002^H^H^H^H6001 anyway.
|
| 58 |
return $ret;
|
| 59 |
}
|
| 60 |
|
| 61 |
/**
|
| 62 |
* Rebuild {gmap_taxonomy_node}.
|
| 63 |
*/
|
| 64 |
function gmap_taxonomy_update_6001() {
|
| 65 |
$ret = array();
|
| 66 |
|
| 67 |
// Drop the existing table and rebuild it from scratch.
|
| 68 |
if (db_table_exists('gmap_taxonomy_node')) {
|
| 69 |
db_drop_table($ret, 'gmap_taxonomy_node');
|
| 70 |
}
|
| 71 |
|
| 72 |
$schema['gmap_taxonomy_node'] = array(
|
| 73 |
'fields' => array(
|
| 74 |
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 75 |
'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 76 |
'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
|
| 77 |
'marker' => array('type' => 'varchar', 'length' => 32),
|
| 78 |
),
|
| 79 |
'primary key' => array('vid'),
|
| 80 |
'indexes' => array(
|
| 81 |
'nid' => array('nid'),
|
| 82 |
),
|
| 83 |
);
|
| 84 |
|
| 85 |
db_create_table($ret, 'gmap_taxonomy_node', $schema['gmap_taxonomy_node']);
|
| 86 |
|
| 87 |
// Recreate the data.
|
| 88 |
// Useful for repopulating in bulk... Copy to hook_enable()?
|
| 89 |
$ret[] = update_sql("INSERT INTO {gmap_taxonomy_node} (nid, vid, tid, marker) (SELECT n.nid, n.vid, t.tid, g.marker FROM {node_revisions} n INNER JOIN {term_node} t ON n.vid = t.vid INNER JOIN {gmap_taxonomy_term} g ON t.tid = g.tid GROUP BY n.vid ORDER BY NULL)");
|
| 90 |
|
| 91 |
return $ret;
|
| 92 |
}
|