function revisioning_revisioning in Revisioning 6.3
Same name and namespace in other branches
- 6.4 revisioning_triggers_actions.inc \revisioning_revisioning()
- 6 revisioning_triggers_actions.inc \revisioning_revisioning()
Implementation of hook_<trigger_name>().
Note the confusing name -- this due to fact that trigger name needs to equal the module name.
Parameters
$op: trigger operation name, e.g 'publish', 'unpublish', 'revert' as passed in from revisioning_revisionapi()
$object: typically the node object as passed in from revisioning_revisionapi(); if omitted this function will try to load the node object based on the URL
See also
File
- ./
revisioning_triggers_actions.inc, line 46 - Triggers and actions supported by the revisioning module.
Code
function revisioning_revisioning($op, $object = NULL, $args = NULL) {
if (!module_exists('trigger')) {
return;
}
$aids = _trigger_get_hook_aids('revisioning', $op);
if (empty($aids)) {
// no actions defined for this trigger
return;
}
watchdog('revisioning', '%op trigger is actioning "@aids"', array(
'%op' => $op,
'@aids' => implode(', ', array_keys($aids)),
));
global $user;
$context = array(
'hook' => 'revisioning',
'op' => $op,
'user' => $user,
);
foreach ($aids as $aid => $action_info) {
if ($action_info['type'] == 'node') {
$object = NULL;
// @todo: sort out why we need this line i.e. enforce reload
$nid = arg(1);
if (!$object && !$node && arg(0) == 'node' && is_numeric($nid)) {
// Clear the static node_load() cache to ensure we are passing the
// updated object to the node actions.
$node = node_load($nid, NULL, TRUE);
}
$obj = $object ? $object : $node;
}
else {
// assume user object
$obj = $object ? $object : $user;
}
// Include node in context so we can use node-related tokens in the action [#1035354]
if (is_object($object) && $object->nid) {
$context['node'] = $object;
}
actions_do($aid, $obj, $context, $args);
}
}