discussthis.install in Discuss This! 6
Same filename and directory in other branches
Installtion functions for Discuss This! module.
File
discussthis.installView source
<?php
/**
* @file
* Installtion functions for Discuss This! module.
*/
/**
* \brief Implementation hook_schema()
*/
function discussthis_schema() {
$schema['discussthis'] = array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'topic_nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'nid',
),
);
$schema['discussthis_forums'] = array(
'fields' => array(
'nid' => array(
'description' => 'Settings apply to this node.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'forum_tid' => array(
'description' => 'This node discussions will go to this forum (only applies to first post.) If -1, prevent Discuss This! on this node.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'nid',
),
);
//$schema['discussthis_comment'] = array(
// ... table used to save the comment until approaval from
// an administrator is received -- this is probably a
// copy of the $schema['comment'] of the Comment module
// with the nid being the source node and not the forum
//);
return $schema;
}
/**
* \brief Implementation of hook_install().
*
* This function creates a table that the module uses to map the forum
* posts to the originating nodes.
*/
function discussthis_install() {
// create the tables
drupal_install_schema('discussthis');
// inform the user that permissions and Discuss This! settings are waiting
drupal_set_message(t('The Discuss This! module is now installed. To complete the installation, you probably want to configure !perm and !settings.', array(
'!perm' => l(t('Administer') . ' > ' . t('User') . ' > ' . t('Administer Permissions'), 'admin/user/permissions'),
'!settings' => l(t('Administer') . ' > ' . t('Site Configuration') . ' > ' . t('Discuss This'), 'admin/settings/discussthis'),
)));
}
/**
* \brief Implementation of hook_uninstall().
*
* Drops the tables and delete the variables used by this module.
*/
function discussthis_uninstall() {
// drop my tables
drupal_uninstall_schema('discussthis');
// delete variables specific to this module
$sql = "DELETE FROM {variable} WHERE name LIKE 'discussthis_%%'";
db_query($sql);
}
/**
* \brief Implementation of hook_update_#()
*
* Remove the old discussthis_forum.
*/
function discussthis_update_6001() {
$ret = array();
db_drop_table($ret, 'discussthis_forums');
return $ret;
}
/**
* \brief Implementation of hook_update_#()
*
* This update creates the new discussthis_forums table.
* I have re-established the use of this table.
*/
function discussthis_update_6002() {
$ret = array();
$schema = discussthis_schema();
db_create_table($ret, 'discussthis_forums', $schema['discussthis_forums']);
return $ret;
}
// vim: ts=2 sw=2 et syntax=php
Functions
Name![]() |
Description |
---|---|
discussthis_install | \brief Implementation of hook_install(). |
discussthis_schema | \brief Implementation hook_schema() |
discussthis_uninstall | \brief Implementation of hook_uninstall(). |
discussthis_update_6001 | \brief Implementation of hook_update_#() |
discussthis_update_6002 | \brief Implementation of hook_update_#() |