You are here

discussthis.install in Discuss This! 5

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

File

discussthis.install
View source
<?php

/**
 * Implementation of hook_install. Sets up two tables for the module's use.
 * discussthis stores nid->topic mapping, and discussthis_forums stores
 * nid->forum(tid) mapping.  
 **/
function discussthis_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {discussthis} (\n\t\tnid int unsigned NOT NULL default '0',\n\t\ttopic_nid int unsigned NOT NULL default '0',\n\t\tPRIMARY KEY (nid)\n\t       ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      db_query("CREATE TABLE {discussthis_forums} (\n\t\tnid int unsigned NOT NULL default '0',\n\t\tforum_tid int unsigned NOT NULL default '0',\n\t\tPRIMARY KEY (nid)\n\t\t) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      drupal_set_message(t("Discuss This! module installed. Configure !perm and !settings to continue", array(
        '!perm' => l('Administer > User > Access Control', 'admin/user/access'),
        '!settings' => l('Administer > Site Configuration > Discuss This', 'admin/settings/discussthis'),
      )));
      break;
    case 'pgsql':

      // someone else?
      break;
  }
}
function discussthis_update_1() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE {discussthis_forums} (\n\t   nid int unsigned NOT NULL default '0',\n\t   forum_tid int unsigned NOT NULL default '0',\n\t   PRIMARY KEY (nid)\n\t   ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
  }
  return $ret;
}
function discussthis_update_2() {
  variable_del('discussthis_author');
}

/**
 * Implementation of hook_uninstall. Drops the two db tables used by this module.
 **/
function discussthis_uninstall() {
  db_query('DROP TABLE {discussthis');
  db_query('DROP TABLE {discussthis_forums');
  $node_types = node_get_types('names');
  $discussthis_nodetypes = variable_get('discussthis_nodetypes', $node_types);
  foreach ($node_types as $type => $name) {
    variable_del('discussthis_node_' . $type);
    variable_del('discussthis_teaser_' . $type);
  }
  variable_del('discussthis_nodetypes');
  variable_del('discussthis_newsubject');
  variable_del('discussthis_newtemplate');
  variable_del('discussthis_comments');
}

Functions

Namesort descending Description
discussthis_install Implementation of hook_install. Sets up two tables for the module's use. discussthis stores nid->topic mapping, and discussthis_forums stores nid->forum(tid) mapping.
discussthis_uninstall Implementation of hook_uninstall. Drops the two db tables used by this module.
discussthis_update_1
discussthis_update_2