You are here

function nodeorder_link in Node Order 5

Same name and namespace in other branches
  1. 6 nodeorder.module \nodeorder_link()

Implementation of hook_link().

File

./nodeorder.module, line 88

Code

function nodeorder_link($type, $node = 0, $main = 0) {
  $links = array();
  if (user_access('order nodes within categories') && variable_get('nodeorder_show_links_on_node', 1)) {

    // If this node belongs to any vocabularies that are orderable,
    // stick a couple links on per term to allow the user to move
    // the node up or down within the term...
    if ($type == 'node') {
      if (array_key_exists('taxonomy', $node)) {
        foreach ($node->taxonomy as $term) {
          $vocabulary = taxonomy_get_vocabulary($term->vid);
          if ($vocabulary->module == 'nodeorder') {
            $links['nodeorder_move_up_' . $term->tid] = array(
              'href' => "nodeorder/moveup/" . $node->nid . "/" . $term->tid,
              'title' => t("move up in " . $term->name),
              'query' => "destination=" . $_GET['q'],
              'attributes' => array(
                'title' => t("Move this " . $node->type . " up in its category."),
              ),
            );
            $links['nodeorder_move_down_' . $term->tid] = array(
              'href' => "nodeorder/movedown/" . $node->nid . "/" . $term->tid,
              'title' => t("move down in " . $term->name),
              'query' => "destination=" . $_GET['q'],
              'attributes' => array(
                'title' => t("Move this " . $node->type . " down in its category."),
              ),
            );
          }
        }
      }
    }
  }
  return $links;
}