function weight_disable in Weight 6
Same name and namespace in other branches
- 5 weight.module \weight_disable()
- 7 weight.admin.inc \weight_disable()
Set nodes back to normal sticky values if they are not enabled for weights.
1 call to weight_disable()
File
- ./
weight.admin.inc, line 183 - This module uses the sticky column of the node table to add weighting to nodes.
Code
function weight_disable($weight_node_types = array()) {
if ($weight_node_types) {
drupal_set_message(t('Disabling weight for: !types', array(
'!types' => implode(', ', $weight_node_types),
)));
$placeholders = db_placeholders($weight_node_types, 'text');
db_query("UPDATE {node} SET sticky = 1 WHERE sticky > 1 AND type IN ({$placeholders})", $weight_node_types);
$count = db_affected_rows();
db_query("UPDATE {node} SET sticky = 0 WHERE sticky < 0 AND type IN ({$placeholders})", $weight_node_types);
$count += db_affected_rows();
}
else {
db_query("UPDATE {node} SET sticky = 1 WHERE sticky > 1");
$count = db_affected_rows();
db_query("UPDATE {node} SET sticky = 0 WHERE sticky < 0");
$count += db_affected_rows();
}
drupal_set_message(t('@count nodes weight disabled.', array(
'@count' => $count,
)));
}