You are here

user_activity.install in Heartbeat 6.2

File

user_activity/user_activity.install
View source
<?php

// by Jochen Stals - ONE-agency - www.one-agency.be

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

  // Create tables.
  drupal_install_schema('user_activity');
}

/**
 * Implementation of hook_uninstall().
 */
function user_activity_uninstall() {

  // Remove all tables so no need to delete the messages
  drupal_uninstall_schema('user_activity');
}

/**
 * Implementation of hook_schema().
 */
function user_activity_schema() {
  $schema['heartbeat_messages'] = array(
    'description' => t('Table that contains predefined messages that can be used in heartbeat views.'),
    'fields' => array(
      'hid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique heartbeat_messages event ID.'),
      ),
      'message' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Text of log message to be passed into the t() function.'),
      ),
      'message_concat' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Text of translatable log message for in concatenated form.'),
      ),
      'concat_args' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Arguments for concatenation message.'),
      ),
      // The messages depend most on "the event" ,
      // "something that happened" worth logging.
      'event' => array(
        'type' => 'varchar',
        'length' => 150,
        'not null' => FALSE,
        'default' => '',
        'description' => t('user activity action to hook.'),
      ),
      'karma_index' => array(
        'type' => 'int',
        'not null' => TRUE,
        'description' => t('The karma index value for this kind of event.'),
        'default' => 1,
      ),
      'description' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => t('Description and/or help text.'),
      ),
      'module' => array(
        'type' => 'varchar',
        'length' => 150,
        'not null' => FALSE,
        'default' => '',
        'description' => t('module where the message is defined.'),
      ),
      'variables' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => t('Variables to parse into the message (used in message).'),
      ),
    ),
    'primary key' => array(
      'hid',
    ),
    'indexes' => array(),
  );
  $schema['user_activity'] = array(
    'description' => t('Table that contains logs of all user triggerable actions.'),
    'fields' => array(
      'uaid' => array(
        'type' => 'serial',
        'not null' => TRUE,
        'description' => t('Primary Key: Unique user_activity event ID.'),
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'description' => t('The {users}.uid of the user who triggered the event (requester).'),
      ),
      'uid_target' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
        'default' => 0,
        'description' => t('The target User ID'),
      ),
      'nid_target' => array(
        'description' => t('The target Node ID.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'hid' => array(
        'description' => t('The heartbeats message ID.'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'message' => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
        'description' => t('Text of log message to be passed into the t() function.'),
      ),
      'timestamp' => array(
        'description' => t('The activity\'s unix timestamp when action occurred'),
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'event' => array(
        'type' => 'varchar',
        'length' => 150,
        'not null' => FALSE,
        'default' => '',
        'description' => t('Event type that is hooked. For example "user hook, login operation" or "nodeapi hook, insert operation".'),
      ),
      'language' => array(
        'type' => 'char',
        'length' => 4,
        'not null' => FALSE,
        'default' => 'en',
        'description' => t('language for a log".'),
      ),
      'variables' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'description' => t('Serialized array of variables that match the message string and that is passed into the t() function.'),
      ),
    ),
    'primary key' => array(
      'uaid',
    ),
    'indexes' => array(
      'timestamp' => array(
        'timestamp',
      ),
      'uid' => array(
        'uid',
      ),
      'uid_target' => array(
        'uid_target',
      ),
      'nid_target' => array(
        'nid_target',
      ),
      'language' => array(
        'language',
      ),
    ),
  );
  return $schema;
}

/**
 * Implementation of hook_enable
 * install basic variables
 */
function user_activity_enable() {
  variable_set('user_activity_no_duplicate_seconds', 3600);
  variable_set('user_activity_grouping_seconds', 3600);
  variable_set('user_activity_grouping_how_many', 5);
}

/**
 * Implementation of hook_disable
 * Uninstall basic variables
 */
function user_activity_disable() {
  heartbeat_messages_uninstall('user_activity');
  variable_del('user_activity_no_duplicate_seconds');
  variable_del('user_activity_grouping_seconds');
  variable_del('user_activity_grouping_how_many');
}

Functions

Namesort descending Description
user_activity_disable Implementation of hook_disable Uninstall basic variables
user_activity_enable Implementation of hook_enable install basic variables
user_activity_install Implementation of hook_install().
user_activity_schema Implementation of hook_schema().
user_activity_uninstall Implementation of hook_uninstall().