You are here

function workflow_actions_get_actions in Workflow 6

Same name and namespace in other branches
  1. 6.2 workflow_actions/workflow_actions.module \workflow_actions_get_actions()

Get the actions associated with a given transition.

Parameters

int $tid: ID of transition.

Return value

array Array of action ids in the same format as _trigger_get_hook_aids().

See also

_trigger_get_hook_aids()

1 call to workflow_actions_get_actions()
workflow_transition_delete in ./workflow.module
Delete a transition (and any associated actions).
1 string reference to 'workflow_actions_get_actions'
workflow_transition_delete in ./workflow.module
Delete a transition (and any associated actions).

File

workflow_actions/workflow_actions.module, line 233
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 creadit to gcassie ( http://drupal.org/user/80260 ) for the…

Code

function workflow_actions_get_actions($tid) {
  $aids = array();
  if (!module_exists('trigger')) {
    watchdog('workflow', 'Unable to get actions associated with a transition because the trigger module is not enabled.', array(), WATCHDOG_WARNING);
    return $aids;
  }
  $result = db_query("SELECT op FROM {trigger_assignments} WHERE hook = 'workflow'");
  while ($data = db_fetch_object($result)) {

    // Transition ID is the last part, e.g., foo-bar-1.
    $transition = array_pop(explode('-', $data->op));
    if ($tid == $transition) {
      $results = db_query("SELECT aa.aid, a.type FROM {trigger_assignments} aa LEFT JOIN {actions} a ON aa.aid = a.aid WHERE aa.hook = '%s' AND aa.op = '%s' ORDER BY weight", 'workflow', $data->op);
      while ($action = db_fetch_object($results)) {
        $aids[$action->aid]['type'] = $action->type;
      }
    }
  }
  return $aids;
}