PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Libraries / Imap2 / Roundcube / MessageHeaderSorter.php

MessageHeaderSorter.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.1.0, at back/Libraries/Imap2/Roundcube/MessageHeaderSorter.php

55 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Libraries\Imap2\Roundcube;
4
5 /**
6 * Class for sorting an array of MessageHeader objects in a predetermined order.
7 *
8 * @package Framework
9 * @subpackage Storage
10 * @author Aleksander Machniak <[email protected]>
11 */
12 class MessageHeaderSorter
13 {
14 private $uids = [];
15
16
17 /**
18 * Set the predetermined sort order.
19 *
20 * @param array $index Numerically indexed array of IMAP UIDs
21 */
22 function set_index($index)
23 {
24 $index = array_flip($index);
25
26 $this->uids = $index;
27 }
28
29 /**
30 * Sort the array of header objects
31 *
32 * @param array $headers Array of MessageHeader objects indexed by UID
33 */
34 function sort_headers(&$headers)
35 {
36 uksort($headers, [$this, "compare_uids"]);
37 }
38
39 /**
40 * Sort method called by uksort()
41 *
42 * @param int $a Array key (UID)
43 * @param int $b Array key (UID)
44 */
45 function compare_uids($a, $b)
46 {
47 // then find each sequence number in my ordered list
48 $posa = isset($this->uids[$a]) ? intval($this->uids[$a]) : -1;
49 $posb = isset($this->uids[$b]) ? intval($this->uids[$b]) : -1;
50
51 // return the relative position as the comparison value
52 return $posa - $posb;
53 }
54 }
55