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

Contents of /contributions/modules/nodecomment/nodecomment.install

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


Revision 1.2 - (show annotations) (download) (as text)
Thu Sep 25 17:58:03 2008 UTC (14 months ago) by sirkitree
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +84 -13 lines
File MIME type: text/x-php
setting HEAD to the same as DRUPAL-6--1-2-RC1

#310619: applying patch provided by wmostry
1 <?php
2 // $Id: nodecomment.install,v 1.1.2.4.2.1 2008/07/22 17:38:20 sirkitree Exp $
3
4 /**
5 * @file
6 * Install file for nodecomment
7 */
8
9 /**
10 * Implementation of hook_enable().
11 */
12 function nodecomment_enable() {
13 // Disable comment.module since it is incompatible with nodecomment
14 $result = db_query("UPDATE {system} SET status = 0 WHERE type = 'module' AND name = 'comment' AND status = 1");
15 if (db_affected_rows()) {
16 drupal_set_message(t('Comment module has been deactivated -- it is incompatible with Node Comment module.'));
17 }
18 }
19
20 function nodecomment_install() {
21 drupal_set_message('Installing Node Comments.');
22 drupal_install_schema('nodecomment');
23 _nodecomment_install_type_create();
24 }
25
26 function _nodecomment_install_type_create() {
27 // During install profiles, node and user modules aren't yet loaded.
28 // Ensure they're loaded before calling node_get_types().
29 include_once './'. drupal_get_path('module', 'node') .'/node.module';
30 include_once './'. drupal_get_path('module', 'user') .'/user.module';
31 $types = node_get_types();
32 $types = array_change_key_case($types, CASE_LOWER);
33
34 if (!in_array('comment', array_keys($types))) {
35 // Create the comment content type.
36 $nodecomment_node_type = array(
37 'type' => 'comment',
38 'name' => t('Comment'),
39 'module' => 'node',
40 'description' => t('A comment for use with the nodecomment module.'),
41 'title_label' => t('Subject'),
42 'body_label' => t('Body'),
43 'custom' => TRUE,
44 'modified' => TRUE,
45 'locked' => FALSE,
46 );
47 $nodecomment_node_type = (object)_node_type_set_defaults($nodecomment_node_type);
48 node_type_save($nodecomment_node_type);
49
50 // Default to not promoted.
51 variable_set('node_options_comment', array('status'));
52 cache_clear_all();
53 system_modules();
54 menu_rebuild();
55 node_types_rebuild();
56 }
57 }
58
59 function nodecomment_schema() {
60 $schema['node_comments'] = array(
61 'fields' => array(
62 'cid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
63 'pid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
64 'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
65 'hostname' => array('type' => 'varchar', 'length' => '128', 'not null' => TRUE, 'default' => ''),
66 'thread' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
67 'name' => array('type' => 'varchar', 'length' => '60', 'not null' => FALSE),
68 'uid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
69 'mail' => array('type' => 'varchar', 'length' => '64', 'not null' => FALSE),
70 'homepage' => array('type' => 'varchar', 'length' => '255', 'not null' => FALSE)
71 ),
72 'primary key' => array('cid'),
73 'indexes' => array(
74 'lid' => array('nid')),
75 );
76 return $schema;
77 }
78
79 function nodecomment_uninstall() {
80 drupal_uninstall_schema('nodecomment');
81 }
82
83 function nodecomment_update_6000() {
84 // adding uid to schema. this is needed to avoid the (not verified) that theme_user now implements
85 $ret = array();
86 db_add_field($ret, 'node_comments', 'uid', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'));
87 return $ret;
88 }

  ViewVC Help
Powered by ViewVC 1.1.2