function workflow_actions_actions_remove in Workflow 6.2
Same name and namespace in other branches
- 6 workflow_actions/workflow_actions.module \workflow_actions_actions_remove()
Remove an action assignment programmatically.
Helpful when deleting a workflow.
Parameters
$tid: Transition ID.
$aid: Action ID.
See also
1 call to workflow_actions_actions_remove()
- workflow_transition_delete in ./
workflow.module - Delete a transition (and any associated actions).
File
- workflow_actions/
workflow_actions.module, line 267 - 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_actions_remove($tid, $aid) {
$ops = array();
$result = db_query("SELECT op FROM {trigger_assignments} WHERE hook = 'workflow' AND aid = '%s'", $aid);
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) {
$ops[] = $data->op;
}
}
foreach ($ops as $op) {
db_query("DELETE FROM {trigger_assignments} WHERE hook = 'workflow' AND op = '%s' AND aid = '%s'", $op, $aid);
$description = db_result(db_query("SELECT description FROM {actions} WHERE aid = '%s'", $aid));
watchdog('workflow', 'Action %action has been unassigned.', array(
'%action' => $description,
));
}
}