You are here

function _faq_ask_answerlink in FAQ_Ask 7

Helper function to create a link to unanswered nodes using the toke verificationb

Parameters

unknown_type $n Node, either node object or node id:

unknown_type $mode 'answer' or 'edit':

Return value

string Link to the node with a token

1 call to _faq_ask_answerlink()
template_preprocess_faq_ask_unanswered_block in ./faq_ask.unanswered.inc
Create list of unanswered questions for display in block

File

./faq_ask.unanswered.inc, line 40
Theming preparation unanswered list functions for the FAQ-Ask module.

Code

function _faq_ask_answerlink($n, $mode) {
  if (!is_object($n)) {
    $n = node_load($n);
  }
  $nid = $n->nid;

  // Create token to enable instant answering of unanswered questions
  $token = _faq_ask_get_token('faq_ask/answer/' . $nid);
  $options = array(
    'query' => array(
      'token' => array(
        $token,
      ),
    ),
  );

  // Allow for edit mode in link to the unanswered questions if in edit mode
  if ($mode == 'edit') {
    return l($n->title, "faq_ask/edit/" . $nid, array(
      'query' => array(
        'ask' => TRUE,
      ),
    ));
  }
  elseif ($mode == 'answer') {
    return l($n->title, "faq_ask/answer/" . $nid, array(
      'query' => array(
        'token' => $token,
      ),
    ));
  }
}