You are here

user_activity.module in Heartbeat 6.2

File

user_activity/user_activity.module
View source
<?php

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

/**
 * Implementation of hook_views_api()
 *
 * This hook will tell views2 that user activity is available
 */
function user_activity_views_api() {
  return array(
    'api' => 2,
    'path' => drupal_get_path('module', 'user_activity'),
  );
}

/**
 *  Implementation of hook_menu().
 */
function user_activity_menu() {
  $items = array();
  $items['admin/settings/heartbeat/user_activity'] = array(
    'title' => 'user activity settings',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'user_activity_admin_settings',
    ),
    'access arguments' => array(
      'configure user activity',
    ),
    'type' => MENU_LOCAL_TASK,
    'weight' => 6,
    'file' => 'user_activity.admin.inc',
  );
  return $items;
}

/**
 * User activity logger function
 * @param   The data to add one row
 */
function user_activity_log($data, $args = array()) {
  $user_activity = new user_activity($data);
  $user_activity
    ->save($args);
}

/**
 * Implementation of hook_heartbeat_message_info
 */
function user_activity_heartbeat_message_info() {
  $info = array(
    0 => array(
      'message' => '!username_link has updated !node_title_link.',
      'message_concat' => '!username_link has updated !node_title_link.',
      'concat_args' => array(
        'type' => 'single',
      ),
      'event' => 'event_node_update',
      'module' => 'user_activity',
      'karma_index' => 1,
      'description' => t('Message to use when a user updates content.'),
      'variables' => array(
        '@username' => '[author:user]',
        '@title' => '[node:title]',
        '@language' => '[node:language]',
        '@nid' => '[node:nid]',
        '@node_type' => '[node:type]',
        '@node_title_link' => '[node:title-link]',
        '@username_link' => '[author:user-name-url]',
        '@username_profile_link' => '[author:user-profile-url]',
        '@username_account_url' => '[author:account-url]',
      ),
    ),
    1 => array(
      'message' => '!username_link added !node_title_link.',
      'message_concat' => '!username_link added %titles%.',
      'concat_args' => array(
        'type' => 'summary',
        'target' => 'titles',
        'separator' => ', ',
      ),
      'event' => 'event_node_insert',
      'module' => 'user_activity',
      'karma_index' => 1,
      'description' => t('Message to use when one user adds new content, like a page, blogpost, etc ... .'),
      'variables' => array(
        '@username' => '[author:user]',
        '@title' => '[node:title]',
        '@language' => '[node:language]',
        '@nid' => '[node:nid]',
        '@node_type' => '[node:type]',
        '@node_title_link' => '[node:title-link]',
        '@username_link' => '[author:user-name-url]',
        '@username_profile_link' => '[author:user-profile-url]',
        '@username_account_url' => '[author:account-url]',
      ),
    ),
    2 => array(
      'message' => '!username_link changed a comment on !node_title_link.',
      'message_concat' => '!username_link has changed a comment on !node_title_link %number% times.',
      'concat_args' => array(
        'type' => 'count',
        'target' => 'number',
      ),
      'event' => 'event_comment_update',
      'module' => 'user_activity',
      'karma_index' => 1,
      'description' => t('Message to use when a user edits a reply or comment.'),
      'variables' => array(
        '@username' => '[comment_author:user]',
        '@title' => '[node:title]',
        '@language' => '[node:language]',
        '@node_title_link' => '[node:title-link]',
        '@username_link' => '[comment_author:user-name-url]',
        '@username_account_url' => '[comment_author:account-url]',
        '@username_profile_link' => '[comment_author:user-profile-url]',
      ),
    ),
    3 => array(
      'message' => '!username_link replied on !node_title_link.',
      'message_concat' => '!username_link replied %number% times on !node_title_link.',
      'concat_args' => array(
        'type' => 'count',
        'target' => 'number',
      ),
      'event' => 'event_comment_insert',
      'module' => 'user_activity',
      'karma_index' => 1,
      'description' => t('Message to use when one user adds a new comment.'),
      'variables' => array(
        '@username' => '[comment_author:user]',
        '@title' => '[node:title]',
        '@language' => '[node:language]',
        '@node_title_link' => '[node:title-link]',
        '@username_link' => '[comment_author:user-name-url]',
        '@username_account_url' => '[comment_author:account-url]',
        '@username_profile_link' => '[comment_author:user-profile-url]',
      ),
    ),
  );
  return $info;
}

Functions

Namesort descending Description
user_activity_heartbeat_message_info Implementation of hook_heartbeat_message_info
user_activity_log User activity logger function
user_activity_menu Implementation of hook_menu().
user_activity_views_api Implementation of hook_views_api()