]>
src.bluestatic.org Git - bugdar.git/blob - admin/autoaction.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 \*=====================================================================*/
13 require_once('./global.php');
15 if (!can_perform('canadminbugs'))
20 // ###################################################################
22 if (empty($_REQUEST['do']))
24 $_REQUEST['do'] = 'modify';
27 // ###################################################################
29 if ($_REQUEST['do'] == 'kill')
31 $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['actionid']));
34 $admin->error($lang->getlex('error_invalid_id'));
37 $db->query("DELETE FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = $action[actionid]");
39 $admin->redirect('autoaction.php?do=modify');
42 // ###################################################################
44 if ($_REQUEST['do'] == 'delete')
46 $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['actionid']));
49 $admin->error($lang->getlex('error_invalid_id'));
52 $admin->page_confirm($lang->string('Are you sure you want to delete this action?'), "autoaction.php?do=kill&actionid=$action[actionid]");
55 // ###################################################################
57 if ($_POST['do'] == 'insert' OR $_POST['do'] == 'update')
59 if (empty($bugsys->in
['name']))
61 $admin->error($lang->string('You need to specify a name for this action.'));
64 foreach ($bugsys->in
['fields'] AS $key => $value)
66 if (!empty($value) AND $value != -1 AND !is_array($value))
68 $deltas['builtin']["$key"] = $value;
72 foreach ($bugsys->in['fields']['custom'] AS $key => $value)
74 if (!empty($value) AND $value != -1)
76 $deltas['custom']["$key"] = $value;
80 if (count($deltas['custom']) < 1 AND count($deltas['builtin']) < 1)
82 $admin->error($lang->string('You need to specify some fields to change.'));
85 if ($_POST['do'] == 'insert')
88 INSERT INTO " . TABLE_PREFIX
. "autoaction
89 (name, description, fieldchanges, comment)
91 ('" . $bugsys->in
['name'] . "', '" . $bugsys->in
['description'] . "',
92 '" . $bugsys->escape(serialize($deltas)) . "', '" . $bugsys->in
['comment'] . "'
96 $admin->redirect('autoaction.php');
100 if (!$bugsys->in
['actionid'])
102 $admin->error($lang->getlex('error_invalid_id'));
106 UPDATE " . TABLE_PREFIX
. "autoaction
107 SET name = '" . $bugsys->in
['name'] . "',
108 description = '" . $bugsys->in
['description'] . "',
109 fieldchanges = '" . $bugsys->escape(serialize($deltas)) . "',
110 comment = '" . $bugsys->in
['comment'] . "'
111 WHERE actionid = " . intval($bugsys->in
['actionid'])
114 $admin->redirect('autoaction.php');
118 // ###################################################################
120 if ($_REQUEST['do'] == 'add' OR $_REQUEST['do'] == 'edit')
122 $add = (($_REQUEST['do'] == 'add') ? true : false);
123 $edit = (($add) ? false : true);
127 $action = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "autoaction WHERE actionid = " . intval($bugsys->in
['actionid']));
130 $admin->error($lang->getlex('error_invalid_id'));
132 $action['fields'] = unserialize($action['fieldchanges']);
135 $admin->page_start(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')));
137 $admin->form_start('autoaction.php', ($add ? 'insert' : 'update'));
141 $admin->form_hidden_field('actionid', $action['actionid']);
144 $admin->table_start();
145 $admin->table_head(($add ? $lang->string('New Automatic Action') : $lang->string('Edit Automatic Action')));
147 $admin->row_input($lang->string('Name'), 'name', $action['name']);
148 $admin->row_textarea($lang->string('Description'), 'description', $action['description']);
149 $admin->row_textarea($lang->string('Add Comment'), 'comment', $action['comment']);
151 $admin->row_span($lang->string('Field Changes'), 'thead', 'center');
153 // -------------------------------------------------------------------
155 construct_datastore_select('severity', 'severity', 'severityid', $action['fields']['builtin']['severity'], true, true);
156 $admin->row_list($lang->string('Severity'), 'fields[severity]');
158 construct_datastore_select('priority', 'priority', 'priorityid', $action['fields']['builtin']['priority'], true, true);
159 $admin->row_list($lang->string('Priority'), 'fields[priority]');
161 construct_datastore_select('status', 'status', 'statusid', $action['fields']['builtin']['status'], true, true);
162 $admin->row_list($lang->string('Status'), 'fields[status]');
164 construct_datastore_select('resolution', 'resolution', 'resolutionid', $action['fields']['builtin']['resolution'], true, true);
165 $admin->row_list($lang->string('Resolution'), 'fields[resolution]');
167 $admin->row_span('', 'tcat', 'center');
169 // -------------------------------------------------------------------
171 $fields_fetch = $bugsys->db
->query("
173 FROM " . TABLE_PREFIX
. "bugfield AS bugfield
174 LEFT JOIN " . TABLE_PREFIX
. "bugfieldpermission AS permission
175 ON (bugfield.fieldid = permission.fieldid)
176 WHERE permission.mask <> 0
177 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}
178 AND bugfield.cansearch = 1"
180 while ($field = $bugsys->db
->fetch_array($fields_fetch))
182 switch ($field['type'])
185 $admin->row_input($field['name'], "fields[custom][$field[fieldid]]", $action['fields']['custom']["$field[fieldid]"]);
188 case 'input_checkbox':
189 $admin->list_item('', 0, ((!$action['fields']['custom']["$field[fieldid]"]) ? true : false));
190 $admin->list_item($lang->string('Checked'), 1, (($action['fields']['custom']["$field[fieldid]"] == 1) ? true : false));
191 $admin->list_item($lang->string('Un-Checked'), 2, (($action['fields']['custom']["$field[fieldid]"] == 2) ? true : false));
192 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
195 case 'select_single':
196 $selectopts = unserialize($field['selects']);
198 $admin->list_item('', -1, ((!$action['fields']['custom']["$field[fieldid]"]) ? true : false));
200 foreach ($selectopts AS $id => $select)
202 $admin->list_item(stripslashes($select), $id, (($action['fields']['custom']["$field[fieldid]"] == $id AND $edit) ? true : false));
204 $admin->row_list($field['name'], "fields[custom][$field[fieldid]]");
210 $admin->row_submit();
217 // ###################################################################
219 if ($_REQUEST['do'] == 'modify')
221 $admin->page_start($lang->string('Automatic Actions'));
223 $admin->table_start();
224 $admin->table_head($lang->string('Automatic Actions'));
226 $actions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "autoaction ORDER BY name ASC");
227 while ($action = $db->fetch_array($actions))
229 $admin->row_text($action['name'] . "\n<div class=\"smallfont\">$action[description]</div>", "<a href=\"autoaction.php?do=edit&actionid=$action[actionid]\">[" . $lang->string('Edit') . "]</a> <a href=\"autoaction.php?do=delete&actionid=$action[actionid]\">[" . $lang->string('Delete') . "]</a>");
232 $admin->row_span('<a href="autoaction.php?do=add">[' . $lang->string('New Automatic Action') . ']</a>', 'tfoot', 'center', 3);
238 /*=====================================================================*\
239 || ###################################################################
242 || ###################################################################
243 \*=====================================================================*/