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