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