heartbeattest.module in Heartbeat 6.4
Test module to use within simpletest.
Remark: DO NOT USE THIS IN PRODUCTION SITES
File
tests/heartbeattest.moduleView source
<?php
/**
* @file
* Test module to use within simpletest.
*
* Remark:
* DO NOT USE THIS IN PRODUCTION SITES
*/
/**
* Implementation of hook_nodeapi().
*/
function heartbeattest_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
// The test module will log activity to heartbeat when
// a page is added or edited. You can see this as an example
// though this module cannot be enabled in production sites.
if ($op == 'insert' && $node->type == 'page') {
$variables = array(
'@username' => $node->uid ? l(!empty($node->name) ? $node->name : heartbeat_user_load($node->uid)->name, 'user/' . $node->uid) : variable_get('anonymous', t('Anonymous')),
'@node_type' => 'page',
'@node_title' => l($node->title, 'node/' . $node->nid),
);
heartbeat_api_log('heartbeattest_add_node', $node->uid, 0, $node->nid, 0, $variables);
}
}
/**
* Implementation of hook_heartbeat_message_info().
*/
function heartbeattest_heartbeat_message_info() {
$info = array(
/**
* Default node messages
*/
0 => array(
'message' => '!username has added !node_title',
'message_concat' => '!username has added %node_title%',
'message_id' => 'heartbeattest_add_node',
'concat_args' => array(
'type' => 'summary',
'group_by' => 'user',
'group_target' => 'node_title',
'merge_separator' => ', ',
'merge_end_separator' => ' and ',
),
'description' => 'When adding a node, log the users activity',
'perms' => '1',
'custom' => HEARTBEAT_MESSAGE_DEFAULT,
'variables' => array(
'@username' => '[node:author-name-url]',
'@node_title' => '[node:title-link]',
),
),
);
return $info;
}
Functions
Name | Description |
---|---|
heartbeattest_heartbeat_message_info | Implementation of hook_heartbeat_message_info(). |
heartbeattest_nodeapi | Implementation of hook_nodeapi(). |