poll_update
- Versions
- 4.6 – 7
poll_update($node)
Implement hook_update().
Code
modules/poll/poll.module, line 505
<?php
function poll_update($node) {
// Update poll settings.
db_update('poll')
->fields(array(
'runtime' => $node->runtime,
'active' => $node->active,
))
->condition('nid', $node->nid)
->execute();
// Poll choices with empty titles signifies removal. We remove all votes to
// the removed options, so people who voted on them can vote again.
foreach ($node->choice as $key => $choice) {
if (!empty($choice['chtext'])) {
db_merge('poll_choice')
->key(array('chid' => $choice['chid']))
->fields(array(
'nid' => $node->nid,
'chtext' => $choice['chtext'],
'chvotes' => (int) $choice['chvotes'],
'weight' => $choice['weight'],
))
->updateExcept('nid')
->execute();
}
else {
db_delete('poll_vote')
->condition('nid', $node->nid)
->condition('chid', $key)
->execute();
}
}
}
?>Login or register to post comments 