1<?php
2/*********************************************************************
3    class.priority.php
4
5    Priority handle
6
7    Peter Rotich <peter@osticket.com>
8    Copyright (c)  2006-2013 osTicket
9    http://www.osticket.com
10
11    Released under the GNU General Public License WITHOUT ANY WARRANTY.
12    See LICENSE.TXT for details.
13
14    vim: expandtab sw=4 ts=4 sts=4:
15**********************************************************************/
16
17class Priority extends VerySimpleModel
18implements TemplateVariable {
19
20    static $meta = array(
21        'table' => PRIORITY_TABLE,
22        'pk' => array('priority_id'),
23        'ordering' => array('-priority_urgency')
24    );
25
26    function getId() {
27        return $this->priority_id;
28    }
29
30    function getTag() {
31        return $this->priority;
32    }
33
34    function getDesc() {
35        return $this->priority_desc;
36    }
37
38    function getColor() {
39        return $this->priority_color;
40    }
41
42    function getUrgency() {
43        return $this->priority_urgency;
44    }
45
46    function isPublic() {
47        return $this->ispublic;
48    }
49
50    // TemplateVariable interface
51    function asVar() { return $this->getDesc(); }
52    static function getVarScope() {
53        return array(
54            'desc' => __('Priority Level'),
55        );
56    }
57
58    function __toString() {
59        return $this->getDesc();
60    }
61
62    /* ------------- Static ---------------*/
63    static function getPriorities( $publicOnly=false) {
64        $priorities=array();
65
66        $objects = static::objects()->values_flat('priority_id', 'priority_desc');
67        if ($publicOnly)
68            $objects->filter(array('ispublic'=>1));
69
70        foreach ($objects as $row) {
71            $priorities[$row[0]] = $row[1];
72        }
73
74        return $priorities;
75    }
76
77    function getPublicPriorities() {
78        return self::getPriorities(true);
79    }
80}
81?>
82