You are here

function _jeditable_workflow_save in jEditable inline content editing 6.2

Same name and namespace in other branches
  1. 6 jeditable.module \_jeditable_workflow_save()
  2. 7 jeditable.module \_jeditable_workflow_save()

Set the workflow state of the node.

Parameters

$node: Node to be acted on.

Return value

The workflow status name after state change.

1 call to _jeditable_workflow_save()
_jeditable_ajax_save in ./jeditable.module
Helper function to save a value using the jeditable callback.

File

./jeditable.module, line 578

Code

function _jeditable_workflow_save($node, $sid) {
  if ($sid == $node->_workflow) {

    // This means there's nothing to change, so we just return the title.
    return workflow_get_state_name($sid);
  }
  else {

    // Here's where we do the actual transition. It will fail if user does not
    // have appropriate permissions.
    $new_sid = workflow_execute_transition($node, $sid, 'set using jeditable at ' . referer_uri());
  }
  if (empty($new_sid)) {

    // In this case, the transition failed, so we'll return "access denied".
    return "access denied";
  }

  // Finally, this is the intended outcome and we can return the changed state's
  // name.
  return workflow_get_state_name($new_sid);
}