r433: Merging the locale-change branch onto trunk; we now use ISSO's localize system
[bugdar.git] / admin / priority.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 require_once('./global.php');
14 require_once('./includes/functions_datastore.php');
15
16 if (!can_perform('canadminfields'))
17 {
18 admin_login();
19 }
20
21 // ###################################################################
22
23 if (empty($_REQUEST['do']))
24 {
25 $_REQUEST['do'] = 'modify';
26 }
27
28 // ###################################################################
29
30 if ($_REQUEST['do'] == 'kill')
31 {
32 $db->query("DELETE FROM " . TABLE_PREFIX . "priority WHERE priorityid = " . intval($bugsys->in['priorityid']));
33 build_priorities();
34 $admin->redirect('priority.php?do=modify');
35 }
36
37 // ###################################################################
38
39 if ($_REQUEST['do'] == 'delete')
40 {
41 $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=' . intval($bugsys->in['priorityid']));
42 }
43
44 // ###################################################################
45
46 if ($_POST['do'] == 'insert')
47 {
48 sanitize(array('priority' => STR, 'displayorder' => INT));
49 $db->query("INSERT INTO " . TABLE_PREFIX . "priority (priority, displayorder) VALUES ('" . $bugsys->in['priority'] . "'," . intval($bugsys->in['displayorder']) . ")");
50 build_priorities();
51 $admin->redirect('priority.php?do=modify');
52 }
53
54 // ###################################################################
55
56 if ($_REQUEST['do'] == 'add')
57 {
58 $admin->page_start($lang->string('Add New Priority'));
59
60 $admin->form_start('priority.php', 'insert');
61 $admin->table_start();
62 $admin->table_head($lang->string('New Priority'));
63 $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');
64 $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');
65 $admin->row_submit();
66 $admin->table_end();
67 $admin->form_end();
68
69 $admin->page_end();
70 }
71
72 // ###################################################################
73
74 if ($_POST['do'] == 'update')
75 {
76 $db->query("UPDATE " . TABLE_PREFIX . "priority SET priority = '" . $bugsys->in['priority'] . "', displayorder = " . intval($bugsys->in['displayorder']) . " WHERE priorityid = " . intval($bugsys->in['priorityid']));
77 build_priorities();
78 $admin->redirect('priority.php?do=modify');
79 }
80
81 // ###################################################################
82
83 if ($_REQUEST['do'] == 'edit')
84 {
85 $priority = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "priority WHERE priorityid = " . intval($bugsys->in['priorityid']));
86 if (!is_array($priority))
87 {
88 $admin->error($lang->getkex('error_invalid_id'));
89 }
90
91 $admin->page_start($lang->string('Edit Priority'));
92
93 $admin->form_start('priority.php', 'update');
94 $admin->form_hidden_field('priorityid', $priority['priorityid']);
95 $admin->table_start();
96 $admin->table_head(sprintf($lang->string('Edit Priority `%1$s` (id: %2$s)', $priority['priority'], $priority['priorityid'])));
97 $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['priority']);
98 $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['displayorder']);
99 $admin->row_submit();
100 $admin->table_end();
101 $admin->form_end();
102
103 $admin->page_end();
104 }
105
106 // ###################################################################
107
108 if ($_REQUEST['do'] == 'modify')
109 {
110 $admin->page_start($lang->string('Priority Manager'));
111
112 $priorities = $db->query("SELECT * FROM " . TABLE_PREFIX . "priority ORDER BY displayorder");
113
114 $admin->form_start('priority.php', 'null');
115 $admin->table_start();
116 $admin->table_head($lang->string('Priority Manager'));
117
118 while ($priority = $db->fetch_array($priorities))
119 {
120 $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>");
121 }
122 $db->free_result($priorityes);
123
124 $admin->row_span('<a href="priority.php?do=add">[' . $lang->string('Add New Priority') . ']</a>', 'tfoot', 'center', 3);
125 $admin->table_end();
126 $admin->form_end();
127
128 $admin->page_end();
129 }
130
131 /*=====================================================================*\
132 || ###################################################################
133 || # $HeadURL$
134 || # $Id$
135 || ###################################################################
136 \*=====================================================================*/
137 ?>