r910: Fixing two SQL free_result() errors
[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/api_resolution.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 $resolution = new ResolutionAPI($bugsys);
45 $resolution->set('resolutionid', $bugsys->in['resolutionid']);
46 $resolution->set_condition();
47 $resolution->delete();
48
49 $admin->redirect('resolution.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 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));
57 }
58
59 // ###################################################################
60
61 if ($_POST['do'] == 'insert')
62 {
63 $resolution = new ResolutionAPI($bugsys);
64 $resolution->set('resolution', $bugsys->in['resolution']);
65 $resolution->set('displayorder', $bugsys->in['displayorder']);
66 $resolution->insert();
67
68 $admin->redirect('resolution.php?do=modify');
69 }
70
71 // ###################################################################
72
73 if ($_REQUEST['do'] == 'add')
74 {
75 NavLinks::resolutionsAdd();
76 $navigator->set_focus('link', 'resolutions-add', 'resolutions');
77
78 $admin->page_start($lang->string('Add New Resolution'));
79
80 $admin->form_start('resolution.php', 'insert');
81 $admin->table_start();
82 $admin->table_head($lang->string('New Resolution'));
83 $admin->row_input($lang->string('Resolution Title<div><dfn>The title of this resolution flag (eg: `Fixed` or `Bogus`)</dfn></div>'), 'resolution');
84 $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');
85 $admin->row_submit();
86 $admin->table_end();
87 $admin->form_end();
88
89 $admin->page_end();
90 }
91
92 // ###################################################################
93
94 if ($_POST['do'] == 'update')
95 {
96 $resolution = new ResolutionAPI($bugsys);
97 $resolution->set('resolutionid', $bugsys->in['resolutionid']);
98 $resolution->set_condition();
99 $resolution->set('resolution', $bugsys->in['resolution']);
100 $resolution->set('displayorder', $bugsys->in['displayorder']);
101 $resolution->update();
102
103 $admin->redirect('resolution.php?do=modify');
104 }
105
106 // ###################################################################
107
108 if ($_REQUEST['do'] == 'edit')
109 {
110 NavLinks::resolutionsEdit($bugsys->in['resolutionid']);
111 $navigator->set_focus('link', 'fields-pages-resolutions', 'fields-pages');
112
113 $resolution = new ResolutionAPI($bugsys);
114 $resolution->set('resolutionid', $bugsys->in['resolutionid']);
115 $resolution->set_condition();
116 $resolution->fetch();
117
118 $admin->page_start($lang->string('Edit Resolution'));
119
120 $admin->form_start('resolution.php', 'update');
121 $admin->form_hidden_field('resolutionid', $resolution->objdata['resolutionid']);
122 $admin->table_start();
123 $admin->table_head(sprintf($lang->string('Edit Resolution - %1$s (id: %2$s)'), $resolution->objdata['resolution'], $resolution->objdata['resolutionid']));
124 $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']);
125 $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']);
126 $admin->row_submit();
127 $admin->table_end();
128 $admin->form_end();
129
130 $admin->page_end();
131 }
132
133 // ###################################################################
134
135 if ($_REQUEST['do'] == 'modify')
136 {
137 NavLinks::resolutionsAdd();
138 $navigator->set_focus('link', 'fields-pages-resolutions', 'fields-pages');
139
140 $admin->page_start($lang->string('Resolution Manager'));
141
142 $resolutions = $db->query("SELECT * FROM " . TABLE_PREFIX . "resolution ORDER BY displayorder");
143
144 $admin->form_start('resolution.php', 'null');
145 $admin->table_start();
146 $admin->table_head($lang->string('Resolution Manager'));
147
148 while ($resolution = $db->fetch_array($resolutions))
149 {
150 $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>");
151 }
152 $db->free_result($resolutions);
153
154 $admin->table_end();
155 $admin->form_end();
156
157 $admin->page_end();
158 }
159
160 /*=====================================================================*\
161 || ###################################################################
162 || # $HeadURL$
163 || # $Id$
164 || ###################################################################
165 \*=====================================================================*/
166 ?>