/[drupal]/contributions/modules/taxonomy_node/taxonomynode.install
ViewVC logotype

Contents of /contributions/modules/taxonomy_node/taxonomynode.install

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


Revision 1.2 - (show annotations) (download) (as text)
Thu May 28 19:38:22 2009 UTC (5 months, 4 weeks ago) by hanoii
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.1: +49 -0 lines
File MIME type: text/x-php
Merge from DRUPAL-5 branch, preparing to start DRUPAL-6--1 branch
1 <?php
2 // $Id: taxonomynode.install,v 1.1.2.2 2008/10/27 15:17:03 hanoii Exp $
3
4 /**
5 * Implementation of hook_install().
6 */
7 function taxonomynode_install() {
8 switch ($GLOBALS['db_type']) {
9 case 'mysql':
10 case 'mysqli':
11 db_query("CREATE TABLE {taxonomynode} (
12 tid INTEGER NOT NULL,
13 vid INTEGER NOT NULL,
14 nid INTEGER NOT NULL,
15 PRIMARY KEY (tid)
16 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
17
18 /* Check if we are upgrading from version 1.3 that was having a conflicting name */
19 /* Code will be removed in future versions */
20 if (db_table_exists('taxonomy_node')) {
21 // move data
22 $result = db_query("SELECT * FROM {taxonomy_node}");
23 while ($row = db_fetch_object($result)) {
24 if ($row->tid && $row->vid && $row->nid) {
25 db_query("INSERT INTO {taxonomynode} (tid, vid, nid) VALUES (%d, %d, %d)", $row->tid, $row->vid, $row->nid);
26 }
27 }
28
29 // move settings
30 foreach (taxonomy_get_vocabularies() as $vocabulary) {
31 $vid = $vocabulary->vid;
32 $vocabsettings = variable_get("taxonomy_node_{$vid}", array());
33 // store in new module's name variable
34 if (is_array($vocabsettings) && !empty($vocabsettings)) {
35 variable_set("taxonomynode_{$vid}", $vocabsettings);
36 }
37 // delete old just in case
38 variable_del("taxonomy_node_{$vid}");
39 }
40
41 // remove module and table
42 db_query("DELETE FROM {system} WHERE name = 'taxonomy_node'");
43 db_query("DROP TABLE {taxonomy_node}");
44 }
45 break;
46 }
47
48 drupal_set_message(t('The Taxonomy Node module was installed. This module extends the configuration screen of vocabularies so you can associate content types with them.'));
49 }

  ViewVC Help
Powered by ViewVC 1.1.2