You are here

function voting_rules_rules_event_info in Voting Rules 6

Same name and namespace in other branches
  1. 7 voting_rules.rules.inc \voting_rules_rules_event_info()

Implementation of hook_rules_event_info().

File

./voting_rules.rules.inc, line 43
Provides Rules integration for the Votingapi module

Code

function voting_rules_rules_event_info() {
  $events = array();
  $content_types = voting_rules_content_types();
  $events['voting_rules_insert'] = array(
    'label' => t('User votes on content of any type'),
    'module' => 'Votingapi',
    'arguments' => array(
      'vote' => array(
        'type' => 'vote',
        'label' => t('The vote'),
      ),
      'user' => array(
        'type' => 'user',
        'label' => t('The user who voted'),
      ),
    ),
    'redirect' => FALSE,
  );
  $events['voting_rules_delete'] = array(
    'label' => t('User deletes a vote on content of any type'),
    'module' => 'Votingapi',
    'arguments' => array(
      'vote' => array(
        'type' => 'vote',
        'label' => t('The vote'),
      ),
    ),
    'redirect' => FALSE,
  );
  $events['voting_rules_results'] = array(
    'label' => t('Votes are calculated for content of any type'),
    'module' => 'Votingapi',
    'arguments' => array(
      'vote_results' => array(
        'type' => 'vote_results',
        'label' => t('The results of the vote'),
      ),
    ),
    'redirect' => FALSE,
  );
  foreach ($content_types as $content_type) {
    $events['voting_rules_insert_' . $content_type] = array(
      'label' => t('User votes on a @type', array(
        '@type' => $content_type,
      )),
      'module' => 'Votingapi',
      'arguments' => array(
        'vote' => array(
          'type' => 'vote',
          'label' => t('The vote'),
        ),
        $content_type => array(
          'type' => $content_type,
          'label' => t("The @type being voted on", array(
            '@type' => $content_type,
          )),
        ),
        'user' => array(
          'type' => 'user',
          'label' => t('The user who voted'),
        ),
      ),
      'redirect' => FALSE,
    );
    $events['voting_rules_delete_' . $content_type] = array(
      'label' => t('User deletes a vote on a @type', array(
        '@type' => $content_type,
      )),
      'module' => 'Votingapi',
      'arguments' => array(
        'vote' => array(
          'type' => 'vote',
          'label' => t('The vote'),
        ),
        $content_type => array(
          'type' => $content_type,
          'label' => t("The @type being voted on", array(
            '@type' => $content_type,
          )),
        ),
        'user' => array(
          'type' => 'user',
          'label' => t('The user who voted'),
        ),
      ),
      'redirect' => FALSE,
    );
    $events['voting_rules_results_' . $content_type] = array(
      'label' => t('Votes are calculated for a @type', array(
        '@type' => $content_type,
      )),
      'module' => 'Votingapi',
      'arguments' => array(
        'vote_results' => array(
          'type' => 'vote_results',
          'label' => t('The results of the vote'),
        ),
        $content_type => array(
          'type' => $content_type,
          'label' => t("The @type being voted on", array(
            '@type' => $content_type,
          )),
        ),
        'user' => array(
          'type' => 'user',
          'label' => t('The user who voted'),
        ),
      ),
      'redirect' => FALSE,
    );
  }
  return $events;
}