diff --git a/workflow_rules/workflow_rules.rules.inc b/workflow_rules/workflow_rules.rules.inc index c300b8e..e7040ed 100644 --- a/workflow_rules/workflow_rules.rules.inc +++ b/workflow_rules/workflow_rules.rules.inc @@ -15,30 +15,49 @@ module_load_include('inc', 'workflow_rules', 'workflow_rules.field'); /** * Implements hook_rules_event_info(). - * - * @todo: add support for any entity type in hook_rules_event_info. */ function workflow_rules_rules_event_info() { - $label = t('updated content'); - // Add variables for the 'node' type. - $node_variables = rules_events_node_variables($label, TRUE); - + $workflow_variables = workflow_rules_events_workflow_variables(); $events = array( 'workflow_state_changed' => array( 'group' => t('Workflow'), 'label' => t('Workflow state has changed'), - 'variables' => $node_variables, + 'variables' => $workflow_variables, ), 'workflow_comment_added' => array( 'group' => t('Workflow'), 'label' => t('Workflow comment was added, but state did not change'), - 'variables' => $node_variables, + 'variables' => $workflow_variables, ), ); return $events; } /** + * Returns some parameters suitable for using it with a workflow transition + */ +function workflow_rules_events_workflow_variables() { + return array( + 'entity' => array( + 'type' => 'entity', + 'label' => t('entity'), + ), + 'entity_type' => array( + 'type' => 'text', + 'label' => 'Entity Type', + ), + 'workflow_sid_previous' => array( + 'type' => WORKFLOWFIELD_PROPERTY_TYPE, + 'label' => 'Previous Workflow State' + ), + 'workflow_sid_new' => array( + 'type' => WORKFLOWFIELD_PROPERTY_TYPE, + 'label' => 'New Workflow State' + ), + ); +} + +/** * Implements hook_rules_condition_info(). */ function workflow_rules_rules_condition_info() { diff --git a/workflow_rules/workflow_rules.workflow.inc b/workflow_rules/workflow_rules.workflow.inc index 8b79970..376c434 100644 --- a/workflow_rules/workflow_rules.workflow.inc +++ b/workflow_rules/workflow_rules.workflow.inc @@ -22,11 +22,12 @@ function workflow_rules_workflow($op, $old_sid, $new_sid, $entity, $force = FALS switch ($op) { case 'transition post': // Rules are updated only after the transition. + $entity_wrapper = entity_metadata_wrapper($entity_type, $entity); if ($old_sid == $new_sid) { - rules_invoke_event('workflow_comment_added', $entity, $entity_type, $old_sid, $new_sid); + rules_invoke_event('workflow_comment_added', $entity_wrapper, $entity_type, $old_sid, $new_sid); } else { - rules_invoke_event('workflow_state_changed', $entity, $entity_type, $old_sid, $new_sid); + rules_invoke_event('workflow_state_changed', $entity_wrapper, $entity_type, $old_sid, $new_sid); } break; @@ -34,3 +35,4 @@ function workflow_rules_workflow($op, $old_sid, $new_sid, $entity, $force = FALS break; } } +