When viewing a node with move permissions, nodeorder always shows the move up and the move down links, even when the node is first or last, and even if it is the only node within the category.

Clicking and the link (for example, moving up a node that is in first position) leads to a access denied error page.

Comments

ricflomag’s picture

Status: Active » Needs review
StatusFileSize
new1.59 KB

I have made a patch to nodeorder_link() function to correct this problem on my site. I am new to drupal so it probably does not stick to the standards, but it works fine for me.

See attached file.

ricflomag’s picture

StatusFileSize
new1.59 KB

I have made a patch to nodeorder_link() function to correct this problem on my site. I am new to drupal so it probably does not stick to the standards, but it works fine for me.

See attached file.

OliverColeman’s picture

Version: 4.7.x-1.0 » 5.x-1.2

Patch works in 1.2, too (though line numbers are a little different I think, I applied it manually). Thanks ricflomag.

Any chance of getting this committed?

marcp’s picture

I like the functionality, but there are going to be too many database hits on page listings with many nodes. Here is the pseudocode for what I'd like to see in nodeorder_link():

// This goes at the beginning of the function...
static $min_weight = array();
static $max_weight = array();

// Load up the min and max weights for all tids and cache them so that we only
// have to do this once per page.
if (empty($min_weight)) {
  $result = db_query("SELECT tid, max(weight_in_tid) as max_weight, min(weight_in_tid) as min_weight FROM {term_node} group by tid");

  while ($row = db_fetch_object($result)) {
    $min_weight[$row->tid] = $row->min_weight;
    $max_weight[$row->tid] = $row->max_weight;
  }
}

/////////

// This goes where the current patch checks $minmax->min and $minmax->max

if ($node->nodeorder[$term->tid] > $min_weight[$term->tid] ) {
  // Show the move up link...
}

if ($node->nodeorder[$term->tid] < $max_weight[$term->tid] ) {
  // Show the move down link...
}

If anyone wants to take a crack at it and provide a patch that implements this, I'd get it in there.

marcp’s picture

Version: 5.x-1.2 » master
Assigned: Unassigned » pvanderspek

Let's get this in there.

pvanderspek’s picture

Version: master » 6.x-1.x-dev
Status: Needs review » Fixed

This has been fixed in the 6.x release

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.