function answers_update_7201 in Answers 7.3
Same name and namespace in other branches
- 7.2 answers.install \answers_update_7201()
Make sure that custom question fields have values set.
If one doesn't, set the default value.
File
- ./
answers.install, line 84
Code
function answers_update_7201() {
$result = db_query("SELECT * from {node} WHERE type = 'question';");
foreach ($result as $question) {
$question = node_load($question->nid);
$changed_p = FALSE;
if (isset($question->field_answer_count['und'][0]['count'])) {
$question->field_question_locked_p['und'][0]['count'] = 0;
$changed_p = TRUE;
}
if (isset($question->field_notify_p['und'][0]['value'])) {
$question->field_notify_p['und'][0]['value'] = 0;
$changed_p = TRUE;
}
if (isset($question->field_question_locked_p['und'][0]['value'])) {
$question->field_question_locked_p['und'][0]['value'] = 0;
$changed_p = TRUE;
}
if ($changed_p) {
watchdog('answers', 'Set default question fields for nid :nid', array(
':nid' => $question->nid,
));
node_save($question);
}
}
return array();
}