You are here

function flag_rules_event_info in Flag 6.2

Same name and namespace in other branches
  1. 6 includes/flag.rules.inc \flag_rules_event_info()
  2. 7.3 flag.rules.inc \flag_rules_event_info()
  3. 7.2 flag.rules.inc \flag_rules_event_info()

Implementation of hook_rules_event_info().

File

includes/flag.rules.inc, line 79
Rules integration for the Flag module.

Code

function flag_rules_event_info() {
  $items = array();
  $flags = flag_get_flags();
  foreach ($flags as $flag) {
    $arguments = array(
      // First, define ubiquitous arguments.
      'flag' => array(
        'type' => 'flag',
        'label' => t('flag'),
      ),
      'flag_content_id' => array(
        'type' => 'number',
        'hidden' => TRUE,
      ),
      'flagging_user' => array(
        'type' => 'user',
        'label' => t('flagging user'),
      ),
    );

    // Then, define flag-specific arguments.
    $arguments += $flag
      ->rules_get_event_arguments_definition();

    // For each flag we define two events.
    $items['flag_flagged_' . $flag->name] = array(
      'module' => 'Flag',
      'label' => t('A @flag-type has been flagged, under "@flag-title"', array(
        '@flag-title' => $flag
          ->get_title(),
        '@flag-type' => t($flag->content_type),
      )),
      'arguments' => $arguments,
    );
    $items['flag_unflagged_' . $flag->name] = array(
      'module' => 'Flag',
      'label' => t('A @flag-type has been unflagged, under "@flag-title"', array(
        '@flag-title' => $flag
          ->get_title(),
        '@flag-type' => t($flag->content_type),
      )),
      'arguments' => $arguments,
    );
  }
  return $items;
}