- Update the copyright notices to use the correct year and not a non-ASCII symbol
[bugdar.git] / includes / api_status.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2004-2008 Blue Static
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 2 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 require_once ISSO . '/Api.php';
23
24 require_once('./includes/functions_datastore.php');
25
26 /**
27 * API: Status
28 *
29 * @author Blue Static
30 * @copyright Copyright (c)2004 - 2008, Blue Static
31 * @package Bugdar
32 *
33 */
34 class StatusAPI extends BSApi
35 {
36 /**
37 * Fields
38 * @var array
39 */
40 protected $fields = array(
41 'statusid' => array(TYPE_UINT, REQ_AUTO),
42 'status' => array(TYPE_STR, REQ_YES),
43 'color' => array(TYPE_STR, REQ_NO),
44 'displayorder' => array(TYPE_INT, REQ_NO)
45 );
46
47 /**
48 * Database table
49 * @var string
50 */
51 protected $table = 'status';
52
53 /**
54 * Table prefix
55 * @var string
56 */
57 protected $prefix = TABLE_PREFIX;
58
59 /**
60 * Post-insert
61 */
62 function post_insert()
63 {
64 build_statuses();
65 }
66
67 /**
68 * Post-update
69 */
70 protected function post_update()
71 {
72 build_statuses();
73 }
74
75 /**
76 * Post-delete
77 */
78 protected function post_delete()
79 {
80 build_statuses();
81 BSApp::$db->query("UPDATE " . TABLE_PREFIX . "bug SET status = " . bugdar::$options['defaultstatus'] . " WHERE status = " . $this->values['statusid']);
82 }
83
84 /**
85 * Validate: statusid
86 */
87 protected function validate_statusid($field)
88 {
89 return $this->_verifyIsNotZero($field);
90 }
91
92 /**
93 * Validate: status
94 */
95 protected function validate_status($field)
96 {
97 return $this->_verifyIsNotEmpty($field);
98 }
99 }
100
101 ?>