|
@@ -28,16 +28,29 @@ require_once('../functions/smtp.php');
|
|
|
*/
|
|
|
function findNextMessage() {
|
|
|
global $msort, $currentArrayIndex, $msgs, $sort,
|
|
|
- $thread_sort_messages, $allow_server_sort;
|
|
|
+ $thread_sort_messages, $allow_server_sort,
|
|
|
+ $server_sort_array;
|
|
|
$result = -1;
|
|
|
- if ($thread_sort_messages == 1) {
|
|
|
- $sort = 0;
|
|
|
+ if ($thread_sort_messages == 1 || $allow_server_sort == true) {
|
|
|
+ reset($server_sort_array);
|
|
|
+ while(list($key, $value) = each ($server_sort_array)) {
|
|
|
+ if ($currentArrayIndex == $value) {
|
|
|
+ if ($key == (count($server_sort_array) -1)) {
|
|
|
+ $result = -1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $result = $server_sort_array[$key +1];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- if ($sort == 6 && $allow_server_sort != TRUE) {
|
|
|
+
|
|
|
+ elseif ($sort == 6 && $allow_server_sort != true && $thread_sort_messages != 1) {
|
|
|
if ($currentArrayIndex != 1) {
|
|
|
$result = $currentArrayIndex - 1;
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ elseif ($allow_server_sort != true && $thread_sort_messages != 1) {
|
|
|
if (!is_array($msort)) {
|
|
|
return -1;
|
|
|
}
|
|
@@ -67,22 +80,31 @@ function RemoveAddress(&$addr_list, $addr) {
|
|
|
function findPreviousMessage() {
|
|
|
global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
|
|
|
$mailbox, $data_dir, $username, $thread_sort_messages,
|
|
|
- $allow_server_sort;
|
|
|
- if ($thread_sort_messages == 1) {
|
|
|
- $sort = 0;
|
|
|
- }
|
|
|
-
|
|
|
+ $allow_server_sort, $server_sort_array;
|
|
|
$result = -1;
|
|
|
-
|
|
|
- if ($sort == 6 && $allow_server_sort != TRUE) {
|
|
|
+ if ($thread_sort_messages == 1 || $allow_server_sort == TRUE) {
|
|
|
+ reset($server_sort_array);
|
|
|
+ while(list($key, $value) = each ($server_sort_array)) {
|
|
|
+ if ($currentArrayIndex == $value) {
|
|
|
+ if ($key == 0) {
|
|
|
+ $result = -1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ $result = $server_sort_array[$key -1];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ elseif ($sort == 6 && $allow_server_sort != TRUE && $thread_sort_messages != 1) {
|
|
|
$numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
|
|
|
if ($currentArrayIndex != $numMessages) {
|
|
|
$result = $currentArrayIndex + 1;
|
|
|
}
|
|
|
- } else {
|
|
|
- if (!is_array($msort)) {
|
|
|
+ }
|
|
|
+ elseif ($thread_sort_messages != 1 && $allow_server_sort != TRUE) {
|
|
|
+ if (!is_array($msort)) {
|
|
|
return -1;
|
|
|
- }
|
|
|
+ }
|
|
|
for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
|
|
|
if ($currentArrayIndex == $msgs[$key]['ID']) {
|
|
|
prev($msort);
|
|
@@ -605,7 +627,6 @@ echo ' ' .
|
|
|
'<SMALL>';
|
|
|
|
|
|
if ( !($where && $what) ) {
|
|
|
-
|
|
|
if ($currentArrayIndex == -1) {
|
|
|
echo 'Previous | Next';
|
|
|
} else {
|