/**
* Sort the message list and crunch to be as small as possible
* (overflow could happen, so make it small if possible)
+ * @param array $aUid array with uid's
+ * @return string $s message set string
*/
-function sqimap_message_list_squisher($messages_array) {
- if( !is_array( $messages_array ) ) {
- return $messages_array;
- }
-
- sort($messages_array, SORT_NUMERIC);
- $msgs_str = '';
- while ($messages_array) {
- $start = array_shift($messages_array);
- $end = $start;
- while (isset($messages_array[0]) && $messages_array[0] == $end + 1) {
- $end = array_shift($messages_array);
- }
- if ($msgs_str != '') {
- $msgs_str .= ',';
- }
- $msgs_str .= $start;
- if ($start != $end) {
- $msgs_str .= ':' . $end;
+function sqimap_message_list_squisher($aUid) {
+ if( !is_array( $aUid ) ) {
+ return $aUid;
+ }
+ sort($aUid, SORT_NUMERIC);
+
+ if (count($aUid)) {
+ $s = '';
+ for ($i=0,$iCnt=count($aUid);$i<$iCnt;++$i) {
+ $iStart = $aUid[$i];
+ $iEnd = $iStart;
+ while ($i<($iCnt-1) && $aUid[$i+1] == $iEnd +1) {
+ $iEnd = $aUid[$i+1];
+ ++$i;
+ }
+ if ($s) {
+ $s .= ',';
+ }
+ $s .= $iStart;
+ if ($iStart != $iEnd) {
+ $s .= ':' . $iEnd;
+ }
}
}
- return $msgs_str;
+ return $s;
}
$cChar = $sThreadResponse{$i};
switch ($cChar) {
case '(': // new sub thread
+ // correction for a subthread of a thread with no parents in thread
+ if (!count($aUidSubThread) && $j > 0) {
+ --$l;
+ }
$aDepthStack[$j] = $l;
++$j;
break;
* @return array $aMessageList associative array with messages. Key is the UID, value is an associative array
* @author Marc Groot Koerkamp
*/
-function parseFetch($aResponse,$aMessageList = array()) {
+function parseFetch(&$aResponse,$aMessageList = array()) {
for ($j=0,$iCnt=count($aResponse);$j<$iCnt;++$j) {
$aMsg = array();
$msgi = '';
}
$aMessageList[$msgi] = $aMsg;
+ $aResponse[$j] = NULL;
}
return $aMessageList;
}
if ($read) {
if (preg_match('/.+FLAGS\s\((.*)\)\s/AUi',$read[0],$regs)) {
if (trim($regs[1])) {
- $flags = preg_split('/ /', $regs[1],-1,'PREG_SPLIT_NI_EMPTY');
+ $flags = preg_split('/ /', $regs[1],-1,PREG_SPLIT_NO_EMPTY);
}
}
} else {
$msg->rfc822_header = $rfc822_header;
return $msg;
}
-
-?>