You are here

heartbeat_example.module in Heartbeat 7

Same filename and directory in other branches
  1. 6.4 modules/heartbeat_example/heartbeat_example.module

Heartbeat example module

This module implements core and bigger contrib hooks to show how custom logging can be done without rules. You will find implementation hooks of heartbeat as well.

File

modules/heartbeat_example/heartbeat_example.module
View source
<?php

/**
 * @file
 * Heartbeat example module
 *
 * This module implements core and bigger contrib hooks to show
 * how custom logging can be done without rules.
 * You will find implementation hooks of heartbeat as well.
 */

/**
 * Implements hook_node_insert().
 * @param <type> $node
 */
function heartbeat_example_node_insert($node) {
  heartbeat_api_log('heartbeat_add_node', $node->uid, 0, $node->nid, 0, array(
    '!node_title' => l($node->title, 'node/' . $node->nid),
    '!username' => l(user_load($node->uid)->name, 'user/' . $node->uid),
    '!node_type' => $node->type,
    '!types' => $node->type . 's',
  ), HEARTBEAT_PUBLIC_TO_ALL, $node->created);
}

/**
 * Implements hook_node_update().
 * @param <type> $node
 */
function heartbeat_example_node_update($node) {
  heartbeat_api_log('heartbeat_edit_node', $node->uid, 0, $node->nid, 0, array(
    '!node_title' => l($node->title, 'node/' . $node->nid),
    '!username' => l(user_load($node->uid)->name, 'user/' . $node->uid),
    '!node_type' => $node->type,
    '!types' => $node->type . 's',
  ), HEARTBEAT_PUBLIC_TO_ALL);
}