r891: Adding and implementing the PriorityAPI
[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/functions_datastore.php');
24 require_once('./includes/api_priority.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 $priority = new PriorityAPI($bugsys);
43 $priority->set('priorityid', $bugsys->in['priorityid']);
44 $priority->set_condition();
45 $priority->delete();
46
47 build_priorities();
48 $admin->redirect('priority.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 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));
56 }
57
58 // ###################################################################
59
60 if ($_POST['do'] == 'insert')
61 {
62 $priority = new PriorityAPI($bugsys);
63 $priority->set('priority', $bugsys->in['priority']);
64 $priority->set('displayorder', $bugsys->in['displayorder']);
65 $priority->insert();
66
67 build_priorities();
68 $admin->redirect('priority.php?do=modify');
69 }
70
71 // ###################################################################
72
73 if ($_REQUEST['do'] == 'add')
74 {
75 $admin->page_start($lang->string('Add New Priority'));
76
77 $admin->form_start('priority.php', 'insert');
78 $admin->table_start();
79 $admin->table_head($lang->string('New Priority'), 2, 'standard_bug_fields');
80 $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');
81 $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');
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 $priority = new PriorityAPI($bugsys);
94 $priority->set('priorityid', $bugsys->in['priorityid']);
95 $priority->set_condition();
96 $priority->set('priority', $bugsys->in['priority']);
97 $priority->set('displayorder', $bugsys->in['displayorder']);
98 $priority->update();
99
100 build_priorities();
101 $admin->redirect('priority.php?do=modify');
102 }
103
104 // ###################################################################
105
106 if ($_REQUEST['do'] == 'edit')
107 {
108 $priority = new PriorityAPI($bugsys);
109 $priority->set('priorityid', $bugsys->in['priorityid']);
110 $priority->set_condition();
111 $priority->fetch();
112
113 $admin->page_start($lang->string('Edit Priority'), 2, 'standard_bug_fields');
114
115 $admin->form_start('priority.php', 'update');
116 $admin->form_hidden_field('priorityid', $priority->objdata['priorityid']);
117 $admin->table_start();
118 $admin->table_head(sprintf($lang->string('Edit Priority `%1$s` (id: %2$s)'), $priority->objdata['priority'], $priority->objdata['priorityid']));
119 $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']);
120 $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']);
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('Priority Manager'));
133
134 $priorities = $db->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder");
135
136 $admin->form_start('priority.php', 'null');
137 $admin->table_start();
138 $admin->table_head($lang->string('Priority Manager'), 2, 'standard_bug_fields');
139
140 while ($priority = $db->fetch_array($priorities))
141 {
142 $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>");
143 }
144 $db->free_result($priorities);
145
146 $admin->row_span('<a href="priority.php?do=add">[' . $lang->string('Add New Priority') . ']</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 ?>