Remove includes/class_api_error.php and all of the places we require() it
[bugdar.git] / admin / severity.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_severity.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 $severity = new SeverityAPI();
47 $severity->set('severityid', $input->in['severityid']);
48 $severity->set_condition();
49 $severity->delete();
50
51 $admin->redirect('severity.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 severity? Doing so will revert all bugs to the default severity (which is set in the options panel)?'), 'severity.php', 'kill', array('severityid' => $input->inputClean('severityid', TYPE_UINT)));
59 }
60
61 // ###################################################################
62
63 if ($_POST['do'] == 'insert')
64 {
65 $severity = new SeverityAPI();
66 $severity->set('severity', $input->in['severity']);
67 $severity->set('displayorder', $input->in['displayorder']);
68 $severity->insert();
69
70 $admin->redirect('severity.php?do=modify');
71 }
72
73 // ###################################################################
74
75 if ($_REQUEST['do'] == 'add')
76 {
77 NavLinks::severitiesAdd();
78 $navigator->set_focus('link', 'severities-add', 'severities');
79
80 $admin->page_start(T('Add New Severity'));
81
82 $admin->form_start('severity.php', 'insert');
83 $admin->table_start();
84 $admin->table_head(T('New Severity'));
85 $admin->row_input(T('Severity Title<div><dfn>The title of this severity flag (eg: `Major` or `Critical`)</dfn></div>'), 'severity');
86 $admin->row_input(T('Display Order<div><dfn>The order in which the severities are displayed. The higher the number, the lower down in the list it is.</dfn></div>'), 'displayorder');
87 $admin->row_submit();
88 $admin->table_end();
89 $admin->form_end();
90
91 $admin->page_end();
92 }
93
94 // ###################################################################
95
96 if ($_POST['do'] == 'update')
97 {
98 $severity = new SeverityAPI();
99 $severity->set('severityid', $input->in['severityid']);
100 $severity->set_condition();
101 $severity->set('severity', $input->in['severity']);
102 $severity->set('displayorder', $input->in['displayorder']);
103 $severity->update();
104
105 $admin->redirect('severity.php?do=modify');
106 }
107
108 // ###################################################################
109
110 if ($_REQUEST['do'] == 'edit')
111 {
112 NavLinks::severitiesEdit($input->in['severityid']);
113 $navigator->set_focus('link', 'fields-pages-severities', 'fields-pages');
114
115 $severity = new SeverityAPI();
116 $severity->set('severityid', $input->in['severityid']);
117 $severity->set_condition();
118 $severity->fetch();
119
120 $admin->page_start(T('Edit Severity'));
121
122 $admin->form_start('severity.php', 'update');
123 $admin->form_hidden_field('severityid', $severity->record['severityid']);
124 $admin->table_start();
125 $admin->table_head(sprintf(T('Edit Severity - %1$s (id: %2$s)'), $severity->record['severity'], $severity->record['severityid']));
126 $admin->row_input(T('Severity Title<div><dfn>The title of this severity flag (eg: `Major` or `Critical`)</dfn></div>'), 'severity', $severity->record['severity']);
127 $admin->row_input(T('Display Order<div><dfn>The order in which the severities are displayed. The higher the number, the lower down in the list it is.</dfn></div>'), 'displayorder', $severity->record['displayorder']);
128 $admin->row_submit();
129 $admin->table_end();
130 $admin->form_end();
131
132 $admin->page_end();
133 }
134
135 // ###################################################################
136
137 if ($_REQUEST['do'] == 'modify')
138 {
139 NavLinks::severitiesAdd();
140 $navigator->set_focus('link', 'fields-pages-severities', 'fields-pages');
141
142 $admin->page_start(T('Severity Manager'));
143
144 $severities = $db->query("SELECT * FROM " . TABLE_PREFIX . "severity ORDER BY displayorder");
145
146 $admin->form_start('severity.php', 'null');
147 $admin->table_start();
148 $admin->table_head(T('Severity Manager'));
149
150 foreach ($severities as $severity)
151 {
152 $admin->row_text("$severity[displayorder]: <a href=\"severity.php?do=edit&amp;severityid=$severity[severityid]\">$severity[severity]</a>", "(severityid: $severity[severityid]) <a href=\"severity.php?do=edit&amp;severityid=$severity[severityid]\">[" . T('Edit') . "]</a> <a href=\"severity.php?do=delete&amp;severityid=$severity[severityid]\">[" . T('Delete') . "]</a>");
153 }
154 $db->free_result($severities);
155
156 $admin->table_end();
157 $admin->form_end();
158
159 $admin->page_end();
160 }
161
162 /*=====================================================================*\
163 || ###################################################################
164 || # $HeadURL$
165 || # $Id$
166 || ###################################################################
167 \*=====================================================================*/
168 ?>