/[drupal]/contributions/modules/nat/nat.install
ViewVC logotype

Contents of /contributions/modules/nat/nat.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.9 - (show annotations) (download) (as text)
Wed May 14 20:54:37 2008 UTC (18 months, 2 weeks ago) by karthik
Branch: MAIN
CVS Tags: DRUPAL-6--1-1-BETA, DRUPAL-6--1-1-BETA2, DRUPAL-6--1-1-BETA3, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.8: +35 -24 lines
File MIME type: text/x-php
D6 port - Work in progress.
1 <?php
2 // $Id: nat.install,v 1.8 2007/12/16 07:20:35 karthik Exp $
3
4 /**
5 * Implementation of hook_install().
6 */
7 function nat_install() {
8 drupal_install_schema('nat');
9 drupal_set_message(t('NAT module: Installation script complete.'));
10 }
11
12 /**
13 * Implementation of hook_install().
14 */
15 function nat_schema() {
16 $schema['nat'] = array(
17 'description' => t('NAT module: establish relationship between nids and tids.'),
18 'fields' => array(
19 'nid' => array(
20 'type' => 'int',
21 'unsigned' => TRUE,
22 'not null' => TRUE,
23 'description' => t('Index: Node ID.')
24 ),
25 'tid' => array(
26 'type' => 'int',
27 'unsigned' => TRUE,
28 'not null' => TRUE,
29 'description' => t('Term ID.')
30 ),
31 'vid' => array(
32 'type' => 'int',
33 'unsigned' => TRUE,
34 'not null' => TRUE,
35 'description' => t('Vocabulary ID.')
36 ),
37 ),
38 'indexes' => array('nid' => array('nid'))
39 );
40
41 return $schema;
42 }
43
44 /**
45 * Add a vid column to the NAT table.
46 */
47 function nat_update_2() {
48 switch ($GLOBALS['db_type']) {
49 case 'mysqli':
50 case 'mysql':
51 $ret[] = update_sql("ALTER TABLE {nat} ADD vid int NOT NULL DEFAULT 0");
52 break;
53 case 'pgsql':
54 db_add_column($ret, 'nat', 'vid', 'int', array('not null' => TRUE, 'default' => 0));
55 break;
56 }
57
58 $result = db_query('SELECT n.nid, n.tid, td.vid FROM {nat} n INNER JOIN {term_data} td USING (tid)');
59 while ($node = db_fetch_array($result)) {
60 db_query('UPDATE {nat} SET vid = %d WHERE nid = %d AND tid = %d', $node['vid'], $node['nid'], $node['tid']);
61 }
62
63 return $ret;
64 }
65
66 /**
67 * Implementation of hook_uninstall().
68 */
69 function nat_uninstall() {
70 variable_del('nat_config');
71 drupal_uninstall_schema('nat');
72 drupal_set_message(t('NAT module: Uninstallation script complete.'));
73 }

  ViewVC Help
Powered by ViewVC 1.1.2