You are here

function answers_question_lock_set in Answers 7.4

Lock a question.

Parameters

object $question: A fully loaded question node.

string $module: The module setting the lock.

3 calls to answers_question_lock_set()
answers_best_answer_flag in answers_best_answer/answers_best_answer.module
Implements hook_flag().
answers_best_answer_flag_flag in answers_best_answer/answers_best_answer.module
Implements hook_flag_flag().
answers_lock_example_install in answers_lock_example/answers_lock_example.install
Implements hook_install().

File

includes/answers.lock.inc, line 84
Question locking functions for the 'Answers' module.

Code

function answers_question_lock_set($question, $module) {
  if (in_array($module, answers_locking_modules())) {
    $items = field_get_items('node', $question, 'question_locks');

    // Check if the question is already locked by this module.
    if (!$items || array_search(array(
      'value' => $module,
    ), $items) === FALSE) {

      // Find the delta.
      $delta = count($items);
      $lang = field_language('node', $question, 'question_locks');
      $question->question_locks[$lang][$delta]['value'] = $module;
      node_save($question);
    }
  }
}