You are here

function weight_disable in Weight 6

Same name and namespace in other branches
  1. 5 weight.module \weight_disable()
  2. 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()
weight_settings_form_submit in ./weight.admin.inc

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,
  )));
}