Remove includes/class_api_error.php and all of the places we require() it
[bugdar.git] / admin / 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('./global.php');
23 require_once('./includes/api_status.php');
24
25 APIError(array(new API_Error_Handler($admin), 'admin_error'));
26
27 NavLinks::fieldsPages();
28 $navigator->set_focus('tab', 'fields', null);
29
30 if (!can_perform('canadminfields'))
31 {
32 admin_login();
33 }
34
35 // ###################################################################
36
37 if (empty($_REQUEST['do']))
38 {
39 $_REQUEST['do'] = 'modify';
40 }
41
42 // ###################################################################
43
44 if ($_REQUEST['do'] == 'kill')
45 {
46 $status = new StatusAPI();
47 $status->set('statusid', $input->in['statusid']);
48 $status->set_condition();
49 $status->delete();
50
51 $admin->redirect('status.php?do=modify');
52 }
53
54 // ###################################################################
55
56 if ($_REQUEST['do'] == 'delete')
57 {
58 $admin->page_confirm(T('Are you sure you want to delete this status? Doing so will revert all bugs to the default status (which is set in the options panel)?'), 'status.php', 'kill', array('statusid' => $input->inputClean('statusid', TYPE_UINT)));
59 }
60
61 // ###################################################################
62
63 if ($_POST['do'] == 'insert')
64 {
65 $status = new StatusAPI();
66 $status->set('status', $input->in['status']);
67 $status->set('color', $input->in['color']);
68 $status->set('displayorder', $input->in['displayorder']);
69 $status->insert();
70
71 $admin->redirect('status.php?do=modify');
72 }
73
74 // ###################################################################
75
76 if ($_REQUEST['do'] == 'add')
77 {
78 NavLinks::statusesAdd();
79 $navigator->set_focus('link', 'statuses-add', 'statuses');
80
81 $admin->page_start(T('Add New Status'));
82
83 $admin->form_start('status.php', 'insert');
84 $admin->table_start();
85 $admin->table_head(T('New Status'));
86 $admin->row_input(T('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status');
87 $admin->row_input(T('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder');
88 $admin->row_input(T('Status Color<div><dfn>The color of the status. This will be displayed on bug listings page to make viewing easier. Note: you must enter the # sign if you are using HEX values.</dfn></div>'), 'color');
89 $admin->row_submit();
90 $admin->table_end();
91 $admin->form_end();
92
93 $admin->page_end();
94 }
95
96 // ###################################################################
97
98 if ($_POST['do'] == 'update')
99 {
100 $status = new StatusAPI();
101 $status->set('statusid', $input->in['statusid']);
102 $status->set_condition();
103 $status->set('status', $input->in['status']);
104 $status->set('color', $input->in['color']);
105 $status->set('displayorder', $input->in['displayorder']);
106 $status->update();
107
108 $admin->redirect('status.php?do=modify');
109 }
110
111 // ###################################################################
112
113 if ($_REQUEST['do'] == 'edit')
114 {
115 NavLinks::statusesEdit($input->in['statusid']);
116 $navigator->set_focus('link', 'fields-pages-statuses', 'fields-pages');
117
118 $status = new StatusAPI();
119 $status->set('statusid', $input->in['statusid']);
120 $status->set_condition();
121 $status->fetch();
122
123 $admin->page_start(T('Edit Status'));
124
125 $admin->form_start('status.php', 'update');
126 $admin->form_hidden_field('statusid', $status->record['statusid']);
127 $admin->table_start();
128 $admin->table_head(sprintf(T('Edit Status - %1$s (id: %2$s)'), $status->record['status'], $status->record['statusid']));
129 $admin->row_input(T('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status', $status->record['status']);
130 $admin->row_input(T('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder', $status->record['displayorder']);
131 $admin->row_input(T('Status Color<div><dfn>The color of the status. This will be displayed on bug listings page to make viewing easier. Note: you must enter the # sign if you are using HEX values.</dfn></div>'), 'color', $status->record['color']);
132 $admin->row_submit();
133 $admin->table_end();
134 $admin->form_end();
135
136 $admin->page_end();
137 }
138
139 // ###################################################################
140
141 if ($_REQUEST['do'] == 'modify')
142 {
143 NavLinks::statusesAdd();
144 $navigator->set_focus('link', 'fields-pages-statuses', 'fields-pages');
145
146 $admin->page_start(T('Status Manager'));
147
148 $statuses = $db->query("SELECT * FROM " . TABLE_PREFIX . "status");
149
150 $admin->table_start();
151 $admin->table_head(T('Status Manager'));
152
153 foreach ($statuses as $status)
154 {
155 $colorblock = '<span style="float: right"><div style="height: 12px; width: 12px; background-color: ' . $status['color'] . '; border: 1px black solid"></div></span>';
156 $admin->row_text("$colorblock$status[displayorder]: <a href=\"status.php?do=edit&amp;statusid=$status[statusid]\">$status[status]</a>", "(statusid: $status[statusid]) <a href=\"status.php?do=edit&amp;statusid=$status[statusid]\">[" . T('Edit') . "]</a> <a href=\"status.php?do=delete&amp;statusid=$status[statusid]\">[" . T('Delete') . "]</a>");
157 }
158 $db->free_result($statuses);
159
160 $admin->table_end();
161
162 $admin->page_end();
163 }
164
165 /*=====================================================================*\
166 || ###################################################################
167 || # $HeadURL$
168 || # $Id$
169 || ###################################################################
170 \*=====================================================================*/
171 ?>