function flag_flag in Flag 5
Same name and namespace in other branches
- 6.2 flag.module \flag_flag()
- 6 flag.module \flag_flag()
- 7.2 flag.module \flag_flag()
Implementation of hook_flag(). Trigger actions if any are available.
File
- ./
flag.module, line 525 - The Flag module.
Code
function flag_flag($action, $flag, $content_id, $account) {
if (module_exists('actions') && function_exists('_actions_get_hook_aids')) {
$flag_action = $flag
->get_flag_action($content_id);
$flag_action->action = $action;
$context = (array) $flag_action;
$aids = _actions_get_hook_aids($action, $action);
foreach ($aids as $aid => $action_info) {
// The 'if ($aid)' is a safeguard against http://drupal.org/node/271460#comment-886564
if ($aid) {
actions_do($aid, $flag, $context);
}
}
}
if (module_exists('rules')) {
$event_name = ($action == 'flag' ? 'flag_flagged_' : 'flag_unflagged_') . $flag->name;
$arguments = array(
'flag' => $flag,
'flag_content_id' => $content_id,
'flagging_user' => $account,
);
rules_invoke_event($event_name, $arguments);
}
}