function flag_rules_event_info in Flag 7.3
Same name and namespace in other branches
- 6.2 includes/flag.rules.inc \flag_rules_event_info()
- 6 includes/flag.rules.inc \flag_rules_event_info()
- 7.2 flag.rules.inc \flag_rules_event_info()
Implements hook_rules_event_info().
File
- ./
flag.rules.inc, line 121 - Rules integration for the Flag module.
Code
function flag_rules_event_info() {
$items = array();
$flags = flag_get_flags();
foreach ($flags as $flag) {
// We only support flags on entities.
if ($info = entity_get_info($flag->entity_type)) {
$variables = array(
'flag' => array(
'type' => 'flag',
'label' => t('flag'),
'flag_type' => $flag->entity_type,
),
'flagged_' . $flag->entity_type => array(
'type' => $flag->entity_type,
'label' => $info['label'],
),
'flagging_user' => array(
'type' => 'user',
'label' => t('flagging user'),
),
'flagging' => array(
'type' => 'flagging',
'label' => t('flagging'),
),
);
// For each flag we define two events.
$items['flag_flagged_' . $flag->name] = array(
'group' => t('Flag'),
'label' => t('A @flag-type has been flagged, under "@flag-title"', array(
'@flag-title' => $flag
->get_title(),
'@flag-type' => t($flag->entity_type),
)),
'variables' => $variables,
'access callback' => 'flag_rules_integration_access',
);
$items['flag_unflagged_' . $flag->name] = array(
'group' => t('Flag'),
'label' => t('A @flag-type has been unflagged, under "@flag-title"', array(
'@flag-title' => $flag
->get_title(),
'@flag-type' => t($flag->entity_type),
)),
'variables' => $variables,
'access callback' => 'flag_rules_integration_access',
);
}
}
return $items;
}