You are here

function workflow_state_delete in Workflow 5

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

Delete a workflow state from the database, including any transitions the state was involved in and any associations with actions that were made to that transition.

Parameters

$sid: The ID of the state to delete.

2 calls to workflow_state_delete()
workflow_deletewf in ./workflow.module
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.
workflow_state_delete_form_submit in ./workflow.module

File

./workflow.module, line 1624

Code

function workflow_state_delete($sid) {

  // find out which transitions this state is involved in
  $preexisting = array();
  $result = db_query("SELECT sid, target_sid FROM {workflow_transitions} WHERE sid = %d OR target_sid = %d", $sid, $sid);
  while ($data = db_fetch_object($result)) {
    $preexisting[$data->sid][$data->target_sid] = TRUE;
  }

  // delete the transitions and associated actions
  foreach ($preexisting as $from => $array) {
    foreach (array_keys($array) as $target_id) {
      $tid = workflow_get_transition_id($from, $target_id);
      workflow_transition_delete($tid);
    }
  }

  // delete the state
  db_query("DELETE FROM {workflow_states} WHERE sid = %d", intval($sid));
}