You are here

radioactivity_votingapi.module in Radioactivity 6

Same filename and directory in other branches
  1. 5 plugins/radioactivity_votingapi.module

VotingAPI support for radioactivity

File

plugins/radioactivity_votingapi.module
View source
<?php

/**
 * @file
 * VotingAPI support for radioactivity
 */
function radioactivity_votingapi_help($path, $arg) {
  $output = '';
  switch ($path) {
    case "admin/help#radioactivity_votingapi":
      $output = '<p>' . t("VotingAPI support for radioactivity. Provides <em>most voted</em> metrics " . "for nodes and comments.") . '</p>';
      break;
  }
  return $output;
}
function radioactivity_votingapi_radioactivity_info() {
  return array(
    'sources' => array(
      'node' => array(
        'vote' => array(
          'title_placeholder' => 'vote',
        ),
      ),
      'comment' => array(
        'vote' => array(
          'title_placeholder' => 'vote',
        ),
      ),
    ),
  );
}
function radioactivity_votingapi_votingapi_insert($votes) {
  require_once drupal_get_path('module', 'radioactivity') . '/radioactivity.inc';
  foreach ($votes as $vote) {
    $oclass = $vote['content_type'];
    $oid = $vote['content_id'];
    switch ($oclass) {
      case 'node':
      case 'comment':
        radioactivity_add_energy($oid, $oclass, 'vote');
    }
  }
}