You are here

function workflow_actions_remove in Workflow 7

Same name and namespace in other branches
  1. 5.2 workflow.module \workflow_actions_remove()
  2. 5 workflow.module \workflow_actions_remove()

Remove an action assignment programmatically.

Helpful when deleting a workflow.

Parameters

$tid: Transition ID.

$aid: Action ID.

1 call to workflow_actions_remove()
workflow_actions_workflow in workflow_actions/workflow_actions.module
Implements hook_workflow().

File

workflow_actions/workflow_actions.module, line 150
Provide actions and triggers for workflows. Why it's own module? Some sites prefer rules, some prefer actions, all prefer a lower code footprint and better performance. Additional credit to gcassie ( http://drupal.org/user/80260 ) for the initial…

Code

function workflow_actions_remove($tid, $aid) {
  $ops = array();
  foreach (workflow_actions_get_trigger_assignments_by_aid($aid) as $data) {

    // Transition ID is the last part, e.g., foo-bar-1.
    $transition = array_pop(explode('-', $data->hook));
    if ($tid == $transition) {
      $hooks[] = $data->hook;
    }
  }
  foreach ($hooks as $hook) {
    workflow_actions_delete_trigger_assignments_by_aid_op($aid, $hook);
    foreach (workflow_actions_get_actions_by_aid($aid) as $action) {
      watchdog('workflow', 'Action %action has been unassigned.', array(
        '%action' => $action->description,
      ));
    }
  }
}