Changing BSApi->objdata[] to BSApi->record[]
[bugdar.git] / admin / status.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_status.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 $status = new StatusAPI($bugsys);
48 $status->set('statusid', $input->in['statusid']);
49 $status->set_condition();
50 $status->delete();
51
52 $admin->redirect('status.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 status? Doing so will revert all bugs to the default status (which is set in the options panel)?'), 'status.php', 'kill', array('statusid' => $input->inputClean('statusid', TYPE_UINT)));
60 }
61
62 // ###################################################################
63
64 if ($_POST['do'] == 'insert')
65 {
66 $status = new StatusAPI($bugsys);
67 $status->set('status', $input->in['status']);
68 $status->set('color', $input->in['color']);
69 $status->set('displayorder', $input->in['displayorder']);
70 $status->insert();
71
72 $admin->redirect('status.php?do=modify');
73 }
74
75 // ###################################################################
76
77 if ($_REQUEST['do'] == 'add')
78 {
79 NavLinks::statusesAdd();
80 $navigator->set_focus('link', 'statuses-add', 'statuses');
81
82 $admin->page_start(T('Add New Status'));
83
84 $admin->form_start('status.php', 'insert');
85 $admin->table_start();
86 $admin->table_head(T('New Status'));
87 $admin->row_input(T('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status');
88 $admin->row_input(T('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder');
89 $admin->row_input(T('Status Color<div><dfn>The color 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');
90 $admin->row_submit();
91 $admin->table_end();
92 $admin->form_end();
93
94 $admin->page_end();
95 }
96
97 // ###################################################################
98
99 if ($_POST['do'] == 'update')
100 {
101 $status = new StatusAPI($bugsys);
102 $status->set('statusid', $input->in['statusid']);
103 $status->set_condition();
104 $status->set('status', $input->in['status']);
105 $status->set('color', $input->in['color']);
106 $status->set('displayorder', $input->in['displayorder']);
107 $status->update();
108
109 $admin->redirect('status.php?do=modify');
110 }
111
112 // ###################################################################
113
114 if ($_REQUEST['do'] == 'edit')
115 {
116 NavLinks::statusesEdit($input->in['statusid']);
117 $navigator->set_focus('link', 'fields-pages-statuses', 'fields-pages');
118
119 $status = new StatusAPI($bugsys);
120 $status->set('statusid', $input->in['statusid']);
121 $status->set_condition();
122 $status->fetch();
123
124 $admin->page_start(T('Edit Status'));
125
126 $admin->form_start('status.php', 'update');
127 $admin->form_hidden_field('statusid', $status->record['statusid']);
128 $admin->table_start();
129 $admin->table_head(sprintf(T('Edit Status - %1$s (id: %2$s)'), $status->record['status'], $status->record['statusid']));
130 $admin->row_input(T('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status', $status->record['status']);
131 $admin->row_input(T('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder', $status->record['displayorder']);
132 $admin->row_input(T('Status Color<div><dfn>The color 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->record['color']);
133 $admin->row_submit();
134 $admin->table_end();
135 $admin->form_end();
136
137 $admin->page_end();
138 }
139
140 // ###################################################################
141
142 if ($_REQUEST['do'] == 'modify')
143 {
144 NavLinks::statusesAdd();
145 $navigator->set_focus('link', 'fields-pages-statuses', 'fields-pages');
146
147 $admin->page_start(T('Status Manager'));
148
149 $statuses = $db->query("SELECT * FROM " . TABLE_PREFIX . "status");
150
151 $admin->table_start();
152 $admin->table_head(T('Status Manager'));
153
154 foreach ($statuses as $status)
155 {
156 $colorblock = '<span style="float: right"><div style="height: 12px; width: 12px; background-color: ' . $status['color'] . '; border: 1px black solid"></div></span>';
157 $admin->row_text("$colorblock$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]\">[" . T('Edit') . "]</a> <a href=\"status.php?do=delete&amp;statusid=$status[statusid]\">[" . T('Delete') . "]</a>");
158 }
159 $db->free_result($statuses);
160
161 $admin->table_end();
162
163 $admin->page_end();
164 }
165
166 /*=====================================================================*\
167 || ###################################################################
168 || # $HeadURL$
169 || # $Id$
170 || ###################################################################
171 \*=====================================================================*/
172 ?>