You are here

function _weight_encode in Weight 6

Same name and namespace in other branches
  1. 7 weight.module \_weight_encode()

Convert our weight to 'encoded' sticky value for DB. Stickiness is the inverse of weight - stickiness is sorted DESC while weight is sorted ASC so we invert the weight before saving... If the sticky box is checked, subtract weight from 100; unweighted sticky nodes will have a value of 100.

2 calls to _weight_encode()
weight_nodeapi in ./weight.module
weight_old_nodes in ./weight.admin.inc
Update the sticky value of existing nodes if they are enabled for weights. This ensures that they will sort correctly.

File

./weight.module, line 471
This module uses the sticky column of the node table to add weighting to nodes.

Code

function _weight_encode(&$node) {
  if ($node->sticky == 1) {
    $node->sticky = 100 - $node->node_weight;
  }
  else {
    if ($node->sticky == 0) {
      $node->sticky = -($node->node_weight + 100);
    }
  }
}