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