function flag_rules_event_info in Flag 7.2
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.3 flag.rules.inc \flag_rules_event_info()
Implements hook_rules_event_info().
File
- ./
flag.rules.inc, line 116 - 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->content_type)) {
$variables = array(
'flag' => array(
'type' => 'flag',
'label' => t('flag'),
'flag_type' => $flag->content_type,
),
'flagged_' . $flag->content_type => array(
'type' => $flag->content_type,
'label' => $info['label'],
),
'flagging_user' => array(
'type' => 'user',
'label' => t('flagging user'),
),
);
// 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->content_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->content_type),
)),
'variables' => $variables,
'access callback' => 'flag_rules_integration_access',
);
}
}
return $items;
}