You are here

shoutbox_group.install in Shoutbox 6.2

File

shoutbox_group/shoutbox_group.install
View source
<?php

/**
 * Implementation of hook_schema
 */
function shoutbox_group_schema() {
  $schema['shoutbox_groups'] = array(
    'description' => 'Link shouts to their respected group.',
    'fields' => array(
      'shout_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The shout id',
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => 'The organic group node id',
      ),
    ),
    'primary key' => array(
      'shout_id',
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_install
 */
function shoutbox_group_install() {
  drupal_install_schema('shoutbox_group');
  shoutbox_group_weight_module();
}

/**
 * Implementation of hook_uninstall
 */
function shoutbox_group_uninstall() {
  drupal_uninstall_schema('shoutbox_group');
}

/**
 * Weight the module
 */
function shoutbox_group_weight_module() {

  // This is needed so this module acts before OG modules,
  // allowing it to set the context first, if needed.
  db_query("UPDATE {system} SET weight = -5 WHERE name = 'shoutbox_group'");
}

/**
 * Accomodate shoutbox schema changes
 */
function shoutbox_group_update_6200() {
  db_query("UPDATE {shoutbox} s INNER JOIN {shoutbox_groups} sg ON s.shout_id = sg.shout_id SET s.module = 'shoutbox_group'");
  return array();
}

/**
 * Update hook to weight the module
 */
function shoutbox_group_update_6201() {
  shoutbox_group_weight_module();
  return array();
}

Functions

Namesort descending Description
shoutbox_group_install Implementation of hook_install
shoutbox_group_schema Implementation of hook_schema
shoutbox_group_uninstall Implementation of hook_uninstall
shoutbox_group_update_6200 Accomodate shoutbox schema changes
shoutbox_group_update_6201 Update hook to weight the module
shoutbox_group_weight_module Weight the module