advpoll_ranking.install in Advanced Poll 7.3
Same filename and directory in other branches
Install file for Advanced Ranking Poll.
File
advpoll_ranking/advpoll_ranking.installView source
<?php
/**
* @file
* Install file for Advanced Ranking Poll.
* */
/**
* Implements hook_uninstall().
*
*/
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);
}
/**
* Implements hook_install().
*/
function advpoll_ranking_install() {
$t = get_t();
// Add borda and run-off to allow ranking-style display and voting.
$field = array(
'field_name' => 'advpoll_behavior',
'settings' => array(
'allowed_values' => array(
'approval' => $t('Approval voting'),
'pool' => $t('Pool votes and choices'),
'borda' => $t('Borda count (Ranking Poll)'),
'runoff' => $t('Instant-runoff (Ranking Poll)'),
'borda_all' => $t('Borda count drag and drop (Ranking Poll)'),
'runoff_all' => $t('Instant-runoff drag and drop (Ranking Poll)'),
),
'allowed_values_function' => '',
),
);
field_update_field($field);
}
/**
* Removes Show votes option.
*/
function advpoll_ranking_update_7000() {
$t = get_t();
// Add borda and run-off to allow ranking-style display and voting.
$field = array(
'field_name' => 'advpoll_behavior',
'settings' => array(
'allowed_values' => array(
'approval' => $t('Approval voting'),
'pool' => $t('Pool votes and choices'),
'borda' => $t('Borda count (Ranking Poll)'),
'runoff' => $t('Instant-runoff (Ranking Poll)'),
'borda_all' => $t('Borda count drag and drop (Ranking Poll)'),
'runoff_all' => $t('Instant-runoff drag and drop (Ranking Poll)'),
),
'allowed_values_function' => '',
),
);
field_update_field($field);
}
Functions
Name | Description |
---|---|
advpoll_ranking_install | Implements hook_install(). |
advpoll_ranking_uninstall | Implements hook_uninstall(). |
advpoll_ranking_update_7000 | Removes Show votes option. |