r898: Moving the build_*() calls to the APIs
[bugdar.git] / admin / priority.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_priority.php');
24
25 if (!can_perform('canadminfields'))
26 {
27 admin_login();
28 }
29
30 // ###################################################################
31
32 if (empty($_REQUEST['do']))
33 {
34 $_REQUEST['do'] = 'modify';
35 }
36
37 // ###################################################################
38
39 if ($_REQUEST['do'] == 'kill')
40 {
41 $priority = new PriorityAPI($bugsys);
42 $priority->set('priorityid', $bugsys->in['priorityid']);
43 $priority->set_condition();
44 $priority->delete();
45
46 $admin->redirect('priority.php?do=modify');
47 }
48
49 // ###################################################################
50
51 if ($_REQUEST['do'] == 'delete')
52 {
53 $admin->page_confirm($lang->string('Are you sure you want to delete this priority? Doing so will revert all bugs to the default priority (which is set in the options panel)?'), 'priority.php?do=kill&amp;priorityid=' . $bugsys->input_clean('priorityid', TYPE_UINT));
54 }
55
56 // ###################################################################
57
58 if ($_POST['do'] == 'insert')
59 {
60 $priority = new PriorityAPI($bugsys);
61 $priority->set('priority', $bugsys->in['priority']);
62 $priority->set('displayorder', $bugsys->in['displayorder']);
63 $priority->insert();
64
65 $admin->redirect('priority.php?do=modify');
66 }
67
68 // ###################################################################
69
70 if ($_REQUEST['do'] == 'add')
71 {
72 $admin->page_start($lang->string('Add New Priority'));
73
74 $admin->form_start('priority.php', 'insert');
75 $admin->table_start();
76 $admin->table_head($lang->string('New Priority'), 2, 'standard_bug_fields');
77 $admin->row_input($lang->string('Priority Title<div><dfn>The title of this priority flag (eg: `Slated for Development` or `Address Now`)</dfn></div>'), 'priority');
78 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the priorities are displayed. The higher the number, the lower down in the list it is.</dfn></div>'), 'displayorder');
79 $admin->row_submit();
80 $admin->table_end();
81 $admin->form_end();
82
83 $admin->page_end();
84 }
85
86 // ###################################################################
87
88 if ($_POST['do'] == 'update')
89 {
90 $priority = new PriorityAPI($bugsys);
91 $priority->set('priorityid', $bugsys->in['priorityid']);
92 $priority->set_condition();
93 $priority->set('priority', $bugsys->in['priority']);
94 $priority->set('displayorder', $bugsys->in['displayorder']);
95 $priority->update();
96
97 $admin->redirect('priority.php?do=modify');
98 }
99
100 // ###################################################################
101
102 if ($_REQUEST['do'] == 'edit')
103 {
104 $priority = new PriorityAPI($bugsys);
105 $priority->set('priorityid', $bugsys->in['priorityid']);
106 $priority->set_condition();
107 $priority->fetch();
108
109 $admin->page_start($lang->string('Edit Priority'), 2, 'standard_bug_fields');
110
111 $admin->form_start('priority.php', 'update');
112 $admin->form_hidden_field('priorityid', $priority->objdata['priorityid']);
113 $admin->table_start();
114 $admin->table_head(sprintf($lang->string('Edit Priority `%1$s` (id: %2$s)'), $priority->objdata['priority'], $priority->objdata['priorityid']));
115 $admin->row_input($lang->string('Priority Title<div><dfn>The title of this priority flag (eg: `Slated for Development` or `Address Now`)</dfn></div>'), 'priority', $priority->objdata['priority']);
116 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the priorities are displayed. The higher the number, the lower down in the list it is.</dfn></div>'), 'displayorder', $priority->objdata['displayorder']);
117 $admin->row_submit();
118 $admin->table_end();
119 $admin->form_end();
120
121 $admin->page_end();
122 }
123
124 // ###################################################################
125
126 if ($_REQUEST['do'] == 'modify')
127 {
128 $admin->page_start($lang->string('Priority Manager'));
129
130 $priorities = $db->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder");
131
132 $admin->form_start('priority.php', 'null');
133 $admin->table_start();
134 $admin->table_head($lang->string('Priority Manager'), 2, 'standard_bug_fields');
135
136 while ($priority = $db->fetch_array($priorities))
137 {
138 $admin->row_text("$priority[displayorder]: <a href=\"priority.php?do=edit&amp;priorityid=$priority[priorityid]\">$priority[priority]</a>", "(priorityid: $priority[priorityid]) <a href=\"priority.php?do=edit&amp;priorityid=$priority[priorityid]\">[" . $lang->string('Edit') . "]</a> <a href=\"priority.php?do=delete&amp;priorityid=$priority[priorityid]\">[" . $lang->string('Delete') . "]</a>");
139 }
140 $db->free_result($priorities);
141
142 $admin->row_span('<a href="priority.php?do=add">[' . $lang->string('Add New Priority') . ']</a>', 'tfoot', 'center', 3);
143 $admin->table_end();
144 $admin->form_end();
145
146 $admin->page_end();
147 }
148
149 /*=====================================================================*\
150 || ###################################################################
151 || # $HeadURL$
152 || # $Id$
153 || ###################################################################
154 \*=====================================================================*/
155 ?>