function advpoll_uninstall in Advanced Poll 7.3
Same name and namespace in other branches
- 8 advpoll.install \advpoll_uninstall()
- 5 advpoll.install \advpoll_uninstall()
- 6.3 advpoll.install \advpoll_uninstall()
- 6 advpoll.install \advpoll_uninstall()
- 6.2 advpoll.install \advpoll_uninstall()
- 7 advpoll.install \advpoll_uninstall()
- 7.2 advpoll.install \advpoll_uninstall()
Implements hook_uninstall().
File
- ./
advpoll.install, line 104 - Install file for Advanced Poll.
Code
function advpoll_uninstall() {
// Gather all the example content that might have been created while this
// module was enabled. Simple selects still use db_query().
// http://api.drupal.org/api/function/db_query/7
$sql = 'SELECT nid FROM {node} n WHERE n.type = :type';
$result = db_query($sql, array(
':type' => 'advpoll',
));
$nid = array();
foreach ($result as $row) {
$nid[] = $row->nid;
}
if ($nid) {
db_delete('votingapi_vote')
->condition('entity_id', $nid, 'IN')
->condition('entity_type', 'node')
->execute();
/* Delete all the nodes at once
* http://api.drupal.org/api/function/node_delete_multiple/7
*/
node_delete_multiple($nid);
}
/* Loop over each of the fields defined by this module and delete
* all instances of the field, their data, and the field itself.
* http://api.drupal.org/api/function/field_delete_field/7
*/
foreach (array_keys(_advpoll_installed_fields()) as $field) {
field_delete_field($field);
}
/* Loop over any remaining field instances attached to the node_example
* content type (such as the body field) and delete them individually.
* http://api.drupal.org/api/function/field_delete_field/7
*/
$instances = field_info_instances('node', 'advpoll');
foreach ($instances as $instance) {
field_delete_instance($instance);
}
/* Delete our content type
* http://api.drupal.org/api/function/node_type_delete/7
*/
node_type_delete('advpoll');
/* Purge all field infromation
* http://api.drupal.org/api/function/field_purge_batch/7
*/
field_purge_batch(1000);
// Delete precision and rounding method variables.
variable_del('advpoll_percentage_precision');
variable_del('advpoll_percentage_rounding_method');
}