Newer
Older
<?php
/*********************************************************************
class.priority.php
Priority handle
Peter Rotich <peter@osticket.com>
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
class Priority {
var $id;
var $ht;
function Priority($id){
$this->id =0;
$this->load($id);
}
function load($id) {
if(!$id && !($id=$this->getId()))
return false;
$sql='SELECT * FROM '.PRIORITY_TABLE
.' WHERE priority_id='.db_input($id);
if(!($res=db_query($sql)) || !db_num_rows($res))
return false;
$this->ht= db_fetch_array($res);
$this->id= $this->ht['priority_id'];
return true;;
}
function getId() {
return $this->id;
}
function getTag() {
return $this->ht['priority'];
}
function getDesc() {
return $this->ht['priority_desc'];
}
function getColor() {
return $this->ht['priority_color'];
}
function getUrgency() {
return $this->ht['priority_urgency'];
}
function isPublic() {
return ($this->ht['ispublic']);
}
/* ------------- Static ---------------*/
function lookup($id) {
return ($id && is_numeric($id) && ($p=new Priority($id)) && $p->getId()==$id)?$p:null;
}
function getPriorities( $publicOnly=false) {
$priorities=array();
$sql ='SELECT priority_id, priority_desc FROM '.PRIORITY_TABLE;
if($publicOnly)
$sql.=' WHERE ispublic=1';
if(($res=db_query($sql)) && db_num_rows($res)) {
while(list($id, $name)=db_fetch_row($res))
$priorities[$id] = $name;
}
return $priorities;
}
function getPublicPriorities() {
return self::getPriorities(true);
}
}
?>