Update api_status.php
[bugdar.git] / includes / api_status.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright ©2002-2007 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 ©2002 - 2007, Blue Static
31 * @version $Revision$
32 * @package Bugdar
33 *
34 */
35 class StatusAPI extends BSApi
36 {
37 /**
38 * Fields
39 * @var array
40 */
41 protected $fields = array(
42 'statusid' => array(TYPE_UINT, REQ_AUTO),
43 'status' => array(TYPE_STR, REQ_YES),
44 'color' => array(TYPE_STR, REQ_NO),
45 'displayorder' => array(TYPE_INT, REQ_NO)
46 );
47
48 /**
49 * Database table
50 * @var string
51 */
52 protected $table = 'status';
53
54 /**
55 * Table prefix
56 * @var string
57 */
58 protected $prefix = TABLE_PREFIX;
59
60 /**
61 * Post-insert
62 */
63 function post_insert()
64 {
65 build_statuses();
66 }
67
68 /**
69 * Post-update
70 */
71 protected function post_update()
72 {
73 build_statuses();
74 }
75
76 /**
77 * Post-delete
78 */
79 protected function post_delete()
80 {
81 build_statuses();
82 BSApp::$db->query("UPDATE " . TABLE_PREFIX . "bug SET status = " . bugdar::$options['defaultstatus'] . " WHERE status = " . $this->values['statusid']);
83 }
84
85 /**
86 * Validate: statusid
87 */
88 protected function validate_statusid($field)
89 {
90 return $this->_verifyIsNotZero($field);
91 }
92
93 /**
94 * Validate: status
95 */
96 protected function validate_status($field)
97 {
98 return $this->_verifyIsNotEmpty($field);
99 }
100 }
101
102 /*=====================================================================*\
103 || ###################################################################
104 || # $HeadURL$
105 || # $Id$
106 || ###################################################################
107 \*=====================================================================*/
108 ?>