View source
<?php
function heartbeat_install() {
drupal_load('module', 'heartbeat');
drupal_install_schema('heartbeat');
heartbeat_check_access_types();
$info = heartbeat_gather_messages();
db_query("UPDATE {system} SET weight = 50 WHERE name = 'heartbeat'");
}
function heartbeat_uninstall() {
drupal_uninstall_schema('heartbeat');
rules_clear_cache();
}
function heartbeat_enable() {
variable_set('heartbeat_enabled', 1);
variable_set('heartbeat_show_time_grouped_items', 1);
variable_set('heartbeat_show_message_times', 1);
variable_set('message_types', array(
'normal',
'flag',
));
variable_set('message_access_types', array(
0 => 'private',
1 => 'public to all',
2 => 'actor and addressee only if exists',
3 => 'public to connections if exists',
));
variable_set('heartbeat_types', array(
'summary',
'single',
'count',
));
variable_set('heartbeat_perms', array(
'Private',
'Friends',
'Full Site',
));
variable_set('heartbeat_activity_no_duplicate_seconds', 172800);
variable_set('heartbeat_activity_grouping_seconds', 7200);
variable_set('heartbeat_activity_grouping_how_many', 5);
variable_set('heartbeat_block_items_max', 100);
variable_set('heartbeat_block_public_items_max', 25);
variable_set('heartbeat_block_private_items_max', 25);
variable_set('heartbeat_activity_date_format', 'Y-m-d H:i:s');
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'),
)));
}
function heartbeat_disable() {
variable_del('heartbeat_enabled');
variable_del('heartbeat_show_message_times');
variable_del('heartbeat_show_time_grouped_items');
variable_del('message_types');
variable_del('message_access_types');
variable_del('heartbeat_types');
variable_del('heartbeat_perms');
variable_del('heartbeat_activity_no_duplicate_seconds');
variable_del('heartbeat_activity_grouping_seconds');
variable_del('heartbeat_activity_grouping_how_many');
variable_del('heartbeat_block_public_items_max');
variable_del('heartbeat_block_private_items_max');
variable_del('heartbeat_block_items_max');
variable_del('heartbeat_activity_date_format');
}
function heartbeat_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_id' => array(
'type' => 'varchar',
'length' => 250,
'not null' => FALSE,
'default' => '',
'description' => t('The message id which is unique to identify activity.'),
),
'message' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => t('Text of log message to be passed into the t() function.'),
'alias' => 'message_orig',
),
'message_concat' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => t('Text of translatable log message for in concatenated form.'),
'alias' => 'message_concat_orig',
),
'concat_args' => array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'description' => t('Arguments for concatenation message.'),
),
'message_type' => array(
'type' => 'text',
'size' => 'small',
'description' => t('The heartbeat message type.'),
),
'perms' => array(
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'description' => t('Permissions for this message.'),
'default' => 0,
),
'custom' => array(
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'description' => t('Custom message type.'),
'default' => 0,
),
'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(
'message_id' => array(
'message_id',
),
),
);
$schema['heartbeat_mt'] = array(
'description' => t('Table links tags with messages to filter logging and viewing.'),
'fields' => array(
'mtid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => t('Primary Key: Unique event ID - heartbeat message id.'),
),
'htid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => t('The heartbeat tag id to link to.'),
),
'hid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => t('The heartbeat message id to link to.'),
),
),
'primary key' => array(
'mtid',
),
'indexes' => array(
'htid' => array(
'htid',
),
'hid' => array(
'hid',
),
),
);
$schema['heartbeat_tags'] = array(
'description' => t('Table with heartbeat tags.'),
'fields' => array(
'htid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => t('Primary Key:heartbeat tag id.'),
),
'name' => array(
'type' => 'varchar',
'length' => 150,
'not null' => FALSE,
'default' => '',
'description' => t('Tag name.'),
),
),
'primary key' => array(
'htid',
),
'indexes' => array(),
);
$schema['heartbeat_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 heartbeat_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,
),
'access' => array(
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'description' => t('Access for this message to others.'),
'default' => 0,
),
'message_id' => array(
'type' => 'varchar',
'length' => 250,
'not null' => FALSE,
'default' => '',
'description' => t('The message id which links to the heartbeat message.'),
),
'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('Concatenated, grouped or merged 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,
),
'language' => array(
'type' => 'varchar',
'length' => 12,
'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',
),
'message_id' => array(
'message_id',
),
'uid_target' => array(
'uid_target',
),
'nid_target' => array(
'nid_target',
),
'language' => array(
'language',
),
),
);
return $schema;
}
function heartbeat_update_3() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("RENAME TABLE {hb_activity} TO {heartbeat_activity}");
break;
}
return $ret;
}