function weight_uninstall in Weight 7
Same name and namespace in other branches
- 5 weight.install \weight_uninstall()
- 6 weight.install \weight_uninstall()
Implements hook_uninstall().
File
- ./
weight.install, line 25 - This module uses the sticky column of the node table to add weighting to nodes.
Code
function weight_uninstall() {
// We need to unset any weighted nodes and reset sticky to normal values.
$weight_node_types = variable_get('weight_node_types', array());
if ($weight_node_types) {
db_update('node')
->fields(array(
'sticky' => 1,
))
->condition('sticky', 1, '>')
->condition('type', $weight_node_types, 'IN')
->execute();
db_update('node')
->fields(array(
'sticky' => 0,
))
->condition('sticky', 0, '<')
->condition('type', $weight_node_types, 'IN')
->execute();
}
// reset sticky values in taxonomy_index table.
db_update('taxonomy_index')
->fields(array(
'sticky' => 1,
))
->condition('sticky', 1, '>')
->execute();
db_update('taxonomy_index')
->fields(array(
'sticky' => 0,
))
->condition('sticky', 0, '<')
->execute();
// reset taxonomy_index field to original type.
$spec = array(
'description' => 'Boolean indicating whether the node is sticky.',
'type' => 'int',
'not null' => FALSE,
'default' => 0,
'size' => 'tiny',
);
db_change_field('taxonomy_index', 'sticky', 'sticky', $spec);
// Delete our variables.
variable_del('weight_node_types');
variable_del('weight_range');
variable_del('weight_use_menu');
}