r892: Adding and implementing ResolutionAPI
[bugdar.git] / admin / resolution.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_resolution.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 $resolution = new ResolutionAPI($bugsys);
43 $resolution->set('resolutionid', $bugsys->in['resolutionid']);
44 $resolution->set_condition();
45 $resolution->delete();
46
47 build_resolutions();
48 $admin->redirect('resolution.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 resolution? Doing so will revert all bugs to the default resolution (which is set in the options panel)?'), 'resolution.php?do=kill&amp;resolutionid=' . $bugsys->input_clean('resolutionid', TYPE_UINT));
56 }
57
58 // ###################################################################
59
60 if ($_POST['do'] == 'insert')
61 {
62 $resolution = new ResolutionAPI($bugsys);
63 $resolution->set('resolution', $bugsys->in['resolution']);
64 $resolution->set('displayorder', $bugsys->in['displayorder']);
65 $resolution->insert();
66
67 build_resolutions();
68 $admin->redirect('resolution.php?do=modify');
69 }
70
71 // ###################################################################
72
73 if ($_REQUEST['do'] == 'add')
74 {
75 $admin->page_start($lang->string('Add New Resolution'));
76
77 $admin->form_start('resolution.php', 'insert');
78 $admin->table_start();
79 $admin->table_head($lang->string('New Resolution'), 2, 'standard_bug_fields');
80 $admin->row_input($lang->string('Resolution Title<div><dfn>The title of this resolution flag (eg: `Fixed` or `Bogus`)</dfn></div>'), 'resolution');
81 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the resolutions are displayed. The higher the number, the lower down in the list it is.</dfn></div>'), 'displayorder');
82 $admin->row_submit();
83 $admin->table_end();
84 $admin->form_end();
85
86 $admin->page_end();
87 }
88
89 // ###################################################################
90
91 if ($_POST['do'] == 'update')
92 {
93 $resolution = new ResolutionAPI($bugsys);
94 $resolution->set('resolutionid', $bugsys->in['resolutionid']);
95 $resolution->set_condition();
96 $resolution->set('resolution', $bugsys->in['resolution']);
97 $resolution->set('displayorder', $bugsys->in['displayorder']);
98 $resolution->update();
99
100 build_resolutions();
101 $admin->redirect('resolution.php?do=modify');
102 }
103
104 // ###################################################################
105
106 if ($_REQUEST['do'] == 'edit')
107 {
108 $resolution = new ResolutionAPI($bugsys);
109 $resolution->set('resolutionid', $bugsys->in['resolutionid']);
110 $resolution->set_condition();
111 $resolution->fetch();
112
113 $admin->page_start($lang->string('Edit Resolution'), 2, 'standard_bug_fields');
114
115 $admin->form_start('resolution.php', 'update');
116 $admin->form_hidden_field('resolutionid', $resolution->objdata['resolutionid']);
117 $admin->table_start();
118 $admin->table_head(sprintf($lang->string('Edit Resolution - %1$s (id: %2$s)'), $resolution->objdata['resolution'], $resolution->objdata['resolutionid']));
119 $admin->row_input($lang->string('Resolution Title<div><dfn>The title of this resolution flag (eg: `Fixed` or `Bogus`)</dfn></div>'), 'resolution', $resolution->objdata['resolution']);
120 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the resolutions are displayed. The higher the number, the lower down in the list it is.</dfn></div>'), 'displayorder', $resolution->objdata['displayorder']);
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('Resolution Manager'));
133
134 $resolutions = $db->query("SELECT * FROM " . TABLE_PREFIX . "resolution ORDER BY displayorder");
135
136 $admin->form_start('resolution.php', 'null');
137 $admin->table_start();
138 $admin->table_head($lang->string('Resolution Manager'), 2, 'standard_bug_fields');
139
140 while ($resolution = $db->fetch_array($resolutions))
141 {
142 $admin->row_text("$resolution[displayorder]: <a href=\"resolution.php?do=edit&amp;resolutionid=$resolution[resolutionid]\">$resolution[resolution]</a>", "(resolutionid: $resolution[resolutionid]) <a href=\"resolution.php?do=edit&amp;resolutionid=$resolution[resolutionid]\">[" . $lang->string('Edit') . "]</a> <a href=\"resolution.php?do=delete&amp;resolutionid=$resolution[resolutionid]\">[" . $lang->string('Delete') . "]</a>");
143 }
144 $db->free_result($resolutiones);
145
146 $admin->row_span('<a href="resolution.php?do=add">[' . $lang->string('Add New Resolution') . ']</a>', 'tfoot', 'center', 3);
147 $admin->table_end();
148 $admin->form_end();
149
150 $admin->page_end();
151 }
152
153 /*=====================================================================*\
154 || ###################################################################
155 || # $HeadURL$
156 || # $Id$
157 || ###################################################################
158 \*=====================================================================*/
159 ?>