function advpoll_ranking_uninstall in Advanced Poll 7
Same name and namespace in other branches
- 7.3 advpoll_ranking/advpoll_ranking.install \advpoll_ranking_uninstall()
- 7.2 advpoll_ranking/advpoll_ranking.install \advpoll_ranking_uninstall()
Implements hook_uninstall().
File
- advpoll_ranking/
advpoll_ranking.install, line 13 - Install file for Advanced Ranking Poll
Code
function advpoll_ranking_uninstall() {
/*
* Get rid of polls that are either borda or ranking polls.
*/
$nid = array();
$result = db_query("SELECT entity_id FROM {field_data_advpoll_behavior} f \n WHERE f.advpoll_behavior_value = 'borda' \n OR f.advpoll_behavior_value = 'runoff'");
foreach ($result as $row) {
$nid[] = $row->entity_id;
}
if ($nid) {
db_delete('votingapi_vote')
->condition('entity_id', $nid, 'IN')
->execute();
// Delete all the nodes at once
// http://api.drupal.org/api/function/node_delete_multiple/7
node_delete_multiple($nid);
}
// fetch the t function for use in uninstall
$t = get_t();
// set field back to its default settings.
$field = array(
'field_name' => 'advpoll_behavior',
'settings' => array(
'allowed_values' => array(
'approval' => $t('Approval voting'),
'pool' => $t('Pool votes and choices'),
),
'allowed_values_function' => '',
),
);
field_update_field($field);
}