From: lkehresman Date: Fri, 21 Apr 2000 03:12:00 +0000 (+0000) Subject: fixed bugs in next/previous X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;ds=sidebyside;h=53524fa0e0df5fbe4c02db82aee010236b265fb7;p=squirrelmail.git fixed bugs in next/previous git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@447 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/src/read_body.php b/src/read_body.php index ca95b696..e6e000fa 100644 --- a/src/read_body.php +++ b/src/read_body.php @@ -19,27 +19,42 @@ // 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() { - 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)) { + $currentArrayIndex = $passed_id; + /* for ($i=0; $i < count($msgs); $i++) { if ($msgs[$i]["ID"] == $passed_id) { $currentArrayIndex = $i; break; } } + */ } else { $currentArrayIndex = -1; }