You are here

function answers_best_answer_question_best_answer in Answers 7.4

Returns the best answer for a question if one is set. Returns NULL otherwise.

1 call to answers_best_answer_question_best_answer()
answers_best_answer_flag in answers_best_answer/answers_best_answer.module
Implements hook_flag().

File

answers_best_answer/answers_best_answer.module, line 115
Support selection of 'Best Answers' for the 'Answers' module.

Code

function answers_best_answer_question_best_answer($question) {
  $flag = flag_get_flag('best_answer') or die('no "best_answer" flag defined');
  foreach (answers_question_answers($question) as $answer) {
    if ($flag
      ->is_flagged($answer->nid)) {
      return $answer;
    }
  }
  return NULL;
}