You are here

function weight_disable in Weight 7

Same name and namespace in other branches
  1. 5 weight.module \weight_disable()
  2. 6 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 144
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),
    )));
    $count = db_update('node')
      ->fields(array(
      'sticky' => 1,
    ))
      ->condition('sticky', 1, '>')
      ->condition('type', $weight_node_types, 'IN')
      ->execute();
    $count += db_update('node')
      ->fields(array(
      'sticky' => 0,
    ))
      ->condition('sticky', 0, '<')
      ->condition('type', $weight_node_types, 'IN')
      ->execute();
  }
  else {
    $count = db_update('node')
      ->fields(array(
      'sticky' => 1,
    ))
      ->condition('sticky', 1, '>')
      ->execute();
    $count += db_update('node')
      ->fields(array(
      'sticky' => 0,
    ))
      ->condition('sticky', 0, '<')
      ->execute();
  }
  drupal_set_message(t('@count nodes weight disabled.', array(
    '@count' => $count,
  )));
}