diff options
Diffstat (limited to 'modules/forum/forum.install')
-rw-r--r-- | modules/forum/forum.install | 152 |
1 files changed, 146 insertions, 6 deletions
diff --git a/modules/forum/forum.install b/modules/forum/forum.install index df6ccf48d..a21244947 100644 --- a/modules/forum/forum.install +++ b/modules/forum/forum.install @@ -22,9 +22,7 @@ function forum_install() { function forum_enable() { if ($vocabulary = taxonomy_vocabulary_load(variable_get('forum_nav_vocabulary', 0))) { - // Existing install. Add back forum node type, if the forums - // vocabulary still exists. Keep all other node types intact there. - $vocabulary->nodes['forum'] = 1; + // Save the vocabulary to create the default field instance. taxonomy_vocabulary_save($vocabulary); } else { @@ -33,17 +31,26 @@ function forum_enable() { // forms. $edit = array( 'name' => t('Forums'), - 'multiple' => 0, - 'required' => 0, + 'machine_name' => 'forums', + 'description' => t('Forum navigation vocabulary'), 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'weight' => -10, - 'nodes' => array('forum' => 1), ); $vocabulary = (object) $edit; taxonomy_vocabulary_save($vocabulary); + $instance = array( + 'field_name' => 'taxonomy_' . $vocabulary->machine_name, + 'label' => $vocabulary->name, + 'bundle' => 'forum', + 'widget' => array( + 'type' => 'options_select', + ), + ); + field_create_instance($instance); + variable_set('forum_nav_vocabulary', $vocabulary->vid); } } @@ -109,6 +116,68 @@ function forum_schema() { ), ); + $schema['forum_index'] = array( + 'description' => 'Maintains denormalized information about node/term relationships.', + 'fields' => array( + 'nid' => array( + 'description' => 'The {node}.nid this record tracks.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'title' => array( + 'description' => 'The title of this node, always treated as non-markup plain text.', + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + ), + 'tid' => array( + 'description' => 'The term ID.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'sticky' => array( + 'description' => 'Boolean indicating whether the node is sticky.', + 'type' => 'int', + 'not null' => FALSE, + 'default' => 0, + 'size' => 'tiny', + ), + 'created' => array( + 'description' => 'The Unix timestamp when the node was created.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default'=> 0, + ), + 'last_comment_timestamp' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.timestamp.', + ), + 'comment_count' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The total number of comments on this node.', + ), + ), + 'indexes' => array( + 'forum_topics' => array('tid', 'sticky', 'last_comment_timestamp'), + ), + 'foreign keys' => array( + 'node' => 'nid', + 'taxonomy_term_data' => 'tid', + ), + ); + + return $schema; } @@ -119,3 +188,74 @@ function forum_update_7000() { db_drop_index('forum', 'nid'); db_add_index('forum', 'forum_topic', array('nid', 'tid')); } + +/** + * Create new {forum_index} table. + */ +function forum_update_7001() { + $forum_index = array( + 'description' => 'Maintains denormalized information about node/term relationships.', + 'fields' => array( + 'nid' => array( + 'description' => 'The {node}.nid this record tracks.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'title' => array( + 'description' => 'The title of this node, always treated as non-markup plain text.', + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + ), + 'tid' => array( + 'description' => 'The term ID.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'sticky' => array( + 'description' => 'Boolean indicating whether the node is sticky.', + 'type' => 'int', + 'not null' => FALSE, + 'default' => 0, + 'size' => 'tiny', + ), + 'created' => array( + 'description' => 'The Unix timestamp when the node was created.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default'=> 0, + ), + 'last_comment_timestamp' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.timestamp.', + ), + 'comment_count' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The total number of comments on this node.', + ), + ), + 'indexes' => array( + 'forum_topics' => array('tid', 'sticky', 'last_comment_timestamp'), + ), + 'foreign keys' => array( + 'node' => 'nid', + 'taxonomy_term_data' => 'tid', + ), + ); + db_create_table($ret, 'forum_index', $forum_index); + + db_query('INSERT INTO {forum_index} (SELECT n.nid, n.title, f.tid, n.sticky, n.created, ncs.last_comment_timestamp, ncs.comment_count FROM {node} n INNER JOIN {forum} f on n.vid = f.vid INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid)'); + + return $ret; +} |