array( 'title' => 'Publish a node', 'page callback' => 'workbench_moderation_test_update_node', 'page arguments' => array(1), 'access arguments' => array('bypass workbench moderation'), ), ); } /** * Implements hook_menu_alter(). */ function workbench_moderation_test_menu_alter(&$items) { // This menu altering replicates what restws_menu_alter() does. // @see https://www.drupal.org/node/1838640 array_unshift($items['node/%node']['page arguments'], 'additional parameter', $items['node/%node']['page callback']); $items['node/%node']['page callback'] = 'workbench_moderation_test_menu_node_callback'; } function workbench_moderation_test_menu_node_callback($ignored_parameter, $page_callback) { $args = func_get_args(); return call_user_func_array($page_callback, array_slice($args, 2)); } /** * Page callback. Publishes, unpublishes or resaves the given node. * * @param object $node * The node to publish, unpublish or resave. * @param string $action * Optionally the action to take, either 'publish' or 'unpublish'. If omitted * the node will be resaved. */ function workbench_moderation_test_update_node($node, $action = NULL) { if (!empty($action)) { $node->status = $action == 'publish' ? NODE_PUBLISHED : NODE_NOT_PUBLISHED; } node_save($node); return array('#markup' => t('Node status: @status', array('@status' => $node->status ? t('published') : t('unpublished')))); }