Mercurial > hg > rc1
comparison plugins/thunderbird_labels/thunderbird_labels.php @ 25:4b2bc456ce42
threaded dates sort working
| author | Charlie Root |
|---|---|
| date | Thu, 18 Jan 2018 07:54:45 -0500 |
| parents | 4869fae20b88 |
| children | b2b6c0af2383 |
comparison
equal
deleted
inserted
replaced
| 24:4869fae20b88 | 25:4b2bc456ce42 |
|---|---|
| 406 }; | 406 }; |
| 407 if ($this->rc->config->get('message_threading')[$mbox]) { | 407 if ($this->rc->config->get('message_threading')[$mbox]) { |
| 408 // The threading information is contained in three fields: | 408 // The threading information is contained in three fields: |
| 409 // depth, parent_uid and uid | 409 // depth, parent_uid and uid |
| 410 // I _think_ if you gave every depth0 message its dates as key | 410 // I _think_ if you gave every depth0 message its dates as key |
| 411 // every depth>0 its date as key | 411 // every depth>0 [already sorted by date, see list.inc:71] |
| 412 // Then first sort all the depth0 messages into a new array | 412 // Then first sort all the depth0 messages into a new array |
| 413 // then iterate over them, pull all depth1 with shared parent and sort _them, | 413 // then iterate over them, pull all depth1 with shared parent |
| 414 // insert after parent | 414 // insert after parent |
| 415 // repeat at depth 1, etc. | 415 // repeat at depth 1, etc. |
| 416 $sm = array(); // sorted result accumulates here | |
| 417 $rm = array(); // unprocessed remnant | |
| 418 foreach ($args['messages'] as $m) { | |
| 419 if ($m->depth===0) { | |
| 420 $sm[]=$m; | |
| 421 } | |
| 422 else { | |
| 423 $rm[]=$m; | |
| 424 } | |
| 425 } | |
| 426 rcube::write_log($this->name,"ts0: |".$rm[0]->depth."| |".($rm[0]->depth===0)."|"); | |
| 427 usort($sm,$datesSort); | |
| 428 $depth=0; | |
| 429 $foundSome=true; | |
| 430 while ($foundSome) { | |
| 431 rcube::write_log($this->name,"ts: $depth ".count($sm).' '.count($rm)); | |
| 432 $foundSome=false; | |
| 433 $tsm = array(); | |
| 434 $trm = array(); | |
| 435 foreach ($sm as $m) { | |
| 436 $tsm[]=$m; | |
| 437 if ($m->depth===$depth) { | |
| 438 $puid = $m->uid; | |
| 439 foreach ($rm as $c) { | |
| 440 if ($c->parent_uid===$puid) { | |
| 441 $tsm[]=$c; | |
| 442 $foundSome=true; | |
| 443 } | |
| 444 else { | |
| 445 $trm[]=$c; | |
| 446 } | |
| 447 } | |
| 448 $rm = $trm; | |
| 449 $trm = array(); | |
| 450 } | |
| 451 } | |
| 452 $sm = $tsm; | |
| 453 $depth+=1; | |
| 454 } | |
| 455 $args['messages']=$sm; | |
| 416 } | 456 } |
| 417 else { | 457 else { |
| 418 usort($args['messages'],$datesSort); | 458 usort($args['messages'],$datesSort); |
| 419 } | 459 } |
| 420 } | 460 } |
