You are here

discussthis.install in Discuss This! 7

Same filename and directory in other branches
  1. 5 discussthis.install
  2. 6 discussthis.install
  3. 7.2 discussthis.install

Installtion functions for Discuss This! module.

File

discussthis.install
View source
<?php

/**
 * @file
 * Installtion functions for Discuss This! module.
 */

/**
 * Implements 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' => FALSE,
        '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' => FALSE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  return $schema;
}

/**
 * Implements hook_install().
 * 
 * This function creates a table that the module uses to map the forum
 * posts to the originating nodes.
 */
function discussthis_install() {

  // 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('Structure') . ' > ' . t('Discuss This'), 'admin/structure/discussthis'),
  )));
}

/**
 * Implements hook_uninstall().
 *
 * Drops the tables and delete the variables used by this module.
 */
function discussthis_uninstall() {

  // Delete variables specific to this module.
  $sql = "DELETE FROM {variable} WHERE name LIKE 'discussthis_%%'";
  db_delete('variable')
    ->condition('name', 'discussthis_%%', 'LIKE')
    ->execute();
}

Functions