1: <?php
2: /**
3: * Copyright 2009-2014 Horde LLC (http://www.horde.org/)
4: *
5: * See the enclosed file COPYING for license information (GPL). If you
6: * did not receive this file, see http://www.horde.org/licenses/gpl.
7: *
8: * @category Horde
9: * @copyright 2009-2014 Horde LLC
10: * @license http://www.horde.org/licenses/gpl GPL
11: * @package IMP
12: */
13:
14: /**
15: * Code for manipulating/parsing MIME header data.
16: *
17: * @author Michael Slusarz <slusarz@horde.org>
18: * @category Horde
19: * @copyright 2009-2014 Horde LLC
20: * @license http://www.horde.org/licenses/gpl GPL
21: * @package IMP
22: */
23: class IMP_Mime_Headers
24: {
25: /**
26: * Determines the priority of the message based on the headers.
27: *
28: * @param Horde_Mime_Headers $header The headers object.
29: *
30: * @return string 'high', 'low', or 'normal'.
31: */
32: public function getPriority($header)
33: {
34: if (($xpriority = $header->getValue('x-priority')) &&
35: (preg_match('/\s*(\d+)\s*/', $xpriority, $matches))) {
36: if (in_array($matches[1], array(1, 2))) {
37: return 'high';
38: } elseif (in_array($matches[1], array(4, 5))) {
39: return 'low';
40: }
41: } elseif (($importance = $header->getValue('importance')) &&
42: preg_match('/:\s*(\w+)\s*/', $importance, $matches)) {
43: if (strcasecmp($matches[1], 'high') === 0) {
44: return 'high';
45: } elseif (strcasecmp($matches[1], 'low') === 0) {
46: return 'low';
47: }
48: }
49:
50: return 'normal';
51: }
52:
53: }
54: