r887: Removing all the annoying calls to intval() in place of ISSO's cleaning framework
[bugdar.git] / admin / status.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 . "status WHERE statusid = " . $bugsys->input_clean('statusid', TYPE_UINT));
42 build_statuses();
43 $admin->redirect('status.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 status? Doing so will revert all bugs to the default status (which is set in the options panel)?'), 'status.php?do=kill&amp;statusid=' . $bugsys->input_clean('statusid', TYPE_UINT));
51 }
52
53 // ###################################################################
54
55 if ($_POST['do'] == 'insert')
56 {
57 $db->query("INSERT INTO " . TABLE_PREFIX . "status (status, displayorder, color) VALUES ('" . $bugsys->in['status'] . "', " . $bugsys->input_clean('displayorder', TYPE_UINT) . ", '" . $bugsys->in['color'] . "')");
58 build_statuses();
59 $admin->redirect('status.php?do=modify');
60 }
61
62 // ###################################################################
63
64 if ($_REQUEST['do'] == 'add')
65 {
66 $admin->page_start($lang->string('Add New Status'));
67
68 $admin->form_start('status.php', 'insert');
69 $admin->table_start();
70 $admin->table_head($lang->string('New Status'), 2, 'standard_bug_fields');
71 $admin->row_input($lang->string('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status');
72 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder');
73 $admin->row_input($lang->string('Status Colour<div><dfn>The colour 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');
74 $admin->row_submit();
75 $admin->table_end();
76 $admin->form_end();
77
78 $admin->page_end();
79 }
80
81 // ###################################################################
82
83 if ($_POST['do'] == 'update')
84 {
85 $db->query("UPDATE " . TABLE_PREFIX . "status SET status = '" . $bugsys->in['status'] . "', displayorder = " . $bugsys->input_clean('displayorder']) . ", color = '" . $bugsys->in['color'] . "' WHERE statusid = " . intval1($bugsys->in['statusid', TYPE_UINT));
86 build_statuses();
87 $admin->redirect('status.php?do=modify');
88 }
89
90 // ###################################################################
91
92 if ($_REQUEST['do'] == 'edit')
93 {
94 $status = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "status WHERE statusid = " . $bugsys->input_clean('statusid', TYPE_UINT));
95 if (!is_array($status))
96 {
97 $admin->error($lang->getlex('error_invalid_id'));
98 }
99
100 $admin->page_start($lang->string('Edit Status'));
101
102 $admin->form_start('status.php', 'update');
103 $admin->form_hidden_field('statusid', $status['statusid']);
104 $admin->table_start();
105 $admin->table_head(sprintf($lang->string('Edit Status - %1$s (id: %2$s)'), $status['status'], $status['statusid']), 2, 'standard_bug_fields');
106 $admin->row_input($lang->string('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status', $status['status']);
107 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder', $status['displayorder']);
108 $admin->row_input($lang->string('Status Colour<div><dfn>The colour 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['color']);
109 $admin->row_submit();
110 $admin->table_end();
111 $admin->form_end();
112
113 $admin->page_end();
114 }
115
116 // ###################################################################
117
118 if ($_REQUEST['do'] == 'modify')
119 {
120 $admin->page_start($lang->string('Status Manager'));
121
122 $statuses = $db->query("SELECT * FROM " . TABLE_PREFIX . "status");
123
124 $admin->table_start();
125 $admin->table_head($lang->string('Status Manager'), 2, 'standard_bug_fields');
126
127 while ($status = $db->fetch_array($statuses))
128 {
129 $colourblock = '<span style="float: right"><div style="height: 12px; width: 12px; background-color: ' . $status['color'] . '; border: 1px black solid"></div></span>';
130 $admin->row_text("$colourblock$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]\">[" . $lang->string('Edit') . "]</a> <a href=\"status.php?do=delete&amp;statusid=$status[statusid]\">[" . $lang->string('Delete') . "]</a>");
131 }
132 $db->free_result($statuses);
133
134 $admin->row_span('<a href="status.php?do=add">[' . $lang->string('Add New Status') . ']</a>', 'tfoot', 'center', 3);
135 $admin->table_end();
136
137 $admin->page_end();
138 }
139
140 /*=====================================================================*\
141 || ###################################################################
142 || # $HeadURL$
143 || # $Id$
144 || ###################################################################
145 \*=====================================================================*/
146 ?>