r665: Renaming product from "BugStrike" to "Bugdar"
[bugdar.git] / admin / status.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]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->string('Are you sure you want to delete this status? Doing so will revert all bugs to the default status (which is set in the options panel)?'), '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->string('Add New Status'));
58
59 $admin->form_start('status.php', 'insert');
60 $admin->table_start();
61 $admin->table_head($lang->string('New Status'), 2, 'standard_bug_fields');
62 $admin->row_input($lang->string('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status');
63 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder');
64 $admin->row_input($lang->string('Status Colour<div><dfn>The colour of the status. This will be displayed on bug listings page to make viewing easier. Note: you must enter the # sign if you are using HEX values.</dfn></div>'), '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->getlex('error_invalid_id'));
89 }
90
91 $admin->page_start($lang->string('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(sprintf($lang->string('Edit Status - %1$s (id: %2$s)'), $status['status'], $status['statusid']), 2, 'standard_bug_fields');
97 $admin->row_input($lang->string('Status Title<div><dfn>The title of this status flag (eg: `Confirmed` or `Closed (Fixed)`)</dfn></div>'), 'status', $status['status']);
98 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the statuses ar displayed.</dfn></div>'), 'displayorder', $status['displayorder']);
99 $admin->row_input($lang->string('Status Colour<div><dfn>The colour of the status. This will be displayed on bug listings page to make viewing easier. Note: you must enter the # sign if you are using HEX values.</dfn></div>'), '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->string('Status Manager'));
112
113 $statuses = $db->query("SELECT * FROM " . TABLE_PREFIX . "status");
114
115 $admin->table_start();
116 $admin->table_head($lang->string('Status Manager'), 2, 'standard_bug_fields');
117
118 while ($status = $db->fetch_array($statuses))
119 {
120 $colourblock = '<span style="float: right"><div style="height: 12px; width: 12px; background-color: ' . $status['color'] . '; border: 1px black solid"></div></span>';
121 $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->string('Edit') . "]</a> <a href=\"status.php?do=delete&amp;statusid=$status[statusid]\">[" . $lang->string('Delete') . "]</a>");
122 }
123 $db->free_result($statuses);
124
125 $admin->row_span('<a href="status.php?do=add">[' . $lang->string('Add New Status') . ']</a>', 'tfoot', 'center', 3);
126 $admin->table_end();
127
128 $admin->page_end();
129 }
130
131 /*=====================================================================*\
132 || ###################################################################
133 || # $HeadURL$
134 || # $Id$
135 || ###################################################################
136 \*=====================================================================*/
137 ?>