You are here

function workbench_moderation_node_edit_context in Workbench Moderation 7.3

Same name and namespace in other branches
  1. 7 workbench_moderation.module \workbench_moderation_node_edit_context()

Custom context creation callback for the ctools node_edit arguments plugin.

This takes the node or nid and loads the correct node by calling workbench_moderation_node_current_load().

See also

workbench_moderation_ctools_plugin_pre_alter()

1 string reference to 'workbench_moderation_node_edit_context'
workbench_moderation_ctools_plugin_pre_alter in ./workbench_moderation.module
Implements hook_ctools_plugin_pre_alter().

File

./workbench_moderation.module, line 2502
Content moderation for Workbench.

Code

function workbench_moderation_node_edit_context($arg = NULL, $conf = NULL, $empty = FALSE) {

  // If unset it wants a generic, unfilled context.
  if ($empty) {
    return ctools_context_create_empty('node_edit_form');
  }

  // We can accept either a node object or a pure nid.
  if (is_object($arg)) {
    $node = workbench_moderation_node_current_load($arg);
    return ctools_context_create('node_edit_form', $node);
  }
  if (!is_numeric($arg)) {
    return FALSE;
  }
  $node = node_load($arg);
  $node = workbench_moderation_node_current_load($node);
  if (!$node) {
    return NULL;
  }

  // This will perform a node_access check, so we don't have to.
  return ctools_context_create('node_edit_form', $node);
}