Replace *API($bugsys) with API()
[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 require_once('./includes/class_api_error.php');
26 APIError(array(new API_Error_Handler($admin), 'admin_error'));
27
28 NavLinks::fieldsPages();
29 $navigator->set_focus('tab', 'fields', null);
30
31 if (!can_perform('canadminfields'))
32 {
33 admin_login();
34 }
35
36 // ###################################################################
37
38 if (empty($_REQUEST['do']))
39 {
40 $_REQUEST['do'] = 'modify';
41 }
42
43 // ###################################################################
44
45 if ($_REQUEST['do'] == 'kill')
46 {
47 $severity = new SeverityAPI();
48 $severity->set('severityid', $input->in['severityid']);
49 $severity->set_condition();
50 $severity->delete();
51
52 $admin->redirect('severity.php?do=modify');
53 }
54
55 // ###################################################################
56
57 if ($_REQUEST['do'] == 'delete')
58 {
59 $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)));
60 }
61
62 // ###################################################################
63
64 if ($_POST['do'] == 'insert')
65 {
66 $severity = new SeverityAPI();
67 $severity->set('severity', $input->in['severity']);
68 $severity->set('displayorder', $input->in['displayorder']);
69 $severity->insert();
70
71 $admin->redirect('severity.php?do=modify');
72 }
73
74 // ###################################################################
75
76 if ($_REQUEST['do'] == 'add')
77 {
78 NavLinks::severitiesAdd();
79 $navigator->set_focus('link', 'severities-add', 'severities');
80
81 $admin->page_start(T('Add New Severity'));
82
83 $admin->form_start('severity.php', 'insert');
84 $admin->table_start();
85 $admin->table_head(T('New Severity'));
86 $admin->row_input(T('Severity Title<div><dfn>The title of this severity flag (eg: `Major` or `Critical`)</dfn></div>'), 'severity');
87 $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');
88 $admin->row_submit();
89 $admin->table_end();
90 $admin->form_end();
91
92 $admin->page_end();
93 }
94
95 // ###################################################################
96
97 if ($_POST['do'] == 'update')
98 {
99 $severity = new SeverityAPI();
100 $severity->set('severityid', $input->in['severityid']);
101 $severity->set_condition();
102 $severity->set('severity', $input->in['severity']);
103 $severity->set('displayorder', $input->in['displayorder']);
104 $severity->update();
105
106 $admin->redirect('severity.php?do=modify');
107 }
108
109 // ###################################################################
110
111 if ($_REQUEST['do'] == 'edit')
112 {
113 NavLinks::severitiesEdit($input->in['severityid']);
114 $navigator->set_focus('link', 'fields-pages-severities', 'fields-pages');
115
116 $severity = new SeverityAPI();
117 $severity->set('severityid', $input->in['severityid']);
118 $severity->set_condition();
119 $severity->fetch();
120
121 $admin->page_start(T('Edit Severity'));
122
123 $admin->form_start('severity.php', 'update');
124 $admin->form_hidden_field('severityid', $severity->record['severityid']);
125 $admin->table_start();
126 $admin->table_head(sprintf(T('Edit Severity - %1$s (id: %2$s)'), $severity->record['severity'], $severity->record['severityid']));
127 $admin->row_input(T('Severity Title<div><dfn>The title of this severity flag (eg: `Major` or `Critical`)</dfn></div>'), 'severity', $severity->record['severity']);
128 $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']);
129 $admin->row_submit();
130 $admin->table_end();
131 $admin->form_end();
132
133 $admin->page_end();
134 }
135
136 // ###################################################################
137
138 if ($_REQUEST['do'] == 'modify')
139 {
140 NavLinks::severitiesAdd();
141 $navigator->set_focus('link', 'fields-pages-severities', 'fields-pages');
142
143 $admin->page_start(T('Severity Manager'));
144
145 $severities = $db->query("SELECT * FROM " . TABLE_PREFIX . "severity ORDER BY displayorder");
146
147 $admin->form_start('severity.php', 'null');
148 $admin->table_start();
149 $admin->table_head(T('Severity Manager'));
150
151 foreach ($severities as $severity)
152 {
153 $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>");
154 }
155 $db->free_result($severities);
156
157 $admin->table_end();
158 $admin->form_end();
159
160 $admin->page_end();
161 }
162
163 /*=====================================================================*\
164 || ###################################################################
165 || # $HeadURL$
166 || # $Id$
167 || ###################################################################
168 \*=====================================================================*/
169 ?>