Skip to content
Snippets Groups Projects
Commit c3bfd7bf authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

[gh-281] Merging test into staging -c1401

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1402 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent 46fbf67b
No related branches found
No related tags found
No related merge requests found
......@@ -60,3 +60,11 @@ sites/sites.php
sites/example.sites.php
* Added an example of the $default_domains array.
* Added the stub record needed for creating site aliases.
------------------------------------
Add Trigger Support Patch to Workbench Moderation
* Trigger support not in 7.x-1.1
* http://drupal.org/files/issues/trigger_support_for_wb_moderation-1079134-23.patch
* from http://drupal.org/node/1079134
* Don't upgrade WB Moderation without first applying this patch unless the new version supports Triggers
[#897] Upgrade Workbench Moderation to 2011-07-15 7.x-1.x-dev version
* r857
* This was done to address broken Unpublishing in 7.x-1.0-beta7
* If future releases don't include the fix (not likely) patches will be needed from http://drupal.org/node/1206694
-----------------------------------
[#911] Upgrade Workbench Moderation to 7.x-1.0-beta8 + trigger support
* Trigger support not in beta8
* http://drupal.org/files/issues/trigger_support_for_wb_moderation-1079134-10.patch
* from http://drupal.org/node/1079134
* Don't upgrade WB Moderation without first applying this patch unless the new version supports Triggers
\ No newline at end of file
......@@ -1473,6 +1473,10 @@ function workbench_moderation_moderate($node, $state) {
if (!empty($node->workbench_moderation['published'])) {
drupal_register_shutdown_function('workbench_moderation_store', $node);
}
/** UNL CHANGE/ADDITION BELOW- SEE /README-UNL.txt **/
if (module_exists('trigger')) {
workbench_moderation_trigger_transition($node, $old_revision->state, $state);
}
}
/**
......@@ -1880,3 +1884,78 @@ function workbench_moderation_ctools_plugin_api($module, $api) {
return array('version' => 1);
}
}
/** UNL CHANGE/ADDITION BELOW- SEE /README-UNL.txt **/
/**
* Implements hook_trigger_info().
*
* Creates a trigger for each transition.
*/
function workbench_moderation_trigger_info() {
$output = array(
'workbench_moderation' => array(
'workbench_moderation_transition' => array(
'label' => t('After any transition between states occurs.'),
),
),
);
// Get all transitions.
$transitions = workbench_moderation_transitions();
// Add a trigger for each trasnistion.
foreach ($transitions as $transition_definition) {
$transition_string = 'wmt_' . $transition_definition->from_name . '__' . $transition_definition->to_name;
// Hash this string if it's longer than the db field size
if (strlen($transition_string) > 32) {
$transition_string = md5($transition_string);
}
$output['workbench_moderation'][$transition_string] = array(
'label' => t('Transition from the state %from_name to %to_name occurs.', array('%from_name' => $transition_definition->from_name, '%to_name' => $transition_definition->to_name)),
);
}
return $output;
}
/**
* transition trigger: Run actions associated with an arbitrary event.
*
* This function is executed after a transition takes place.
*
* @param $node
* The node undergoing the transition.
* @param $from_state
* The previous workbench moderation state.
* @param $state
* The new workbench moderation state.
*/
function workbench_moderation_trigger_transition($node, $from_state, $state, $a3 = NULL, $a4 = NULL) {
// Ask the trigger module for all actions enqueued for the 'transition' trigger.
$aids = trigger_get_assigned_actions('workbench_moderation_transition');
// prepare a basic context, indicating group and "hook", and call all the
// actions with this context as arguments.
$context = array(
'group' => 'workbench_moderation',
'hook' => 'transition',
'from_state' => $from_state,
'state' => $state,
);
actions_do(array_keys($aids), $node, $context, $a3, $a4);
// Ask the trigger module for all actions enqueued for this specific transition.
$transition_string = 'wmt_' . $from_state . '__' . $state;
// Hash this string if it's longer than the db field size
if (strlen($transition_string) > 32) {
$transition_string = md5($transition_string);
}
$aids = trigger_get_assigned_actions($transition_string);
$context['hook'] = $transition_string;
actions_do(array_keys($aids), $node, $context, $a3, $a4);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment