You are here

weight.install in Weight 5

Same filename and directory in other branches
  1. 6 weight.install
  2. 7.3 weight.install
  3. 7 weight.install
  4. 7.2 weight.install

This module uses the sticky column of the node table to add weighting to nodes.

File

weight.install
View source
<?php

// Author: Harry Slaughter <harry@devbee.com>

/**
 * @file
 * This module uses the sticky column of the node table
 * to add weighting to nodes.
 */

/**
 * Implementation of hook_install().
 */
function weight_install() {
  drupal_set_message(t('Weight module is now enabled. You must now update your nodes using the <a href="!url">Weight DB setup page</a>', array(
    '!url' => url('admin/settings/weight/setup'),
  )));
}

/**
 * Implementation of hook_uninstall().
 */
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) {
    $list = implode("', '", $weight_node_types);
    db_query("UPDATE {node} n SET n.sticky = 1 WHERE n.sticky > 1 AND n.type IN ('" . $list . "')");
    db_query("UPDATE {node} n SET n.sticky = 0 WHERE n.sticky < 0 AND n.type IN ('" . $list . "')");
  }

  // Delete our variables.
  variable_del('weight_node_types');
  variable_del('weight_range');
  variable_del('weight_use_menu');
}

Functions

Namesort descending Description
weight_install Implementation of hook_install().
weight_uninstall Implementation of hook_uninstall().