You are here

function answers_link in Answers 5.2

File

./answers.module, line 533
Enables the creation of question nodes that can be answered by posting answer nodes.

Code

function answers_link($type, $node = 0, $teaser = FALSE) {
  $questlinks = variable_get('questlinks', '');
  if ($questlinks) {
    $links = array();
    global $user;
    if ($user->uid == 0 && $node->type == 'answers') {

      // $links['answerlogin']['title'] = t(' ');
      $links['loganswers'] = array(
        'title' => t('You must be signed in to post <a href="/user/register">Register</a> | <a href="/user/login">Sign In</a>'),
        'html' => 'true',
      );
    }
    if ($node->type == 'answers' && $teaser) {
      $result = db_query_range("SELECT count(distinct(q.nid)) as items FROM {answers} q WHERE q.qid = %d", $node->nid, 0, 100);
      while ($znode = db_fetch_object($result)) {
        if ($znode->items == 1) {
          $links['qitem']['title'] .= $znode->items . " answer";
        }
        else {
          $links['qitem']['title'] .= $znode->items . " answers";
        }
      }
    }
    return $links;
  }
}