You are here

function answers_best_answer_flag_access in Answers 7.4

Implements hook_flag_access().

Determines whether a user can flag a best answer for a question.

1 call to answers_best_answer_flag_access()
answers_best_answer_node_view in answers_best_answer/answers_best_answer.module
Implements hook_node_view().

File

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

Code

function answers_best_answer_flag_access($flag, $content_id, $action, $account) {
  if ($flag->name == "best_answer") {
    module_load_include('inc', 'answers', 'includes/answers.lock');
    $question = answers_answer_question($content_id);
    $best_answer_locked_p = variable_get('answers_best_answer_lock_choice_p', NULL) && answers_question_locked_p($question);

    // The question author can set a best answer if best answers are not locked.
    // A user with the 'manage answers content' permission can always set a
    // best answer.
    return $question->uid == $account->uid && !$best_answer_locked_p || user_access('manage answers content', $account);
  }
}