r898: Moving the build_*() calls to the APIs
[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/api_status.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 $status = new StatusAPI($bugsys);
42 $status->set('statusid', $bugsys->in['statusid']);
43 $status->set_condition();
44 $status->delete();
45
46 $admin->redirect('status.php?do=modify');
47 }
48
49 // ###################################################################
50
51 if ($_REQUEST['do'] == 'delete')
52 {
53 $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));
54 }
55
56 // ###################################################################
57
58 if ($_POST['do'] == 'insert')
59 {
60 $status = new StatusAPI($bugsys);
61 $status->set('status', $bugsys->in['status']);
62 $status->set('color', $bugsys->in['color']);
63 $status->set('displayorder', $bugsys->in['displayorder']);
64 $status->insert();
65
66 $admin->redirect('status.php?do=modify');
67 }
68
69 // ###################################################################
70
71 if ($_REQUEST['do'] == 'add')
72 {
73 $admin->page_start($lang->string('Add New Status'));
74
75 $admin->form_start('status.php', 'insert');
76 $admin->table_start();
77 $admin->table_head($lang->string('New Status'), 2, 'standard_bug_fields');
78 $admin->row_input($lang->string('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status');
79 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder');
80 $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');
81 $admin->row_submit();
82 $admin->table_end();
83 $admin->form_end();
84
85 $admin->page_end();
86 }
87
88 // ###################################################################
89
90 if ($_POST['do'] == 'update')
91 {
92 $status = new StatusAPI($bugsys);
93 $status->set('statusid', $bugsys->in['statusid']);
94 $status->set_condition();
95 $status->set('status', $bugsys->in['status']);
96 $status->set('color', $bugsys->in['color']);
97 $status->set('displayorder', $bugsys->in['displayorder']);
98 $status->update();
99
100 $admin->redirect('status.php?do=modify');
101 }
102
103 // ###################################################################
104
105 if ($_REQUEST['do'] == 'edit')
106 {
107 $status = new StatusAPI($bugsys);
108 $status->set('statusid', $bugsys->in['statusid']);
109 $status->set_condition();
110 $status->fetch();
111
112 $admin->page_start($lang->string('Edit Status'));
113
114 $admin->form_start('status.php', 'update');
115 $admin->form_hidden_field('statusid', $status->objdata['statusid']);
116 $admin->table_start();
117 $admin->table_head(sprintf($lang->string('Edit Status - %1$s (id: %2$s)'), $status->objdata['status'], $status->objdata['statusid']), 2, 'standard_bug_fields');
118 $admin->row_input($lang->string('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status', $status->objdata['status']);
119 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder', $status->objdata['displayorder']);
120 $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->objdata['color']);
121 $admin->row_submit();
122 $admin->table_end();
123 $admin->form_end();
124
125 $admin->page_end();
126 }
127
128 // ###################################################################
129
130 if ($_REQUEST['do'] == 'modify')
131 {
132 $admin->page_start($lang->string('Status Manager'));
133
134 $statuses = $db->query("SELECT * FROM " . TABLE_PREFIX . "status");
135
136 $admin->table_start();
137 $admin->table_head($lang->string('Status Manager'), 2, 'standard_bug_fields');
138
139 while ($status = $db->fetch_array($statuses))
140 {
141 $colourblock = '<span style="float: right"><div style="height: 12px; width: 12px; background-color: ' . $status['color'] . '; border: 1px black solid"></div></span>';
142 $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>");
143 }
144 $db->free_result($statuses);
145
146 $admin->row_span('<a href="status.php?do=add">[' . $lang->string('Add New Status') . ']</a>', 'tfoot', 'center', 3);
147 $admin->table_end();
148
149 $admin->page_end();
150 }
151
152 /*=====================================================================*\
153 || ###################################################################
154 || # $HeadURL$
155 || # $Id$
156 || ###################################################################
157 \*=====================================================================*/
158 ?>