You are here

function quotes_link in Quotes 6

Same name and namespace in other branches
  1. 5 quotes.module \quotes_link()

Implementation of hook_link().

File

./quotes.module, line 548
The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.

Code

function quotes_link($type, $node = NULL, $teaser = FALSE) {
  global $user;
  $links = array();
  if ($type == 'node' && $node->type == 'quotes') {

    // Some links are not done in blocks.
    $in_block = isset($node->in_block) && $node->in_block;
    if (!(arg(0) == 'quotes' && arg(1) == $node->uid)) {
      $name = $node->uid ? $node->name : variable_get('anonymous', t('Anonymous'));

      // Note: links already get check_plain, so the text is safe.
      if (!$in_block && variable_get('quotes_showlink', TRUE)) {
        if ($node->uid != $user->uid) {

          // Get the menu title.
          $menu_info = menu_get_item('quotes');
          $menu_title = $menu_info['title'];
          $links['quotes_usernames_quotes'] = array(
            'title' => t("!name's !menu", array(
              '!menu' => $menu_title,
              '!name' => $name,
            )),
            'href' => "quotes/{$node->uid}",
            'attributes' => array(
              'title' => t("View !name's !menu.", array(
                '!menu' => $menu_title,
                '!name' => $name,
              )),
            ),
          );
        }
      }
      if (!$in_block && variable_get('quotes_edit_link', TRUE)) {
        if (user_access('edit own quotes') && $node->uid == $user->uid || user_access('administer quotes')) {
          $links['quotes_edit_link'] = array(
            'title' => t('Edit !menu', array(
              '!menu' => drupal_strtolower($menu_title),
            )),
            'href' => 'node/' . $node->nid . '/edit',
            'attributes' => array(
              'title' => t('Edit this !menu', array(
                '!menu' => drupal_strtolower($menu_title),
              )),
            ),
          );
        }
      }
    }
    if ($in_block && $node->more_text) {
      $links['more_link'] = array(
        'title' => $node->more_text,
        'href' => 'quotes',
        'attributes' => array(
          'class' => 'quotes-more-link',
        ),
      );
    }
    if ($in_block && $node->comment == COMMENT_NODE_READ_WRITE && !empty($node->view_text)) {
      $links['view_link'] = array(
        'title' => $node->view_text,
        'href' => 'node/' . $node->nid,
        'attributes' => array(
          'class' => 'quotes-view-link',
        ),
      );
    }
  }

  // End if type.
  return $links;
}