r380: Converting some hard-coded text to the language system
[bugdar.git] / admin / status.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 . "status WHERE statusid = " . intval($bugsys->in['statusid']));
33 build_statuses();
34 $admin->redirect('status.php?do=modify');
35 }
36
37 // ###################################################################
38
39 if ($_REQUEST['do'] == 'delete')
40 {
41 $admin->page_confirm(lang::p('confirm_delete_status'), 'status.php?do=kill&amp;statusid=' . intval($bugsys->in['statusid']));
42 }
43
44 // ###################################################################
45
46 if ($_POST['do'] == 'insert')
47 {
48 $db->query("INSERT INTO " . TABLE_PREFIX . "status (status, displayorder, color) VALUES ('" . $bugsys->in['status'] . "', " . intval($bugsys->in['displayorder']) . ", '" . $bugsys->in['color'] . "')");
49 build_statuses();
50 $admin->redirect('status.php?do=modify');
51 }
52
53 // ###################################################################
54
55 if ($_REQUEST['do'] == 'add')
56 {
57 $admin->page_start(lang::p('add_new_status'));
58
59 $admin->form_start('status.php', 'insert');
60 $admin->table_start();
61 $admin->table_head(lang::p('new_status'));
62 $admin->row_input(lang::p('status_title'), 'status');
63 $admin->row_input(lang::p('status_display_order'), 'displayorder');
64 $admin->row_input(lang::p('status_color'), 'color');
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 . "status SET status = '" . $bugsys->in['status'] . "', displayorder = " . intval($bugsys->in['displayorder']) . ", color = '" . $bugsys->in['color'] . "' WHERE statusid = " . intval($bugsys->in['statusid']));
77 build_statuses();
78 $admin->redirect('status.php?do=modify');
79 }
80
81 // ###################################################################
82
83 if ($_REQUEST['do'] == 'edit')
84 {
85 $status = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "status WHERE statusid = " . intval($bugsys->in['statusid']));
86 if (!is_array($status))
87 {
88 $admin->error(lang::p('error_invalid_id'));
89 }
90
91 $admin->page_start(lang::p('edit_status'));
92
93 $admin->form_start('status.php', 'update');
94 $admin->form_hidden_field('statusid', $status['statusid']);
95 $admin->table_start();
96 $admin->table_head(lang::p('edit_status_title', $status['status'], $status['statusid']));
97 $admin->row_input(lang::p('status_title'), 'status', $status['status']);
98 $admin->row_input(lang::p('status_display_order'), 'displayorder', $status['displayorder']);
99 $admin->row_input(lang::p('status_color'), 'color', $status['color']);
100 $admin->row_submit();
101 $admin->table_end();
102 $admin->form_end();
103
104 $admin->page_end();
105 }
106
107 // ###################################################################
108
109 if ($_REQUEST['do'] == 'modify')
110 {
111 $admin->page_start(lang::p('status_manager'));
112
113 $statuses = $db->query("SELECT * FROM " . TABLE_PREFIX . "status");
114
115 $admin->form_start('status.php', 'null');
116 $admin->table_start();
117 $admin->table_head(lang::p('status_manager'));
118
119 while ($status = $db->fetch_array($statuses))
120 {
121 $colourblock = '<span style="float: right"><div style="height: 12px; width: 12px; background-color: ' . $status['color'] . '; border: 1px black solid"></div></span>';
122 $admin->row_text("$colourblock$status[displayorder]: <a href=\"status.php?do=edit&amp;statusid=$status[statusid]\">$status[status]</a>", "(statusid: $status[statusid]) <a href=\"status.php?do=edit&amp;statusid=$status[statusid]\">[" . lang::p('edit') . "]</a> <a href=\"status.php?do=delete&amp;statusid=$status[statusid]\">[" . lang::p('delete') . "]</a>");
123 }
124 $db->free_result($statuses);
125
126 $admin->row_span('<input type="button" name="addug" value=" ' . lang::p('add_new_status') . ' " onclick="window.location = \'status.php?do=add\';" />', 'tfoot', 'center', 3);
127 $admin->table_end();
128 $admin->form_end();
129
130 $admin->page_end();
131 }
132
133 /*=====================================================================*\
134 || ###################################################################
135 || # $HeadURL$
136 || # $Id$
137 || ###################################################################
138 \*=====================================================================*/
139 ?>