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

Contents of /contributions/modules/topichubs/topichubs.install

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


Revision 1.1 - (show annotations) (download) (as text)
Tue Mar 3 23:53:11 2009 UTC (8 months, 3 weeks ago) by febbraro
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, HEAD
Branch point for: DRUPAL-6--1, DRUPAL-6--2
File MIME type: text/x-php
initial import from svn
1 <?php
2 /**
3 * Implementation of hook_install().
4 */
5 function topichubs_install() {
6 drupal_install_schema('topichubs');
7
8 _topichubs_install_type();
9
10 // Must be after views
11 db_query("UPDATE {system} SET weight = 11 WHERE name = 'topichubs'");
12 }
13
14 /**
15 * Implementation of hook_uninstall().
16 */
17 function topichubs_uninstall() {
18 drupal_uninstall_schema('topichubs');
19 }
20
21 /**
22 * Implementation of hook_schema().
23 */
24 function topichubs_schema() {
25
26 $schema['topichub'] = array(
27 'description' => 'Holds Topic Hub information',
28 'fields' => array(
29 'nid' => array(
30 'type' => 'int',
31 'unsigned' => TRUE,
32 'not null' => TRUE,
33 'description' => t("Primary Key: The feed item node's nid."),
34 ),
35 'config' => array(
36 'type' => 'blob',
37 'description' => t('A serialized array of config options for this topichub.'),
38 ),
39 ),
40 'primary key' => array('nid'),
41 );
42 $schema['topichub_condition'] = array(
43 'description' => 'Holds Topic Hub taxonomy expression conditions',
44 'fields' => array(
45 'tcid' => array(
46 'type' => 'serial',
47 'not null' => TRUE,
48 'description' => t('Primary Key: Unique ID.'),
49 ),
50 'nid' => array(
51 'type' => 'int',
52 'unsigned' => TRUE,
53 'not null' => TRUE,
54 'description' => t("The Node id."),
55 ),
56 'tid' => array(
57 'type' => 'int',
58 'unsigned' => TRUE,
59 'not null' => TRUE,
60 'description' => t("Taxonomy Term id."),
61 ),
62 'condition' => array(
63 'type' => 'int',
64 'unsigned' => TRUE,
65 'not null' => TRUE,
66 'default' => 0,
67 'description' => t("The condition index for this term."),
68 ),
69 ),
70 'indexes' => array(
71 'nid' => array('nid'),
72 ),
73 'primary key' => array('tcid'),
74 );
75 return $schema;
76 }
77
78 /**
79 * Update from single term to a term expression.
80 */
81 function topichubs_update_6001() {
82 $ret = array();
83 if (!db_table_exists('topichub_condition')) {
84 $schema = topichubs_schema();
85 db_create_table($ret, 'topichub_condition', $schema['topichub_condition']);
86
87 // Seed table with pre-existing term
88 $result = db_query("SELECT * FROM {topichub}");
89 while($hub = db_fetch_object($result)) {
90 db_query("INSERT INTO {topichub_condition} (nid, tid, `condition`) VALUES (%d, %d, %d)", $hub->nid, $hub->tid, 0);
91 }
92
93 // Remove term id from the main table if the migration was successful
94 db_drop_field($ret, 'topichub', 'tid');
95 }
96
97 return $ret;
98 }
99
100 /**
101 * Create new content type for a topic hub
102 */
103 function _topichubs_install_type() {
104 $type = array(
105 'type' => 'topichub',
106 'name' => t('Topic Hub'),
107 'module' => 'node',
108 'description' => t('These nodes represent a collection of related data pertaining to the same topic.'),
109 'has_title' => TRUE,
110 'title_label' => t('Title'),
111 'has_body' => TRUE,
112 'body_label' => t('Description'),
113 'custom' => TRUE,
114 'modified' => TRUE,
115 'locked' => FALSE,
116 );
117
118 $type = (object)_node_type_set_defaults($type);
119 $result = node_type_save($type);
120
121 // Default to not promoted.
122 variable_set('node_options_topichub', array('status'));
123 node_types_rebuild();
124 }
125

  ViewVC Help
Powered by ViewVC 1.1.2