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