You are here

function radioactivity_up_down_voting_votingapi_insert in Radioactivity 6

File

plugins/radioactivity_up_down_voting.module, line 29
Up/down voting support for radioactivity

Code

function radioactivity_up_down_voting_votingapi_insert($votes) {
  require_once drupal_get_path('module', 'radioactivity') . '/radioactivity.inc';
  foreach ($votes as $vote) {
    $oclass = $vote['content_type'];
    $oid = $vote['content_id'];
    $value = $vote['value'];
    switch ($oclass) {
      case 'node':
      case 'comment':
        if ($value > 0) {
          radioactivity_add_energy($oid, $oclass, 'vote_up');
        }
        elseif ($value < 0) {
          radioactivity_add_energy($oid, $oclass, 'vote_down');
        }
    }
  }
}