You are here

function workbench_moderation_get_moderation_links in Workbench Moderation 7.3

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

Generates a list of links to available moderation actions.

Parameters

$node: The node being acted upon.

$url_options: An array of options to pass, following the url() function syntax.

Return value

A list of links to display with the revision.

1 call to workbench_moderation_get_moderation_links()
workbench_moderation_handler_field_links::render in includes/workbench_moderation_handler_field_links.inc
Render the field.

File

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

Code

function workbench_moderation_get_moderation_links($node, $url_options = array()) {

  // Make sure that this node is moderated.
  if (!workbench_moderation_node_moderated($node)) {
    return;
  }

  // Build links to available moderation states.
  $links = array();
  $my_revision = $node->workbench_moderation['my_revision'];
  if ($my_revision->vid == $node->workbench_moderation['current']->vid && ($next_states = workbench_moderation_states_next($my_revision->state, NULL, $node))) {
    foreach ($next_states as $state => $label) {
      $link = array_merge($url_options, array(
        'title' => t('Change to %label', array(
          '%label' => workbench_moderation_state_label($state),
        )),
        'href' => "node/{$node->nid}/moderation/{$node->vid}/change-state/{$state}",
      ));
      $link['query']['token'] = drupal_get_token("{$node->nid}:{$node->vid}:{$state}");
      $links[] = $link;
    }
  }
  return $links;
}