You are here

function webform_workflow_state_load_by_submission in Webform Workflow 7

Get the state of a submission.

Parameters

object $submission: The webform submission object.

bool $reset: Whether to reset the static cache for this request.

Return value

object|FALSE The workflow state entity, or FALSE if the submission does not have a state.

7 calls to webform_workflow_state_load_by_submission()
webform_workflow_change_submission_state in ./webform_workflow.module
Action callback for changing the workflow state of a submission.
webform_workflow_get_notify_users in ./webform_workflow.module
Get a list of user accounts to notify when the submission changes state.
webform_workflow_submission_state_form in includes/webform_workflow.forms.inc
Form for changing the state of an existing submission.
webform_workflow_tokens in ./webform_workflow.tokens.inc
Implements hook_tokens().
webform_workflow_transition in ./webform_workflow.module
Change the state of a submission.

... See full list

File

./webform_workflow.module, line 303
A simple workflow module for webforms.

Code

function webform_workflow_state_load_by_submission($submission, $reset = FALSE) {
  if ($reset || !isset($submission->_webform_workflow_state)) {
    $wsid = db_query('SELECT wsid FROM {webform_workflow_submissions} WHERE sid = :sid', array(
      ':sid' => $submission->sid,
    ))
      ->fetchField();
    $state = $wsid ? webform_workflow_state_load($wsid) : FALSE;
    $submission->_webform_workflow_state = $state ? $state : webform_workflow_state_none();
  }
  return $submission->_webform_workflow_state;
}