r887: Removing all the annoying calls to intval() in place of ISSO's cleaning framework
[bugdar.git] / admin / severity.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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 [#]gpl[#] 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/functions_datastore.php');
24
25 if (!can_perform('canadminfields'))
26 {
27 admin_login();
28 }
29
30 // ###################################################################
31
32 if (empty($_REQUEST['do']))
33 {
34 $_REQUEST['do'] = 'modify';
35 }
36
37 // ###################################################################
38
39 if ($_REQUEST['do'] == 'kill')
40 {
41 $db->query("DELETE FROM " . TABLE_PREFIX . "severity WHERE severityid = " . $bugsys->input_clean('serverityid', TYPE_UINT));
42 build_severities();
43 $admin->redirect('severity.php?do=modify');
44 }
45
46 // ###################################################################
47
48 if ($_REQUEST['do'] == 'delete')
49 {
50 $admin->page_confirm($lang->string('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?do=kill&amp;severityid=' . $bugsys->input_clean('severityid', TYPE_UINT));
51 }
52
53 // ###################################################################
54
55 if ($_POST['do'] == 'insert')
56 {
57 $db->query("INSERT INTO " . TABLE_PREFIX . "severity (severity, displayorder) VALUES ('" . $bugsys->in['severity'] . "', " . $bugsys->input_clean('displayorder', TYPE_UINT) . ")");
58 build_severities();
59 $admin->redirect('severity.php?do=modify');
60 }
61
62 // ###################################################################
63
64 if ($_REQUEST['do'] == 'add')
65 {
66 $admin->page_start($lang->string('Add New Severity'));
67
68 $admin->form_start('severity.php', 'insert');
69 $admin->table_start();
70 $admin->table_head($lang->string('New Severity'), 2, 'standard_bug_fields');
71 $admin->row_input($lang->string('Severity Title<div><dfn>The title of this severity flag (eg: `Major` or `Critical`)</dfn></div>'), 'severity');
72 $admin->row_input($lang->string('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');
73 $admin->row_submit();
74 $admin->table_end();
75 $admin->form_end();
76
77 $admin->page_end();
78 }
79
80 // ###################################################################
81
82 if ($_POST['do'] == 'update')
83 {
84 $db->query("UPDATE " . TABLE_PREFIX . "severity SET severity = '" . $bugsys->in['severity'] . "', displayorder = " . $bugsys->input_clean('displayorder']) . " WHERE severityid = " . intval1($bugsys->in['severityid', TYPE_UINT));
85 build_severities();
86 $admin->redirect('severity.php?do=modify');
87 }
88
89 // ###################################################################
90
91 if ($_REQUEST['do'] == 'edit')
92 {
93 $severity = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "severity WHERE severityid = " . $bugsys->input_clean('severityid', TYPE_UINT));
94 if (!is_array($severity))
95 {
96 $admin->error($lang->getlex('error_invalid_id'));
97 }
98
99 $admin->page_start($lang->string('Edit Severity'));
100
101 $admin->form_start('severity.php', 'update');
102 $admin->form_hidden_field('severityid', $severity['severityid']);
103 $admin->table_start();
104 $admin->table_head(sprintf($lang->string('Edit Severity - %1$s (id: %2$s)'), $severity['severity'], $severity['severityid']), 2, 'standard_bug_fields');
105 $admin->row_input($lang->string('Severity Title<div><dfn>The title of this severity flag (eg: `Major` or `Critical`)</dfn></div>'), 'severity', $severity['severity']);
106 $admin->row_input($lang->string('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['displayorder']);
107 $admin->row_submit();
108 $admin->table_end();
109 $admin->form_end();
110
111 $admin->page_end();
112 }
113
114 // ###################################################################
115
116 if ($_REQUEST['do'] == 'modify')
117 {
118 $admin->page_start($lang->string('Severity Manager'));
119
120 $severities = $db->query("SELECT * FROM " . TABLE_PREFIX . "severity ORDER BY displayorder");
121
122 $admin->form_start('severity.php', 'null');
123 $admin->table_start();
124 $admin->table_head($lang->string('Severity Manager'), 2, 'standard_bug_fields');
125
126 while ($severity = $db->fetch_array($severities))
127 {
128 $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]\">[" . $lang->string('Edit') . "]</a> <a href=\"severity.php?do=delete&amp;severityid=$severity[severityid]\">[" . $lang->string('Delete') . "]</a>");
129 }
130 $db->free_result($severityes);
131
132 $admin->row_span('<a href="severity.php?do=add">[' . $lang->string('Add New Severity') . ']</a>', 'tfoot', 'center', 3);
133 $admin->table_end();
134 $admin->form_end();
135
136 $admin->page_end();
137 }
138
139 /*=====================================================================*\
140 || ###################################################################
141 || # $HeadURL$
142 || # $Id$
143 || ###################################################################
144 \*=====================================================================*/
145 ?>