You are here

function workflow_deletewf in Workflow 6.2

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

Delete a workflow from the database. Deletes all states, transitions and node type mappings, too. Removes workflow state information from nodes participating in this workflow.

Parameters

$wid: The ID of the workflow.

1 call to workflow_deletewf()
workflow_admin_ui_delete_form_submit in workflow_admin_ui/workflow_admin_ui.module
Submit handler for workflow deletion form.

File

./workflow.module, line 779
Support workflows made up of arbitrary states.

Code

function workflow_deletewf($wid) {
  $wf = workflow_get_name($wid);
  $result = db_query('SELECT sid FROM {workflow_states} WHERE wid = %d', $wid);
  while ($data = db_fetch_object($result)) {

    // Delete the state and any associated transitions and actions.
    workflow_state_delete($data->sid);
    db_query('DELETE FROM {workflow_node} WHERE sid = %d', $data->sid);
  }
  db_query("DELETE FROM {workflow_type_map} WHERE wid = %d", $wid);
  db_query('DELETE FROM {workflows} WHERE wid = %d', $wid);

  // Notify any interested modules.
  module_invoke_all('workflow', 'workflow delete', $wid, NULL, NULL);

  // Workflow deletion affects tabs (local tasks), so force menu rebuild.
  cache_clear_all('*', 'cache_menu', TRUE);
  menu_rebuild();
}