You are here

votingapiactivity.module in Activity 5.2

File

contrib/votingapiactivity.module
View source
<?php

/**
 * Activity definition file
 *
 * This defines what hooks activity module should use
 */
function votingapiactivity_activity_info() {
  $tags = array();
  $query = db_query("SELECT DISTINCT tag FROM {votingapi_cache}");
  while ($result = db_fetch_array($query)) {
    $tags[] = $result['tag'];
  }
  return array(
    'name' => 'votingapi',
    'module' => 'votingapi',
    'ops' => array(
      'mark',
      'unmark',
    ),
    'types' => array_values($tags),
    'tokens' => array(
      'user' => 'user who done the action',
      'node-id' => 'id of what was voted upon',
      'node-title' => 'title of what was voted upon',
      'rating' => 'rating data',
    ),
  );
}

/**
 * Implementation of hook_votingapi_insert()
 */
function votingapiactivity_votingapi_insert() {
  global $user;
  $args = func_get_args();
  $node = node_load($args[0]->content_id);

  // it's safe to set this to 'mark' since we're only implementing hook_votingapi_insert()
  $action = 'mark';
  $type = 1;
  $token = array(
    'user-id' => $user->uid,
    'user-name' => $user->name,
    'node-id' => $args[0]->content_id,
    'node-title' => $node->title,
    'rating-value' => $args[0]->value,
    'rating_type' => $args[0]->value_type,
  );
  activity_insert('votingapi', $type, $action, $token);
}

Functions

Namesort descending Description
votingapiactivity_activity_info Activity definition file
votingapiactivity_votingapi_insert Implementation of hook_votingapi_insert()