function advpoll_ranking_uninstall in Advanced Poll 7.3
Same name and namespace in other branches
- 7 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 12 - 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("\n SELECT entity_id FROM {field_data_advpoll_behavior} f\n WHERE f.advpoll_behavior_value = 'borda'\n OR f.advpoll_behavior_value = 'runoff'\n OR f.advpoll_behavior_value = 'borda_all'\n OR f.advpoll_behavior_value = 'runoff_all'\n ");
foreach ($result as $row) {
$nid[] = $row->entity_id;
}
if ($nid) {
db_delete('votingapi_vote')
->condition('entity_id', $nid, 'IN')
->condition('entity_type', 'advpoll')
->execute();
/* Delete all the nodes at once.
* http://api.drupal.org/api/function/node_delete_multiple/7
*/
node_delete_multiple($nid);
}
$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);
}