From ed5d29f4b3c57235594931d33dde7cccaf7cd58b Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Thu, 25 May 2006 14:25:04 -0400 Subject: [PATCH] Finalized GoogieSpell integration --- program/lib/imap.inc | 56 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 42 insertions(+), 14 deletions(-) diff --git a/program/lib/imap.inc b/program/lib/imap.inc index 73eb970..51db669 100644 --- a/program/lib/imap.inc +++ b/program/lib/imap.inc @@ -41,6 +41,9 @@ - Avoid stripslahes in iil_Connect() - Added patch to iil_SortHeaders() by Richard Green - Removed <br> from error messages (better for logging) + - Added patch to iil_C_Sort() enabling UID SORT commands + - Added function iil_C_ID2UID() + - Casting date parts in iil_StrToTime() to avoid mktime() warnings - Removed some debuggers (echo ...) ********************************************************/ @@ -611,15 +614,15 @@ //$month_a=array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12); $month_str=$a[1]; $month=$IMAP_MONTHS[$month_str]; - $day=$a[0]; - $year=$a[2]; + $day=(int)$a[0]; + $year=(int)$a[2]; $time=$a[3]; $tz_str = $a[4]; $tz = substr($tz_str, 0, 3); - $ta=explode(":",$time); + $ta = explode(":",$time); $hour=(int)$ta[0]-(int)$tz; - $minute=$ta[1]; - $second=$ta[2]; + $minute=(int)$ta[1]; + $second=(int)$ta[2]; //make UNIX timestamp $time2 = mktime($hour, $minute, $second, $month, $day, $year); @@ -627,7 +630,7 @@ return $time2; } -function iil_C_Sort(&$conn, $mailbox, $field, $add=''){ +function iil_C_Sort(&$conn, $mailbox, $field, $add='', $is_uid=FALSE, $encoding='US-ASCII'){ /* Do "SELECT" command */ if (!iil_C_Select($conn, $mailbox)) return false; @@ -635,10 +638,16 @@ if ($field=='INTERNALDATE') $field='ARRIVAL'; $fields = array('ARRIVAL'=>1,'CC'=>1,'DATE'=>1,'FROM'=>1,'SIZE'=>1,'SUBJECT'=>1,'TO'=>1); - if (!$fields[$field]) return false; + if (!$fields[$field]) + return false; + $is_uid = $is_uid ? 'UID ' : ''; + + if (!empty($add)) + $add = " $add"; + $fp = $conn->fp; - $command = 's SORT ('.$field.') US-ASCII ALL '."$add\r\n"; + $command = 's '. $is_uid .'SORT ('.$field.') '.$encoding.' ALL'."$add\r\n"; $line = $data = ''; if (!fputs($fp, $command)) return false; @@ -656,7 +665,7 @@ return $out; } -function iil_C_FetchHeaderIndex(&$conn, $mailbox, $message_set, $index_field,$normalize=true){ +function iil_C_FetchHeaderIndex(&$conn, $mailbox, $message_set, $index_field, $normalize=true){ global $IMAP_USE_INTERNAL_DATE; $c=0; @@ -1407,18 +1416,18 @@ and use that to sort the main array. */ - // create "index" array + // create "index" array $index=array(); reset($a); while (list($key, $val)=each($a)){ if ($field=="timestamp"){ - $data = @strtotime($value->date); - if ($data != false) - $data = $timestamp; + $data = @strtotime($val->date); + if ($data == false) + $data = $val->timestamp; } else { - $data=$a[$key]->$field; + $data = $val->$field; if (is_string($data)) $data=strtoupper(str_replace($stripArr, "", $data)); } @@ -1570,6 +1579,25 @@ return false; } +function iil_C_ID2UID(&$conn, $folder, $id){ + $fp = $conn->fp; + $result=-1; + if ($id > 0) { + if (iil_C_Select($conn, $folder)){ + $key = "FUID"; + if (fputs($fp, "$key FETCH $id (UID)\r\n")){ + do{ + $line=chop(iil_ReadLine($fp, 1024)); + if (eregi("^\* $id FETCH \(UID (.*)\)", $line, $r)){ + $result = $r[1]; + } + } while (!preg_match("/^$key/", $line)); + } + } + } + return $result; +} + function iil_C_Search(&$conn, $folder, $criteria){ $fp = $conn->fp; if (iil_C_Select($conn, $folder)){ -- Gitblit v1.9.1