function revisioning_action_revision_trigger in Revisioning 7
Same name and namespace in other branches
- 8 revisioning_triggers_actions.inc \revisioning_action_revision_trigger()
Execute all actions associated with the supplied trigger.
Parameters
object $revision: the node object as passed in from revisioning_revisionapi(); if omitted this function will try to load the node object based on the URL
string $hook: trigger name, as passed in from revisioning_revision_hook() above, ie. one of 'revision_publish', 'revision_unpublish' or 'revision_revert'.
3 calls to revisioning_action_revision_trigger()
- revisioning_revision_publish in ./
revisioning_triggers_actions.inc - Implements hook_revision_publish().
- revisioning_revision_revert in ./
revisioning_triggers_actions.inc - Implements hook_revision_revert().
- revisioning_revision_unpublish in ./
revisioning_triggers_actions.inc - Implements hook_revision_unpublish().
File
- ./
revisioning_triggers_actions.inc, line 78 - Triggers and actions supported by the Revisioning module.
Code
function revisioning_action_revision_trigger($revision, $hook) {
if (!module_exists('trigger')) {
return;
}
$aids = trigger_get_assigned_actions($hook);
if (empty($aids)) {
// No actions defined for this trigger.
return;
}
// Prepare a context to pass to all the actions to be invoked.
// Include everything we can think of (important for token replacement).
// See token_tokens()
global $user;
$context = array(
'group' => 'revisioning',
'hook' => $hook,
'comment' => NULL,
'file' => NULL,
'menu-link' => NULL,
'node' => $revision,
'node_type' => node_type_get_type($revision),
'revision' => $revision,
'path' => NULL,
// Use taxonomy_term_load() ?
'term' => NULL,
'user' => $user,
'vocabulary' => NULL,
);
// Loop through all actions attached to this trigger and load up the
// appropriate argument (eg node or user object) before invoking each action.
foreach ($aids as $aid => $info) {
$type = $info['type'];
$objects[$type] = NULL;
if (!isset($revision) && ($type == 'node' || $type == 'user')) {
drupal_set_message(t('Trigger %hook: no argument supplied to pass to @type action %aid', array(
'%hook' => $hook,
'@type' => $type,
'%aid' => $info['label'],
)), 'warning');
}
watchdog('revisioning', '%hook trigger is actioning %label', array(
'%hook' => $hook,
'%label' => $info['label'],
));
if (!isset($objects[$type])) {
switch ($type) {
case 'node':
$objects[$type] = $revision;
break;
case 'user':
$objects[$type] = user_load($revision->uid);
break;
case 'comment':
// Not sure how.
break;
default:
}
}
actions_do($aid, $objects[$type], $context);
}
}