Commit e6b10910 authored by normanice's avatar normanice

Warren's Modules first upload

parents
This module was written by Warren Smith (wsmith@newmmc.com,warren.m.smith@comcast.net)
Requirements
------------
This module requires Drupal 4.3.0 or higher
Installation
------------
Copy the .module file to your modules directory.
Enable the module in your system administration
Author
------
Warren Smith <wsmith@newmmc.com> <warren.m.smith@comcast.net>
This diff is collapsed.
This module adds a weight option to all nodes. It does this by modifying the status variable in the table (drupal automatically sorts by status) to put lighter weights on the top.
<?php
function weight_system($field) {
$info["name"] = "weight";
$info["description"] = "add weight capability to all nodes";
return $info[$field];
}
function weight_nodeapi(&$node, $op, $arg = 0) {
switch($op) {
case 'form pre':
$x = $node->static;
$node->static = 0;
if($x & 0x80) {
$node->static = 1;
}
$x = $x & 0x7F; /* AND $x with 0111 1111 */
if($x) {
$x = 22 - $x - 10;
}
$node->weight = $x;
return form_weight("Weight", "weight", $node->weight, 10);
break;
case 'validate':
if(isset($node->weight)) {
$x = $node->static;
$node->static = 0;
if($x & 0x80) {
$x = 1;
}
if($x == 1) {
$node->static = 0x80;
}
$node->static += (22 - ($node->weight + 10));
}
break;
}
}
// vim: ft=php
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment