fixed bugs in next/previous
authorlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 21 Apr 2000 03:12:00 +0000 (03:12 +0000)
committerlkehresman <lkehresman@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 21 Apr 2000 03:12:00 +0000 (03:12 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@447 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/read_body.php

index ca95b696939a3613ca08f635f3308dccdb85cb32..e6e000fa4a680e556cb063e615e609d2e9f241db 100644 (file)
 
    // returns the index of the next valid message from the array
    function findNextMessage() {
 
    // returns the index of the next valid message from the array
    function findNextMessage() {
-      global $currentArrayIndex, $msgs;
-      if ($currentArrayIndex < (count($msgs)-1))
-         return $msgs[$currentArrayIndex+1]["ID"];
+      global $msort, $currentArrayIndex, $msgs;
+               for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { 
+          if ($currentArrayIndex == $msgs[$key]["ID"]) {
+                               next($msort); 
+                               $key = key($msort);
+                               if (isset($key)) 
+                                       return $msgs[$key]["ID"];
+                       }
+               }
       return -1;
    }
 
    // returns the index of the previous message from the array
    function findPreviousMessage() {
       return -1;
    }
 
    // returns the index of the previous message from the array
    function findPreviousMessage() {
-      global $currentArrayIndex, $msgs;
-      if ($currentArrayIndex > 0)
-         return $msgs[$currentArrayIndex-1]["ID"];
+      global $msort, $currentArrayIndex, $msgs;
+               for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) { 
+          if ($currentArrayIndex == $msgs[$key]["ID"]) {
+                               prev($msort);
+                               $key = key($msort);
+                               if (isset($key))
+                                       return $msgs[$key]["ID"];
+                       }
+               }
       return -1;
    }
 
    if (isset($msgs)) {
       return -1;
    }
 
    if (isset($msgs)) {
+               $currentArrayIndex = $passed_id;
+               /*
       for ($i=0; $i < count($msgs); $i++) {
          if ($msgs[$i]["ID"] == $passed_id) {
             $currentArrayIndex = $i;
             break;
          }
       }
       for ($i=0; $i < count($msgs); $i++) {
          if ($msgs[$i]["ID"] == $passed_id) {
             $currentArrayIndex = $i;
             break;
          }
       }
+               */
    } else {
       $currentArrayIndex = -1;
    }
    } else {
       $currentArrayIndex = -1;
    }