r796: Parse error: syntax error, unexpected ';', expecting ')' in /Server/htdocs...
[bugdar.git] / includes / api_bug.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
6 || #
7 || # This program 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; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 $GLOBALS['isso:callback']->load('api', null);
23
24 /**
25 * API: Bug
26 *
27 * Note: When priority, esverity, status, and resolution should throw a
28 * verification error, they actually set it to the default value
29 *
30 * @author Iris Studios, Inc.
31 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
32 * @version $Revision$
33 * @package Bugdar
34 *
35 */
36 class BugAPI extends API
37 {
38 /**
39 * Database fields
40 * @var array
41 * @access private
42 */
43 var $fields = array(
44 'bugid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'),
45 'userid' => array(TYPE_UINT, REQ_NO),
46 'dateline' => array(TYPE_UINT, REQ_SET),
47 'productid' => array(TYPE_UINT, REQ_YES, ':self'),
48 'componentid' => array(TYPE_UINT, REQ_NO, ':self'),
49 'versionid' => array(TYPE_UINT, REQ_YES, ':self'),
50 'summary' => array(TYPE_STR, REQ_YES, 'verify_noempty'),
51 'priority' => array(TYPE_UINT, REQ_NO, ':self'),
52 'severity' => array(TYPE_UINT, REQ_NO, ':self'),
53 'status' => array(TYPE_UINT, REQ_NO, ':self'),
54 'resolution' => array(TYPE_UINT, REQ_NO, ':self'),
55 'assignedto' => array(TYPE_UINT, REQ_NO, ':self', array('includes/api_user.php', 'UserAPI')),
56 'duplicateof' => array(TYPE_STR, REQ_NO),
57 'dependency' => array(TYPE_STR, REQ_NO),
58 'hidden' => array(TYPE_BOOL, REQ_NO),
59 'initialreport' => array(TYPE_UINT, REQ_NO),
60 'lastposttime' => array(TYPE_UINT, REQ_NO),
61 'lastpostby' => array(TYPE_UINT, REQ_NO),
62 'hiddenlastposttime' => array(TYPE_UINT, REQ_NO),
63 'hiddenlastpostby' => array(TYPE_UINT, REQ_NO)
64 );
65
66 /**
67 * Database table
68 * @var string
69 * @access private
70 */
71 var $table = 'bug';
72
73 /**
74 * Table prefix
75 * @var string
76 * @access private
77 */
78 var $prefix = TABLE_PREFIX;
79
80 // ###################################################################
81 /**
82 * Set field: dateline
83 *
84 * @access private
85 */
86 function set_dateline()
87 {
88 $this->set('dateline', time());
89 }
90
91 // ###################################################################
92 /**
93 * Verify: productid
94 *
95 * @access private
96 */
97 function verify_productid()
98 {
99 $this->verify_nozero('productid');
100
101 if (!$this->registry->datastore['product'][ $this->values['productid'] ])
102 {
103 return false;
104 }
105 return true;
106 }
107
108 // ###################################################################
109 /**
110 * Verify: componentid
111 *
112 * @access private
113 */
114 function verify_componentid()
115 {
116 if ($this->values['componentid'] != 0)
117 {
118 $product = $this->registry->datastore['product'][ $this->values['product'] ];
119 $version = $this->registry->datastore['version'][ $this->values['version'] ];
120 if ($component['componentmother'] != $product['productid'])
121 {
122 return false;
123 }
124 if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
125 {
126 return false;
127 }
128 }
129 return true;
130 }
131
132 // ###################################################################
133 /**
134 * Verify: versionid
135 *
136 * @access private
137 */
138 function verify_versionid()
139 {
140 $this->verify_nozero('versionid');
141
142 if (!$this->registry->datastore['version'][ $this->values['versionid'] ])
143 {
144 return false;
145 }
146 return true;
147 }
148
149 // ###################################################################
150 /**
151 * Verify: priority
152 *
153 * @access private
154 */
155 function verify_priority()
156 {
157 if (!$this->registry->datastore['priority'][ $this->values['priority'] ])
158 {
159 $this->set('priority', $this->registry->options['defaultpriority']);
160 }
161 return true;
162 }
163
164 // ###################################################################
165 /**
166 * Verify: severity
167 *
168 * @access private
169 */
170 function verify_severity()
171 {
172 if (!$this->registry->datastore['severity'][ $this->values['severity'] ])
173 {
174 $this->set('priority', $this->registry->options['defaultseverity']);
175 }
176 return true;
177 }
178
179 // ###################################################################
180 /**
181 * Verify: status
182 *
183 * @access private
184 */
185 function verify_status()
186 {
187 if (!$this->registry->datastore['status'][ $this->values['status'] ])
188 {
189 $this->set('priority', $this->registry->options['defaultstatus']);
190 }
191 return true;
192 }
193
194 // ###################################################################
195 /**
196 * Verify: resolution
197 *
198 * @access private
199 */
200 function verify_resolution()
201 {
202 if (!$this->registry->datastore['resolution'][ $this->values['resolution'] ])
203 {
204 $this->set('priority', $this->registry->options['defaultresolve']);
205 }
206 return true;
207 }
208
209 // ###################################################################
210 /**
211 * Verify: assignedto
212 *
213 * @access private
214 */
215 function verify_assignedto()
216 {
217 if (!$this->registry->datastore['assignedto'][ $this->values['assignedto'] ]['userid'])
218 {
219 $this->set('priority', $this->registry->options['defaultassign']);
220 }
221 return true;
222 }
223 }
224
225 /*=====================================================================*\
226 || ###################################################################
227 || # $HeadURL$
228 || # $Id$
229 || ###################################################################
230 \*=====================================================================*/
231 ?>