Index: acidfree.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/acidfree/acidfree.module,v
retrieving revision 1.71
diff -u -r1.71 acidfree.module
--- acidfree.module     7 Feb 2006 23:30:40 -0000       1.71
+++ acidfree.module     27 Feb 2006 19:59:03 -0000
@@ -1940,6 +1940,10 @@
     drupal_goto(url("node/$nid", "{$p}&{$pager}"));
 }

+/*
+ *  Old version of function; New one is below
+ *
+
 function _acidfree_get_offset_in_parent(&$parent, &$node) {
     $query = "SELECT COUNT(nid) FROM {node} n ".
         "INNER JOIN {acidfree} ON {acidfree}.aid = n.nid ".
@@ -1954,6 +1958,29 @@

     return db_result($res);
 }
+*/
+
+function _acidfree_get_offset_in_parent(&$parent, &$node) {
+    $query = "SELECT nid FROM {node} n ".
+        "INNER JOIN {acidfree} ON {acidfree}.aid = n.nid ".
+        "INNER JOIN {acidfree_hierarchy} ON child = aid ".
+        "WHERE class <> 'album' AND parent=%d ".
+         _acidfree_content_sort_clause();
+    $query = db_rewrite_sql($query);
+    $res = db_query($query, $parent->nid);
+    if (db_num_rows($res) == 0)
+        return 0;
+    // A loop is pretty much the only way to reliable locate the node in a set if the sort order is anything
+    // other than a single unique column for mysql 3.x. This should be pretty quick for but 100's of rows.
+    $count = 0;
+    while ($row = db_fetch_object($res)) {
+      if ($row->nid == $node->nid) {
+        break;
+      }
+      $count++;
+    }
+    return $count;
+}

 function _acidfree_get_pager_offset_from_path($pager_id) {
     $pager = explode(',', $_GET[PAGER_STRING]);