r908: Implementing new navigation system for the entire "Fields" tab
[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 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 $priority = new PriorityAPI($bugsys);
45 $priority->set('priorityid', $bugsys->in['priorityid']);
46 $priority->set_condition();
47 $priority->delete();
48
49 $admin->redirect('priority.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 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));
57 }
58
59 // ###################################################################
60
61 if ($_POST['do'] == 'insert')
62 {
63 $priority = new PriorityAPI($bugsys);
64 $priority->set('priority', $bugsys->in['priority']);
65 $priority->set('displayorder', $bugsys->in['displayorder']);
66 $priority->insert();
67
68 $admin->redirect('priority.php?do=modify');
69 }
70
71 // ###################################################################
72
73 if ($_REQUEST['do'] == 'add')
74 {
75 NavLinks::prioritiesAdd();
76 $navigator->set_focus('link', 'priorities-add', 'priorities');
77
78 $admin->page_start($lang->string('Add New Priority'));
79
80 $admin->form_start('priority.php', 'insert');
81 $admin->table_start();
82 $admin->table_head($lang->string('New Priority'), 2, 'standard_bug_fields');
83 $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');
84 $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');
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 $priority = new PriorityAPI($bugsys);
97 $priority->set('priorityid', $bugsys->in['priorityid']);
98 $priority->set_condition();
99 $priority->set('priority', $bugsys->in['priority']);
100 $priority->set('displayorder', $bugsys->in['displayorder']);
101 $priority->update();
102
103 $admin->redirect('priority.php?do=modify');
104 }
105
106 // ###################################################################
107
108 if ($_REQUEST['do'] == 'edit')
109 {
110 NavLinks::prioritiesEdit($bugsys->in['priorityid']);
111 $navigator->set_focus('link', 'fields-pages-priorities', 'fields-pages');
112
113 $priority = new PriorityAPI($bugsys);
114 $priority->set('priorityid', $bugsys->in['priorityid']);
115 $priority->set_condition();
116 $priority->fetch();
117
118 $admin->page_start($lang->string('Edit Priority'), 2, 'standard_bug_fields');
119
120 $admin->form_start('priority.php', 'update');
121 $admin->form_hidden_field('priorityid', $priority->objdata['priorityid']);
122 $admin->table_start();
123 $admin->table_head(sprintf($lang->string('Edit Priority `%1$s` (id: %2$s)'), $priority->objdata['priority'], $priority->objdata['priorityid']));
124 $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']);
125 $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']);
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::prioritiesAdd();
138 $navigator->set_focus('link', 'fields-pages-priorities', 'fields-pages');
139
140 $admin->page_start($lang->string('Priority Manager'));
141
142 $priorities = $db->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder");
143
144 $admin->form_start('priority.php', 'null');
145 $admin->table_start();
146 $admin->table_head($lang->string('Priority Manager'), 2, 'standard_bug_fields');
147
148 while ($priority = $db->fetch_array($priorities))
149 {
150 $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>");
151 }
152 $db->free_result($priorities);
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 ?>