You are here

function workflow_state_save in Workflow 5

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

Add or update a workflow state to the database.

Parameters

$edit: An array containing values for the new or updated workflow state.

Return value

The ID of the new or updated workflow state.

3 calls to workflow_state_save()
workflow_create in ./workflow.module
Create a workflow and its (creation) state.
workflow_state_add_form_submit in ./workflow.module
workflow_state_create in ./workflow.module
Legacy code for workflow_state_create().

File

./workflow.module, line 1594

Code

function workflow_state_save($edit) {
  $defaults = array(
    'weight' => 0,
    'sysid' => 0,
  );
  $edit = array_merge($defaults, $edit);
  if (!isset($edit['sid'])) {
    $edit['sid'] = db_next_id('{workflow_states}_sid');
    db_query("INSERT INTO {workflow_states} (sid, wid, state, sysid, weight) VALUES (%d, %d, '%s', %d, %d)", $edit['sid'], $edit['wid'], $edit['state'], $edit['sysid'], $edit['weight']);
  }
  else {
    db_query("UPDATE {workflow_states} SET wid = %d, state = '%s', sysid = %d, weight = %d WHERE sid = %d", $edit['wid'], $edit['state'], $edit['sysid'], $edit['weight'], $edit['sid']);
  }
  return $edit['sid'];
}