You are here

og_activity.install in Heartbeat 6.4

Same filename and directory in other branches
  1. 6.3 modules/og_activity/og_activity.install

Installation file for organic group activity

File

modules/og_activity/og_activity.install
View source
<?php

/**
 * @file
 *   Installation file for organic group activity
 */

/**
 * Define a column definition for {heartbeat_activity}.in_group.
 */
function og_activity_in_group_column() {
  return array(
    'type' => 'int',
    'not null' => TRUE,
    'size' => 'tiny',
    'description' => t('Custom message type.'),
    'default' => 0,
  );
}

/**
 * Implementation of hook_install().
 */
function og_activity_install() {

  // Module weights in core: put heartbeat after heartbeat in the chain.
  db_query("UPDATE {system} SET weight = 51 WHERE name = 'og_activity'");
  $ret = array();
  db_add_field($ret, 'heartbeat_activity', 'in_group', og_activity_in_group_column());
  db_add_index($ret, 'heartbeat_activity', 'group_language_timestamp', array(
    'in_group',
    'language',
    'timestamp',
  ));
}

/**
 * Implementation of hook_uninstall().
 */
function og_activity_unininstall() {
  $ret = array();
  db_drop_field($ret, 'heartbeat_activity', 'in_group');
  db_drop_index($ret, 'heartbeat_activity', 'group_language_timestamp');
}

/**
 * Implementation of hook_schema_alter().
 */
function og_activity_schema_alter(&$schema) {
  $schema['heartbeat_activity']['in_group'] = og_activity_in_group_column();
  $schema['heartbeat_activity']['indexes']['group_language_timestamp'] = array(
    'in_group',
    'language',
    'timestamp',
  );
}

/**
 * Implementation of hook_disable().
 */
function og_activity_disable() {
  variable_del('heartbeat_add_og_admins_to_personal');
  variable_del('heartbeat_add_og_members_to_personal');
  variable_del('heartbeat_add_og_related_to_personal');
}

/**
 * Implementation of hook_enable().
 */
function og_activity_enable() {
  variable_set('heartbeat_add_og_admins_to_personal', TRUE);
  variable_set('heartbeat_add_og_members_to_personal', TRUE);
  variable_set('heartbeat_add_og_related_to_personal', TRUE);
  drupal_set_message(t('Please visit !messages_page to import default heartbeat messages from other modules.', array(
    '!messages_page' => l(t('Heartbeat messages page'), 'admin/build/heartbeat'),
  )));
}

/**
 * Set 'in_group' for existing activity records.
 */
function og_activity_update_6400() {
  $ret = array();
  db_add_field($ret, 'heartbeat_activity', 'in_group', og_activity_in_group_column());
  db_query("UPDATE {heartbeat_activity} SET in_group = 1 WHERE nid IN (SELECT DISTINCT nid FROM {og_ancestry})");
  db_query("UPDATE {heartbeat_activity} SET in_group = 1 WHERE nid IN (SELECT DISTINCT nid FROM {og})");
  return $ret;
}

/**
 * Add in_group, language, timestamp index to {heartbeat_activity}.
 */
function og_activity_update_6401() {
  $ret = array();
  db_add_index($ret, 'heartbeat_activity', 'group_language_timestamp', array(
    'in_group',
    'language',
    'timestamp',
  ));
  return $ret;
}

Functions

Namesort descending Description
og_activity_disable Implementation of hook_disable().
og_activity_enable Implementation of hook_enable().
og_activity_install Implementation of hook_install().
og_activity_in_group_column Define a column definition for {heartbeat_activity}.in_group.
og_activity_schema_alter Implementation of hook_schema_alter().
og_activity_unininstall Implementation of hook_uninstall().
og_activity_update_6400 Set 'in_group' for existing activity records.
og_activity_update_6401 Add in_group, language, timestamp index to {heartbeat_activity}.