File:
0.00.1a/core/request/RequestBase.php (
View as Code)
1: 2: /* -------------------------------------------------------------
3: This file is part of FreeDESK
4:
5: FreeDESK is (C) Copyright 2012 David Cutting
6:
7: FreeDESK is free software: you can redistribute it and/or modify
8: it under the terms of the GNU General Public License as published by
9: the Free Software Foundation, either version 3 of the License, or
10: (at your option) any later version.
11:
12: FreeDESK is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU General Public License for more details.
16:
17: You should have received a copy of the GNU General Public License
18: along with FreeDESK. If not, see www.gnu.org/licenses
19:
20: For more information see www.purplepixie.org/freedesk/
21: -------------------------------------------------------------- */
22:
23: /**
24: * Abstract Request base class for all request classes
25: **/
26: abstract class RequestBase
27: {
28: /**
29: * Current FreeDESK instance
30: **/
31: protected $DESK = null;
32:
33: /**
34: * Current Request ID
35: **/
36: var $ID = 0;
37:
38: /**
39: * Entity Data
40: **/
41: protected $Entity = null;
42:
43: /**
44: * Updates
45: **/
46: protected $Updates = null;
47:
48: /**
49: * Constructor
50: * @param mixed &$freeDESK Current FreeDESK instance
51: **/
52: function RequestBase(&$freeDESK)
53: {
54: $this->DESK = &$freeDESK;
55: }
56:
57: /**
58: * Create a request
59: * @param int $customer Customer ID
60: * @param string $update Initial Update
61: * @param int $class Request Class
62: * @param int $status Request status
63: * @param int $priority Priority Code (optional, default 0)
64: * @param int $group Request Group (optional, default 0)
65: * @param string $assign Assigned user (optional, default "")
66: * @return string Request ID
67: **/
68: abstract function Create($customer, $update, $class, $status, $priority=0, $group=0, $assign="");
69:
70: /**
71: * Update a request
72: * @param string $update Update text
73: * @param bool $public Public update (optional, default false)
74: **/
75: abstract function Update($update, $public=false);
76:
77: /**
78: * Change a request status
79: * @param int $status New status
80: * @param bool $public Public update (optional, default false)
81: **/
82: abstract function Status($status, $public=false);
83:
84: /**
85: * Assign a request
86: * @param int $group Group ID
87: * @param string $username Username (optional, default "")
88: * @param bool $public Public update (optional, default false)
89: **/
90: abstract function Assign($group, $username="", $public=false);
91:
92: /**
93: * Attach a file
94: * @param int $fileid File ID
95: * @param bool $public Public update (optional, default false)
96: **/
97: abstract function Attach($fileid, $public=false);
98:
99: /**
100: * Output XML
101: * @return string xml output
102: * @param bool $header Put XML header on output (optional, default false)
103: **/
104: abstract function XML($header=false);
105:
106: /**
107: * Set an entity value
108: * @param string $field Field ID
109: * @param string $value Value
110: **/
111: function Set($field, $value)
112: {
113: if ($this->Entity == null)
114: $this->Entity = new Entity($this->DESK);
115: $this->Entity->Set($field, $value);
116: }
117:
118: /**
119: * Get an entity value
120: * @param string $field Field ID
121: * @return mixed Value
122: **/
123: function Get($field)
124: {
125: $data = $this->Entity->GetData();
126: if (isset($data[$field]))
127: return $data[$field];
128: else
129: return false;
130: }
131:
132: /**
133: * Load updates for our ID
134: **/
135: function LoadUpdates()
136: {
137: $q="SELECT * FROM ".$this->DESK->Database->Table("update")." WHERE ";
138: $q.=$this->DESK->Database->Field("requestid")."=".$this->DESK->Database->Safe($this->ID)." ";
139: $q.="ORDER BY ".$this->DESK->Database->Field("updateid")." DESC";
140:
141: $this->Updates = array();
142:
143: $r=$this->DESK->Database->Query($q);
144:
145: while ($row=$this->DESK->Database->FetchAssoc($r))
146: $this->Updates[] = $row;
147:
148: $this->DESK->Database->Free($r);
149: }
150:
151: /**
152: * Get updates
153: * @return array Updates
154: **/
155: function GetUpdates()
156: {
157: if ($this->Updates == null)
158: $this->LoadUpdates();
159: return $this->Updates;
160: }
161:
162: }
163: ?>
164: