You are here

function _jeditable_workflow_save in jEditable inline content editing 6

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

Set the workflow state of the node

Parameters

object $node: Node to be changed.

Return value

string the 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 568
jeditable.module

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);
}