You are here

function book_copy_link in Book Copy 6

Implementatin of hook_link()

File

./book_copy.module, line 55

Code

function book_copy_link($type, $node = NULL, $teaser = FALSE) {
  global $user;
  $links = array();
  if ($type == 'node' && isset($node->book) && !$teaser) {
    if (user_access('view book history')) {
      $links['book_copy_history'] = array(
        'title' => t('Show Book History'),
        'href' => 'book_copy/history/' . $node->book['bid'],
      );
    }
    if (user_access('copy books')) {
      if (book_copy_can_copy($node->book['bid'])) {
        $links['book_copy_copy'] = array(
          'title' => t('Derive a Copy'),
          'href' => 'book_copy/copy/' . $node->book['bid'],
        );
      }
      elseif (variable_get('book_copy_always_display_copy_links', TRUE)) {
        $links['book_copy_copy'] = array(
          'title' => t('Derive a Copy'),
          'href' => 'book_copy/explain/' . $node->book['bid'],
        );
      }
      if ($node->book['bid'] != $node->nid && book_copy_can_copy($node->book['bid'], $node->nid)) {
        $links['book_copy_subtree'] = array(
          'title' => t('Copy subtree'),
          'href' => 'book_copy/copy/' . $node->book['bid'] . '/' . $node->nid,
        );
      }
      elseif (variable_get('book_copy_always_display_copy_links', TRUE)) {
        $links['book_copy_subtree'] = array(
          'title' => t('Copy subtree'),
          'href' => 'book_copy/explain/' . $node->book['bid'] . '/' . $node->nid,
        );
      }
    }
  }
  return $links;
}