You are here

function _voting_rules_votingapi_op in Voting Rules 7

Wrapper for hook_votingapi_insert() and hook_votingapi_delete().

2 calls to _voting_rules_votingapi_op()
voting_rules_votingapi_delete in ./voting_rules.module
Implements hook_votingapi_results().
voting_rules_votingapi_insert in ./voting_rules.module
Implements hook_votingapi_insert().

File

./voting_rules.module, line 30
Voting Rules module.

Code

function _voting_rules_votingapi_op($votes, $op) {
  foreach ($votes as $vote) {
    $entity = voting_rules_load_entity($vote['entity_type'], $vote['entity_id']);
    if ($entity) {
      if (in_array($vote['entity_type'], array_keys(voting_rules_get_types()))) {
        rules_invoke_event('voting_rules_' . $op . '_' . $vote['entity_type'], $vote, $entity);
      }
      else {
        rules_invoke_event('voting_rules_' . $op . '_entity', $vote, entity_metadata_wrapper($vote['entity_type'], $entity));
      }
    }
  }
}