You are here

function workflow_get_states in Workflow 6

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

Load workflow states for a workflow from the database. If $wid is not passed, all states for all workflows are given. States that have been deleted are not included.

Parameters

$wid: The ID of the workflow.

Return value

An array of workflow states keyed by state ID.

16 calls to workflow_get_states()
theme_workflow_admin_ui_edit_form in workflow_admin_ui/workflow_admin_ui.module
Theme the workflow editing form.
views_handler_argument_workflow_state::workflow_states in workflow_views/includes/workflow_views_handler_argument_state.inc
workflow_access_form_workflow_edit_form_alter in workflow_access/workflow_access.module
Implementation of hook_form_alter().
workflow_actions_hook_info in workflow_actions/workflow_actions.module
Implementation of hook_hook_info(). Expose each transition as a hook.
workflow_admin_ui_overview in workflow_admin_ui/workflow_admin_ui.module
Menu callback. Create the main workflow page, which gives an overview of workflows and workflow states.

... See full list

File

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

Code

function workflow_get_states($wid = NULL) {
  $states = array();
  if (isset($wid)) {
    $result = db_query("SELECT sid, state FROM {workflow_states} WHERE wid = %d AND status = 1 ORDER BY weight, sid", $wid);
    while ($data = db_fetch_object($result)) {
      $states[$data->sid] = check_plain(t($data->state));
    }
  }
  else {
    $result = db_query("SELECT ws.sid, ws.state, w.name FROM {workflow_states} ws INNER JOIN {workflows} w ON ws.wid = w.wid WHERE status = 1 ORDER BY sid");
    while ($data = db_fetch_object($result)) {
      $states[$data->sid] = check_plain(t($data->name)) . ': ' . check_plain(t($data->state));
    }
  }
  return $states;
}